Natools

Check-in [4f2d39211e]
Login
Overview
Comment:chunked_str0ings-tests: further improve coverage (900/924 lines)
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 4f2d39211e7233406dc99d88e438374965b49998
User & Date: nat on 2013-09-30 18:50:00
Other Links: manifest | tags
Context
2013-10-01
18:49
chunked_strings: remove some (hopefully) dead code check-in: 585443dcaf user: nat tags: trunk
2013-09-30
18:50
chunked_str0ings-tests: further improve coverage (900/924 lines) check-in: 4f2d39211e user: nat tags: trunk
2013-09-29
14:29
chunked_str0ings-tests: add a few more tests to improve coverage check-in: 2536bbf623 user: nat tags: trunk
Changes

Modified tests/natools-chunked_strings-tests-coverage.adb from [e9a5d7e043] to [364a803ccf].

12
13
14
15
16
17
18

19
20
21
22
23
24
25
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26







+







-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN    --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF  --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.           --
------------------------------------------------------------------------------

with Ada.Exceptions;
with Ada.Strings.Fixed;
with Ada.Strings.Maps;

procedure Natools.Chunked_Strings.Tests.Coverage
  (Report : in out Natools.Tests.Reporter'Class)
is
   package NT renames Natools.Tests;

   procedure Report_Result
324
325
326
327
328
329
330





















































331
332
333
334
335
336
337
338
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+








         NT.Info (Report, "Smaller >= CS_Name");
      end if;

      if CS_Name <= Smaller then
         Report_Result (Name, Reported);
         NT.Info (Report, "CS_Name <= Smaller");
      end if;

      Report_Result (Name, Reported, NT.Success);
   exception
      when Error : others => NT.Report_Exception (Report, Name, Error);
   end;

   declare
      Name : constant String := "Procedure Index, backwards without match";
      CS : constant Chunked_String := To_Chunked_String (Name);
      N : Natural;
   begin
      N := Index
        (Source => CS,
         Set => Ada.Strings.Maps.To_Set ("."),
         Test => Ada.Strings.Inside,
         Going => Ada.Strings.Backward);

      if N /= 0 then
         NT.Item (Report, Name, NT.Fail);
         NT.Info (Report, "Unexpected match at" & Natural'Image (N));
      else
         NT.Item (Report, Name, NT.Success);
      end if;
   exception
      when Error : others => NT.Report_Exception (Report, Name, Error);
   end;

   declare
      Name : constant String := "Function Trim, one-sided";
      Str : constant String := "   word  ";
      Reported : Boolean := False;
   begin
      declare
         CS : constant Chunked_String := To_Chunked_String (Str);
         Left : constant String
           := Ada.Strings.Fixed.Trim (Str, Ada.Strings.Left);
         Right : constant String
           := Ada.Strings.Fixed.Trim (Str, Ada.Strings.Right);
         CS_Left : constant Chunked_String := Trim (CS, Ada.Strings.Left);
         CS_Right : constant Chunked_String := Trim (CS, Ada.Strings.Right);
      begin
         if To_String (CS_Left) /= Left then
            Report_Result (Name, Reported);
            NT.Info (Report, "Found """ & To_String (CS_Left) & '"');
            NT.Info (Report, "Expected """ & Left & '"');
         end if;

         if To_String (CS_Right) /= Right then
            Report_Result (Name, Reported);
            NT.Info (Report, "Found """ & To_String (CS_Right) & '"');
            NT.Info (Report, "Expected """ & Right & '"');
         end if;
      end;

      Report_Result (Name, Reported, NT.Success);
   exception
      when Error : others => NT.Report_Exception (Report, Name, Error);
   end;

   Natools.Tests.End_Section (Report);
end Natools.Chunked_Strings.Tests.Coverage;