File: test.adb

package info (click to toggle)
libgnatcoll 18-4
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 5,068 kB
  • sloc: ada: 40,393; python: 354; ansic: 310; makefile: 245; sh: 31
file content (35 lines) | stat: -rw-r--r-- 1,017 bytes parent folder | download | duplicates (3)
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
with Test_Assert;
with GNATCOLL.JSON;
with GNATCOLL.VFS;
with GNAT.Strings;
with Ada.Command_Line;
with Ada.Exceptions;

function Test return Integer is
   package A renames Test_Assert;
   package JSON renames GNATCOLL.JSON;
   package VFS renames GNATCOLL.VFS;

   procedure Test (JSON_String : String);

   procedure Test (JSON_String : String) is
   begin
      declare
         V : JSON.JSON_Value;
      begin
         V := JSON.Read(JSON_String);
         A.Assert (False, "invalid json (exception not raised)");
      exception
         when JSON.Invalid_JSON_Stream =>
            A.Assert (True, "failed with Invalid_JSON_Stream");
         when E : others =>
            A.Assert (False, "invalid json: (wrong exception)" & ASCII.LF &
                      Ada.Exceptions.Exception_Information (E));
      end;
   end Test;

   File_Content : GNAT.Strings.String_Access := VFS.Read_File (VFS.Create(VFS."+"(Ada.Command_Line.Argument (1))));
begin
   Test (File_Content.all); 
   return A.Report;
end Test;