Overview
Comment: | s_expressions-test_tools: new helper procedure to test all atom accessors at once |
---|---|
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
962add2a19953fa6263d4fd0d1c4b728 |
User & Date: | nat on 2014-02-17 19:43:39 |
Other Links: | manifest | tags |
Context
2014-02-18
| ||
20:34 | s_expressions-test_tools: new helper procedure to test exception throwing from all atom accessors check-in: 04e35d38a1 user: nat tags: trunk | |
2014-02-17
| ||
19:43 | s_expressions-test_tools: new helper procedure to test all atom accessors at once check-in: 962add2a19 user: nat tags: trunk | |
2014-02-16
| ||
17:59 | s_expressions-generic_caches: fix duplication of child lists check-in: 50ec4ef40a user: nat tags: trunk | |
Changes
Modified tests/natools-s_expressions-test_tools.adb from [32354a28b6] to [157c2660bd].
︙ | |||
198 199 200 201 202 203 204 205 206 207 208 209 210 211 | 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | if Found /= Expected then Test.Fail; Dump_Atom (Test, Found, "Found"); Dump_Atom (Test, Expected, "Expected"); end if; end Test_Atom; procedure Test_Atom_Accessors (Test : in out NT.Test; Tested : in Descriptor'Class; Expected : in Atom; Expected_Level : in Integer := -1) is Print_Expected : Boolean := False; begin if Tested.Current_Event /= Events.Add_Atom then Test.Error ("Test_Atom_Accessors called with current event " & Events.Event'Image (Tested.Current_Event)); return; end if; if Expected_Level >= 0 then Current_Level_Test : declare Level : constant Natural := Tested.Current_Level; begin if Level /= Expected_Level then Test.Fail ("Current_Level is" & Integer'Image (Level) & ", expected" & Integer'Image (Expected_Level)); end if; end Current_Level_Test; end if; Current_Atom_Test : declare Current_Atom : constant Atom := Tested.Current_Atom; begin if Current_Atom /= Expected then Print_Expected := True; Test.Fail; Dump_Atom (Test, Current_Atom, "Current_Atom"); end if; end Current_Atom_Test; Query_Atom_Test : declare procedure Process (Data : in Atom); Calls : Natural := 0; Buffer : Atom_Buffers.Atom_Buffer; procedure Process (Data : in Atom) is begin Calls := Calls + 1; Buffer.Append (Data); end Process; begin Tested.Query_Atom (Process'Access); if Calls = 0 then Test.Fail ("Query_Atom did not call Process"); elsif Calls > 1 then Test.Fail ("Query_Atom called Process" & Integer'Image (Calls) & " times"); Print_Expected := True; Dump_Atom (Test, Buffer.Data, "Buffer"); elsif Buffer.Data /= Expected then Print_Expected := True; Test.Fail; Dump_Atom (Test, Buffer.Data, "Query_Atom"); end if; end Query_Atom_Test; Long_Read_Atom_Test : declare Buffer : Atom (21 .. Expected'Length + 30); Length : Count; begin Tested.Read_Atom (Buffer, Length); if Buffer (Buffer'First .. Buffer'First + Length - 1) /= Expected then Print_Expected := True; Test.Fail; Dump_Atom (Test, Buffer (Buffer'First .. Buffer'First + Length - 1), "Read_Atom"); end if; end Long_Read_Atom_Test; Short_Read_Atom_Test : declare Buffer : Atom (11 .. Expected'Length / 2 + 10); Length : Count; begin Tested.Read_Atom (Buffer, Length); if Expected (Expected'First .. Expected'First + Buffer'Length - 1) /= Buffer then Print_Expected := True; Test.Fail; Dump_Atom (Test, Buffer, "Short Read_Atom"); end if; end Short_Read_Atom_Test; if Print_Expected then Dump_Atom (Test, Expected, "Expected"); end if; end Test_Atom_Accessors; ------------------- -- Memory Stream -- ------------------- overriding procedure Read |
︙ |
Modified tests/natools-s_expressions-test_tools.ads from [ec3eb81d6e] to [92a8d34147].
︙ | |||
52 53 54 55 56 57 58 59 60 61 62 63 64 65 | 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | + + + + + + + | procedure Test_Atom (Test : in out NT.Test; Expected : in Atom; Found : in Atom); -- Report success when Found is equal to Expected, and failure -- with diagnostics otherwise. procedure Test_Atom_Accessors (Test : in out NT.Test; Tested : in Descriptor'Class; Expected : in Atom; Expected_Level : in Integer := -1); -- Test all the ways of accessing atom in Tested type Memory_Stream is new Ada.Streams.Root_Stream_Type with private; overriding procedure Read (Stream : in out Memory_Stream; Item : out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset); |
︙ |