summaryrefslogtreecommitdiff
path: root/graph_macro/tests/works.rs
diff options
context:
space:
mode:
Diffstat (limited to 'graph_macro/tests/works.rs')
-rw-r--r--graph_macro/tests/works.rs95
1 files changed, 90 insertions, 5 deletions
diff --git a/graph_macro/tests/works.rs b/graph_macro/tests/works.rs
index fe8a853..a57e866 100644
--- a/graph_macro/tests/works.rs
+++ b/graph_macro/tests/works.rs
@@ -1,13 +1,98 @@
#![allow(dead_code)]
-use graph_macro::Testing;
+use graph_macro::Graph;
-#[derive(Debug, Testing)]
-struct Haha {
- size: usize,
+#[derive(Debug, Graph, Default)]
+pub(crate) struct Haha {
+ test: String,
+ #[graph]
+ little_graph: graph::ALGraph,
+}
+
+#[derive(Debug)]
+/// Testing docs
+#[allow(unused)]
+#[derive(Default, Graph)]
+pub struct HahaU(pub(crate) graph::ALGraph);
+
+#[derive(Debug, Graph)]
+pub struct HahaG<T: graph::GraphLabel> {
+ graph: graph::DLGraph<T>,
+}
+
+impl<T: graph::GraphLabel> Default for HahaG<T> {
+ fn default() -> Self {
+ Self {
+ graph: Default::default(),
+ }
+ }
+}
+
+#[derive(Debug, Graph)]
+pub struct HahaW<T>
+where
+ T: graph::GraphLabel,
+{
+ name: String,
+ #[graph]
+ graph: graph::DLGraph<T>,
+}
+
+impl<T: graph::GraphLabel> Default for HahaW<T> {
+ fn default() -> Self {
+ Self {
+ name: Default::default(),
+ graph: Default::default(),
+ }
+ }
+}
+
+impl Haha {
+ fn new(test: impl ToString) -> Self {
+ use graph::builder::Builder;
+
+ let test = test.to_string();
+ let mut little_graph_builder: graph::adlist::ALGBuilder = Default::default();
+
+ little_graph_builder.add_vertex();
+ little_graph_builder.add_vertex();
+ little_graph_builder.add_edge(0, 1, ()).unwrap();
+
+ let little_graph = little_graph_builder.build();
+
+ Self { little_graph, test }
+ }
}
#[test]
fn it_works() {
- println!("it works: {:?}", Haha { size: 0 });
+ use graph::{builder::Builder, Graph};
+ let haha = Haha::new("test");
+
+ assert!(!haha.is_empty());
+
+ assert_eq!(haha.has_edge(0, 1), Ok(true));
+
+ let hahaw = HahaW::<usize>::default();
+
+ assert!(hahaw.is_empty());
+
+ assert!(matches!(
+ hahaw.has_edge(0, 1),
+ Err(graph::error::Error::IndexOutOfBounds(0, 0))
+ ));
+
+ let mut builder: graph::adlist::ALGBuilder = Default::default();
+
+ let first = builder.add_vertex();
+ let second = builder.add_vertex();
+ builder.add_edge(first, second, ()).unwrap();
+
+ let hahau = HahaU(builder.build());
+
+ assert!(!hahau.is_empty());
+
+ assert_eq!(hahau.has_edge(0, 1), Ok(true));
+
+ dbg!(haha, hahaw, hahau);
}