zeromq_ada_4.1.5_b2a857f7/eBindings/dl/tests/dl-test_basics.adb

 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
with ada.Text_IO;
with GNAT.Source_Info;
with AUnit.Assertions;
with System.Address_Image;
with Interfaces.C.Strings;
with ada.Unchecked_Conversion;
package body Dl.Test_Basics is
   use AUnit;
   use AUnit.Assertions;

   -- Fixture elements


   ----------
   -- Name --
   ----------

   function Name (T : Test_Case)
                  return AUnit.Message_String is
      pragma Unreferenced (T);
   begin
      return Format (GNAT.Source_Info.File & ":(no description)");
   end Name;


   -------------------------
   --  SampleTest
   -------------------------
   procedure SampleTest (Test : in out AUnit.Test_Cases.Test_Case'Class) is
      T : Test_Case renames Test_Case (Test);
      pragma Unreferenced (T);
      P : Dynamic_Library;
      type zlibVersion_Access is access function return Interfaces.C.Strings.chars_ptr;
      function conv is new ada.Unchecked_Conversion (system.Address, zlibVersion_Access);
      zlibVersion : zlibVersion_Access;
   begin
      p.open (File_Name => "/lib/libz.so.1");
      zlibVersion := conv (p.Sym ("zlibVersion"));
      declare
         version : constant string := Interfaces.C.Strings.Value (zlibVersion.all);
      begin
         test.Assert (Version (version'first + 1 ) = '.', "Dont seem to be a version numnber");
         test.Assert (Version (version'first + 3 ) = '.', "Dont seem to be a version numnber");
      end;

      p.close;
   end SampleTest;

   --------------------
   -- Register_Tests --
   --------------------

   procedure Register_Tests (T : in out Test_Case) is
      use Test_Cases.Registration;

   begin
      Register_Routine  (T, SampleTest'Access, "SampleTest");
   end Register_Tests;

end Dl.Test_Basics;