@@ -5,56 +5,65 @@ use crate::mock_graph::{
5
5
} ;
6
6
use duplicate:: duplicate_item;
7
7
use graphene:: core:: {
8
- property:: { AddEdge , HasVertex , NewVertex , UniqueGraph , VertexInGraph } ,
8
+ property:: { AddEdge , HasVertex , NewVertex , SimpleGraph , UniqueGraph , VertexInGraph } ,
9
9
Directed , EnsureUnloaded , Graph , ReleaseUnloaded , Undirected ,
10
10
} ;
11
11
12
12
#[ duplicate_item(
13
- directedness; [ Directed ] ; [ Undirected ]
13
+ test_graph directedness_to_test edge_type;
14
+ [ UniqueGraph ] [ [ Directed ] ; [ Undirected ] ] [ MockEdgeWeight ] ;
15
+ [ SimpleGraph ] [ [ Undirected ] ] [ ( ) ]
14
16
) ]
15
17
mod __
16
18
{
17
19
use super :: * ;
18
-
19
- /// Tests that UniqueGraph correctly identifies unique graphs.
20
- # [ quickcheck ]
21
- fn accept_unique ( g : Arb < UniqueGraph < MockGraph < directedness > > > ) -> bool
20
+ # [ duplicate_item (
21
+ directedness ; directedness_to_test
22
+ ) ]
23
+ mod __
22
24
{
23
- UniqueGraph :: validate ( & g. 0 . release_all ( ) )
24
- }
25
+ use super :: * ;
25
26
26
- /// Tests that UniqueGraph correctly rejects non-unique graphs.
27
- #[ quickcheck]
28
- fn reject_non_unique ( g : Arb < NonUniqueGraph < directedness > > ) -> bool
29
- {
30
- ! UniqueGraph :: validate ( & g. 0 )
31
- }
27
+ /// Tests that test_graph correctly identifies its own graphs.
28
+ #[ quickcheck]
29
+ fn accept_property ( g : Arb < test_graph < MockGraph < directedness , edge_type > > > ) -> bool
30
+ {
31
+ test_graph :: validate ( & g. 0 . release_all ( ) )
32
+ }
32
33
33
- /// Tests that a UniqueGraph accepts adding a non-duplicate edge
34
- #[ quickcheck]
35
- fn accept_add_edge (
36
- Arb ( mut g) : Arb < VertexInGraph < UniqueGraph < MockGraph < directedness > > > > ,
37
- v_weight : MockVertexWeight ,
38
- e_weight : MockEdgeWeight ,
39
- ) -> bool
40
- {
41
- let v = g. get_vertex ( ) . clone ( ) ;
42
- // To ensure we add a non-duplicate edge,
43
- // we create a new vertex and add an edge to it from an existing one.
44
- let v2 = g. new_vertex_weighted ( v_weight) . unwrap ( ) ;
45
- let accepted = g. add_edge_weighted ( & v, & v2, e_weight) . is_ok ( ) ;
46
- accepted && g. edges_between ( v, & v2) . count ( ) == 1
47
- }
34
+ /// Tests that test_graph correctly rejects non-unique graphs.
35
+ #[ quickcheck]
36
+ fn reject_non_unique ( g : Arb < NonUniqueGraph < directedness , edge_type > > ) -> bool
37
+ {
38
+ !test_graph:: validate ( & g. 0 )
39
+ }
48
40
49
- /// Tests that a UniqueGraph rejects adding a duplicate edge
50
- #[ quickcheck]
51
- fn reject_add_edge (
52
- Arb ( g) : Arb < EdgeIn < UniqueGraph < MockGraph < directedness > > > > ,
53
- weight : MockEdgeWeight ,
54
- ) -> bool
55
- {
56
- let source = g. get_vertex ( ) ;
57
- let EdgeIn ( mut g, sink, _) = g;
58
- g. add_edge_weighted ( source, sink, weight) . is_err ( )
41
+ /// Tests that a test_graph accepts adding a non-duplicate edge
42
+ #[ quickcheck]
43
+ fn accept_add_edge (
44
+ Arb ( mut g) : Arb < VertexInGraph < test_graph < MockGraph < directedness , edge_type > > > > ,
45
+ v_weight : MockVertexWeight ,
46
+ e_weight : edge_type ,
47
+ ) -> bool
48
+ {
49
+ let v = g. get_vertex ( ) . clone ( ) ;
50
+ // To ensure we add a non-duplicate edge,
51
+ // we create a new vertex and add an edge to it from an existing one.
52
+ let v2 = g. new_vertex_weighted ( v_weight) . unwrap ( ) ;
53
+ let accepted = g. add_edge_weighted ( & v, & v2, e_weight) . is_ok ( ) ;
54
+ accepted && g. edges_between ( v, & v2) . count ( ) == 1
55
+ }
56
+
57
+ /// Tests that a test_graph rejects adding a duplicate edge
58
+ #[ quickcheck]
59
+ fn reject_add_edge (
60
+ Arb ( g) : Arb < EdgeIn < test_graph < MockGraph < directedness , edge_type > > > > ,
61
+ weight : edge_type ,
62
+ ) -> bool
63
+ {
64
+ let source = g. get_vertex ( ) ;
65
+ let EdgeIn ( mut g, sink, _) = g;
66
+ g. add_edge_weighted ( source, sink, weight) . is_err ( )
67
+ }
59
68
}
60
69
}
0 commit comments