blob: 5d3aa330294e611518002642b70343c0a0dc9e33 (
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
|
-- with Ada.Text_IO, Ada.Exceptions;
-- use Ada.Text_IO, Ada.Exceptions;
package body Graph_Tests.Basic is
function To_Graph_Check
return Test_Result
is
Illegal_Graph : Graphs.Graph;
begin
begin
Illegal_Graph := Graphs.To_Graph (No_Nodes, Some_Edges);
return Fail;
exception
when Constraint_Error => null;
end;
begin
Illegal_Graph := Graphs.To_Graph (Dup_Nodes, No_Edges);
return Fail;
exception
when Constraint_Error => null;
end;
return Pass;
end To_Graph_Check;
function Is_Empty_Check
return Test_Result is
begin
if My_Empty_Graph.Is_Empty and not My_Nonempty_Graph.Is_Empty then
return Pass;
else
return Fail;
end if;
end Is_Empty_Check;
function Clear_Check
return Test_Result
is
My_Cleared_Graph : Graphs.Graph := My_Nonempty_Graph;
begin
My_Cleared_Graph.Clear;
if My_Cleared_Graph.Is_Empty then
return Pass;
else
return Fail;
end if;
end Clear_Check;
function Cursor_Element_Check
return Test_Result
is
use type Graphs.Cursor;
My_Cursor : Graphs.Cursor;
begin
if Graphs.Has_Element (Graphs.No_Element) or
Graphs.Element (Graphs.No_Element) /= Graphs.Extended_Node_ID_Type'First
then
return Fail;
end if;
My_Cursor := My_Nonempty_Graph.To_Cursor (2);
if not Graphs.Has_Element (My_Cursor) or
Graphs.Element (My_Cursor) /= 2
then
return Fail;
end if;
My_Cursor := My_Empty_Graph.To_Cursor (1);
if My_Cursor /= Graphs.No_Element then
return Fail;
end if;
return Pass;
end Cursor_Element_Check;
function Equals_Check
return Test_Result
is
use type Graphs.Graph;
Other_Nonempty_Graph : Graphs.Graph := Graphs.To_Graph (Some_Nodes, Some_Edges);
begin
if not (Graphs.Empty_Graph = My_Empty_Graph) or
My_Empty_Graph = My_Nonempty_Graph or
not (My_Nonempty_Graph = Other_Nonempty_Graph)
then
return Fail;
else
return Pass;
end if;
end Equals_Check;
function Assign_Check
return Test_Result
is
use type Graphs.Graph;
Target_Graph : Graphs.Graph := Graphs.Empty_Graph;
begin
if Target_Graph = My_Nonempty_Graph then
return Fail;
end if;
Target_Graph.Assign (My_Nonempty_Graph);
if not (Target_Graph = My_Nonempty_Graph) then
return Fail;
end if;
return Pass;
end Assign_Check;
function Copy_Check
return Test_Result
is
use type Graphs.Graph;
begin
if My_Nonempty_Graph.Copy = My_Empty_Graph or
not (My_Nonempty_Graph.Copy = My_Nonempty_Graph)
then
return Fail;
end if;
return Pass;
end Copy_Check;
function Move_Check
return Test_Result
is
use type Graphs.Graph;
Source_Graph : Graphs.Graph := My_Nonempty_Graph;
Target_Graph : Graphs.Graph := Graphs.Empty_Graph;
begin
Target_Graph.Move (Source_Graph);
if not (Source_Graph = Graphs.Empty_Graph) or
not (Target_Graph = My_Nonempty_Graph)
then
return Fail;
end if;
return Pass;
end Move_Check;
end Graph_Tests.Basic;
|