summaryrefslogtreecommitdiff
path: root/test/graph_tests-labels.adb
blob: b99eb5df009d50f6e67a88b26729bc62a3109852 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201


package body Graph_Tests.Labels is


    function Getter_Setter_Check
        return Test_Result
    is
        Copy_Graph : Graphs.Graph := My_Nonempty_Graph;
    begin
        if Copy_Graph.Has_Label (2) then
            return Fail;
        end if;
        Copy_Graph.Append_Label (2, Node_Label (+"OMG"));
        if not Copy_Graph.Has_Label (2) or
            Copy_Graph.Label (2) /= Node_Label (+"OMG")
        then
            return Fail;
        end if;
        if Copy_Graph.Has_Label ((7, 2, 5)) then
            return Fail;
        end if;
        Copy_Graph.Append_Label ((7, 2, 5), Edge_Label (+"EDGY"));
        if not Copy_Graph.Has_Label ((7, 2, 5)) or
            Copy_Graph.Label ((7, 2, 5)) /= Edge_Label (+"EDGY")
        then
            return Fail;
        end if;
        return Pass;
    end Getter_Setter_Check;


    function Replace_Label_Check
        return Test_Result
    is
        Copy_Graph : Graphs.Graph := My_Nonempty_Graph;
    begin
        begin
            Copy_Graph.Replace_Label (2, Node_Label (+"OMG"));
            return Fail;
        exception
            when Constraint_Error => null;
        end;
        Copy_Graph.Append_Label (2, Node_Label (+"OMG"));
        Copy_Graph.Replace_Label (2, Node_Label (+"NOOO"));
        if Copy_Graph.Label (2) /= Node_Label (+"NOOO") then
            return Fail;
        end if;
        begin
            Copy_Graph.Replace_Label ((7, 2, 5), Edge_Label (+"EDGY"));
            return Fail;
        exception
            when Constraint_Error => null;
        end;
        Copy_Graph.Append_Label ((7, 2, 5), Edge_Label (+"EDGY"));
        Copy_Graph.Replace_Label ((7, 2, 5), Edge_Label (+"YEES"));
        if Copy_Graph.Label ((7, 2, 5)) /= Edge_Label (+"YEES") then
            return Fail;
        end if;
        return Pass;
    end Replace_Label_Check;


    function Delete_Label_Check
        return Test_Result
    is
        Copy_Graph : Graphs.Graph := My_Nonempty_Graph;
    begin
        Copy_Graph.Append_Label (2, Node_Label (+"A"));
        Copy_Graph.Delete_Label (2);
        if Copy_Graph.Has_Label (2) then
            return Fail;
        end if;
        Copy_Graph.Append_Label ((7, 2, 5), Edge_Label (+"B"));
        Copy_Graph.Delete_Label ((7, 2, 5));
        if Copy_Graph.Has_Label ((7, 2, 5)) then
            return Fail;
        end if;
        return Pass;
    end Delete_Label_Check;


    function Const_Ref_Check
        return Test_Result
    is
        Copy_Graph : Graphs.Graph := My_Nonempty_Graph;
    begin
        Copy_Graph.Append_Label (2, Node_Label (+"A"));
        Copy_Graph.Append_Label ((7, 2, 5), Edge_Label (+"B"));
        begin
            declare
                Ref : Graphs.Node_Label_Constant_Reference :=
                    Copy_Graph.Constant_Label_Reference (11);
            begin
                return Fail;
            end;
        exception
            when Constraint_Error => null;
        end;
        begin
            declare
                Ref : Graphs.Edge_Label_Constant_Reference :=
                    Copy_Graph.Constant_Label_Reference ((5, 11, 2));
            begin
                return Fail;
            end;
        exception
            when Constraint_Error => null;
        end;
        if Copy_Graph.Constant_Label_Reference (2) /= Node_Label (+"A") or
            Copy_Graph.Constant_Label_Reference ((7, 2, 5)) /= Edge_Label (+"B")
        then
            return Fail;
        end if;
        return Pass;
    end Const_Ref_Check;


    function Ref_Check
        return Test_Result
    is
        Copy_Graph : Graphs.Graph := My_Nonempty_Graph;
    begin
        Copy_Graph.Append_Label (2, Node_Label (+"A"));
        Copy_Graph.Append_Label ((7, 2, 5), Edge_Label (+"B"));
        begin
            declare
                Ref : Graphs.Node_Label_Reference :=
                    Copy_Graph.Label_Reference (11);
            begin
                return Fail;
            end;
        exception
            when Constraint_Error => null;
        end;
        begin
            declare
                Ref : Graphs.Edge_Label_Reference :=
                    Copy_Graph.Label_Reference ((5, 11, 2));
            begin
                return Fail;
            end;
        exception
            when Constraint_Error => null;
        end;
        if Copy_Graph.Label_Reference (2) /= Node_Label (+"A") or
            Copy_Graph.Label_Reference ((7, 2, 5)) /= Edge_Label (+"B")
        then
            return Fail;
        end if;
        Copy_Graph.Label_Reference (2) := Node_Label (+"C");
        Copy_Graph.Label_Reference ((7, 2, 5)) := Edge_Label (+"D");
        if Copy_Graph.Label_Reference (2) /= Node_Label (+"C") or
            Copy_Graph.Label_Reference ((7, 2, 5)) /= Edge_Label (+"D")
        then
            return Fail;
        end if;
        return Pass;
    end Ref_Check;


    function Has_Labeled_Edge_Check
        return Test_Result
    is
        Copy_Graph : Graphs.Graph := My_Nonempty_Graph;
    begin
        Copy_Graph.Append_Label ((5, 11, 2), Edge_Label (+"BLAH"));
        if not Copy_Graph.Has_Labeled_Edge (11, 2) or
            Copy_Graph.Has_Labeled_Edge (2, 5) or
            Copy_Graph.Has_Labeled_Edge (2, 11)
        then
            return Fail;
        end if;
        return Pass;
    end Has_Labeled_Edge_Check;


    function Clear_Labels_Check
        return Test_Result
    is
        Copy_Graph : Graphs.Graph := My_Nonempty_Graph;
    begin
        Copy_Graph.Append_Label (2, Node_Label (+"A"));
        Copy_Graph.Append_Label (11, Node_Label (+"B"));
        Copy_Graph.Append_Label ((7, 2, 5), Edge_Label (+"C"));
        Copy_Graph.Append_Label ((5, 11, 2), Edge_Label (+"D"));
        Copy_Graph.Clear_Labels;
        if Copy_Graph.Has_Label (2) or
            Copy_Graph.Has_Label (11) or
            Copy_Graph.Has_Label ((7, 2, 5)) or
            Copy_Graph.Has_Label ((5, 11, 2))
        then
            return Fail;
        end if;
        return Pass;
    end Clear_Labels_Check;


end Graph_Tests.Labels;