1 | --------------------------------------------------------------- {{{1 ---------- |
---|---|
2 | --: Copyright © 2007 … 2023 Martin Krischik «krischik@users.sourceforge.net» |
3 | ------------------------------------------------------------------------------- |
4 | --: Ada_Demo is free software: you can redistribute it and/or modify it under |
5 | --: the terms of the GNU General Public License as published by the Free |
6 | --: Software Foundation, either version 3 of the License, or (at your option) |
7 | --: any later version. |
8 | --: |
9 | --: Ada_Demo is distributed in the hope that it will be useful, but WITHOUT |
10 | --: ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
11 | --: FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
12 | --: more details. |
13 | --: |
14 | --: You should have received a copy of the GNU General Public License along |
15 | --: with Ada_Demo. If not, see <http://www.gnu.org/licenses/>. |
16 | --------------------------------------------------------------- }}}1----------- |
17 | |
18 | pragma License (Modified_Gpl); |
19 | pragma Ada_2022; |
20 | |
21 | with Ada.Strings.Unbounded; |
22 | with Ada.Strings.Wide_Unbounded; |
23 | with Ada.Strings.Wide_Wide_Unbounded; |
24 | with Ada.Calendar; |
25 | with GNAT.Source_Info; |
26 | |
27 | --- |
28 | -- @summary |
29 | -- Enhanced assertions |
30 | -- |
31 | -- @description |
32 | -- Additional Asserts which produce more detailed diagnostic messages Diagnostics will be reported via the |
33 | -- Report_Assertion function. The Report function is passed as a generic ot avoid dependence to AUnit. |
34 | -- |
35 | generic |
36 | |
37 | with procedure Report_Assertion |
38 | (Condition : Boolean := False; |
39 | Message : String; |
40 | Source : String; |
41 | Line : Natural) is <>; |
42 | |
43 | package AdaCL.Assert is |
44 | |
45 | ---------- Unbounded_String -------------------------------- {{{1 ---------- |
46 | |
47 | --- |
48 | -- Assert that a unbounded string is equal a given value |
49 | -- |
50 | --: @param Actual Actual value |
51 | --: @param Expected Expected value |
52 | --: @param Name Name of variable or function restlt. |
53 | --: @param Source Source code |
54 | --: @param Line Line number |
55 | procedure Equal |
56 | (Actual : Ada.Strings.Unbounded.Unbounded_String; |
57 | Expected : String; |
58 | Name : String; |
59 | Source : String := GNAT.Source_Info.File; |
60 | Line : Natural := GNAT.Source_Info.Line); |
61 | |
62 | --- |
63 | -- Assert that a unbounded string is equal a given value |
64 | -- |
65 | --: @param Actual Actual value |
66 | --: @param Expected Expected value |
67 | --: @param Name Name of variable or function restlt. |
68 | --: @param Source Source code |
69 | --: @param Line Line number |
70 | procedure Equal |
71 | (Actual : Ada.Strings.Unbounded.Unbounded_String; |
72 | Expected : Ada.Strings.Unbounded.Unbounded_String; |
73 | Name : String; |
74 | Source : String := GNAT.Source_Info.File; |
75 | Line : Natural := GNAT.Source_Info.Line); |
76 | |
77 | --- |
78 | -- Assert that a string is of given length |
79 | -- |
80 | --: @param Actual Actual value |
81 | --: @param Expected Expected value |
82 | --: @param Name Name of variable or function restlt. |
83 | --: @param Source Source code |
84 | --: @param Line Line number |
85 | procedure Length |
86 | (Actual : Ada.Strings.Unbounded.Unbounded_String; |
87 | Expected : Natural; |
88 | Name : String; |
89 | Source : String := GNAT.Source_Info.File; |
90 | Line : Natural := GNAT.Source_Info.Line); |
91 | |
92 | ---------- Wide_Unbounded_String --------------------------- {{{1 ---------- |
93 | |
94 | --- |
95 | -- Assert that a unbounded string is equal a given value |
96 | -- |
97 | --: @param Actual Actual value |
98 | --: @param Expected Expected value |
99 | --: @param Name Name of variable or function restlt. |
100 | --: @param Source Source code |
101 | --: @param Line Line number |
102 | procedure Equal |
103 | (Actual : Ada.Strings.Wide_Unbounded.Unbounded_Wide_String; |
104 | Expected : Wide_String; |
105 | Name : String; |
106 | Source : String := GNAT.Source_Info.File; |
107 | Line : Natural := GNAT.Source_Info.Line); |
108 | |
109 | --- |
110 | -- Assert that a unbounded string is equal a given value |
111 | -- |
112 | --: @param Actual Actual value |
113 | --: @param Expected Expected value |
114 | --: @param Name Name of variable or function restlt. |
115 | --: @param Source Source code |
116 | --: @param Line Line number |
117 | procedure Equal |
118 | (Actual : Ada.Strings.Wide_Unbounded.Unbounded_Wide_String; |
119 | Expected : Ada.Strings.Wide_Unbounded.Unbounded_Wide_String; |
120 | Name : String; |
121 | Source : String := GNAT.Source_Info.File; |
122 | Line : Natural := GNAT.Source_Info.Line); |
123 | |
124 | --- |
125 | -- Assert that a string is of given length |
126 | -- |
127 | --: @param Actual Actual value |
128 | --: @param Expected Expected value |
129 | --: @param Name Name of variable or function restlt. |
130 | --: @param Source Source code |
131 | --: @param Line Line number |
132 | procedure Length |
133 | (Actual : Ada.Strings.Wide_Unbounded.Unbounded_Wide_String; |
134 | Expected : Natural; |
135 | Name : String; |
136 | Source : String := GNAT.Source_Info.File; |
137 | Line : Natural := GNAT.Source_Info.Line); |
138 | |
139 | ---------- Wide_Wide_Unbounded_String --------------------------- {{{1 ---------- |
140 | |
141 | --- |
142 | -- Assert that a unbounded string is equal a given value |
143 | -- |
144 | --: @param Actual Actual value |
145 | --: @param Expected Expected value |
146 | --: @param Name Name of variable or function restlt. |
147 | --: @param Source Source code |
148 | --: @param Line Line number |
149 | procedure Equal |
150 | (Actual : Ada.Strings.Wide_Wide_Unbounded.Unbounded_Wide_Wide_String; |
151 | Expected : Wide_Wide_String; |
152 | Name : String; |
153 | Source : String := GNAT.Source_Info.File; |
154 | Line : Natural := GNAT.Source_Info.Line); |
155 | |
156 | --- |
157 | -- Assert that a unbounded string is equal a given value |
158 | -- |
159 | --: @param Actual Actual value |
160 | --: @param Expected Expected value |
161 | --: @param Name Name of variable or function restlt. |
162 | --: @param Source Source code |
163 | --: @param Line Line number |
164 | procedure Equal |
165 | (Actual : Ada.Strings.Wide_Wide_Unbounded.Unbounded_Wide_Wide_String; |
166 | Expected : Ada.Strings.Wide_Wide_Unbounded.Unbounded_Wide_Wide_String; |
167 | Name : String; |
168 | Source : String := GNAT.Source_Info.File; |
169 | Line : Natural := GNAT.Source_Info.Line); |
170 | |
171 | --- |
172 | -- Assert that a string is of given length |
173 | -- |
174 | --: @param Actual Actual value |
175 | --: @param Expected Expected value |
176 | --: @param Name Name of variable or function restlt. |
177 | --: @param Source Source code |
178 | --: @param Line Line number |
179 | procedure Length |
180 | (Actual : Ada.Strings.Wide_Wide_Unbounded.Unbounded_Wide_Wide_String; |
181 | Expected : Natural; |
182 | Name : String; |
183 | Source : String := GNAT.Source_Info.File; |
184 | Line : Natural := GNAT.Source_Info.Line); |
185 | |
186 | ---------- Boolean ----------------------------------------- {{{1 ---------- |
187 | |
188 | --- |
189 | -- Assert that Boolean is true |
190 | -- |
191 | --: @param Actual Actual value |
192 | --: @param Name Name of variable or function restlt. |
193 | --: @param Source Source code |
194 | --: @param Line Line number |
195 | procedure Is_True |
196 | (Actual : Boolean; |
197 | Name : String; |
198 | Source : String := GNAT.Source_Info.File; |
199 | Line : Natural := GNAT.Source_Info.Line); |
200 | |
201 | --- |
202 | -- Assert that Boolean is false |
203 | -- |
204 | --: @param Actual Actual value |
205 | --: @param Name Name of variable or function restlt. |
206 | --: @param Source Source code |
207 | --: @param Line Line number |
208 | procedure Is_False |
209 | (Actual : Boolean; |
210 | Name : String; |
211 | Source : String := GNAT.Source_Info.File; |
212 | Line : Natural := GNAT.Source_Info.Line); |
213 | |
214 | ---------- Time ------------------------------------------- {{{1 ---------- |
215 | |
216 | --- |
217 | -- Assert that a Time value is equal a given value |
218 | -- |
219 | --: @param Actual Actual value |
220 | --: @param Expected Expected value |
221 | --: @param Name Name of variable or function restlt. |
222 | --: @param Source Source code |
223 | --: @param Line Line number |
224 | procedure Equal |
225 | (Actual : Ada.Calendar.Time; |
226 | Expected : Ada.Calendar.Time; |
227 | Name : String; |
228 | Source : String := GNAT.Source_Info.File; |
229 | Line : Natural := GNAT.Source_Info.Line); |
230 | |
231 | --: ------------------------------------------------------- }}}1 ---------- |
232 | |
233 | end AdaCL.Assert; |
234 | |
235 | ---------------------------------------------------------------- {{{ ---------- |
236 | --: vim: set textwidth=0 nowrap tabstop=8 shiftwidth=3 softtabstop=3 expandtab : |
237 | --: vim: set filetype=ada fileencoding=utf-8 fileformat=unix foldmethod=marker : |
238 | --: vim: set spell spelllang=en_gb |