cashe_1.0.0_d142893b/tests/src/cashe_currency_tests.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
with Ada.Assertions; use Ada.Assertions;
with Cashe; use Cashe;
with Cashe.Currency_Handling; use Cashe.Currency_Handling;
package body Cashe_Currency_Tests is

   procedure Run_Tests is

      --  Create some currency for simple testing.
      King_Currency : constant Custom_Currency :=
         Create (Code => "AJ", Minor_Unit => 2,
               Name => "AJ Currency", Symbol => "👑");
      Bitcoin : constant Custom_Currency :=
         Create (Code => "BTC", Minor_Unit => 8,
               Name => "Bitcoin", Symbol => "฿");
      Ethereum : constant Custom_Currency :=
         Create (Code => "ETH", Minor_Unit => 18,
               Name => "Ether", Symbol => "Ξ");
      Cardano : constant Custom_Currency :=
         Create (Code => "ADA", Minor_Unit => 15,
               Name => "Cardano", Symbol => "₳");
      RadCur   : constant Custom_Currency :=
         Create (Code => "RAD", Minor_Unit => 0,
               Name => "Rad Currency", Symbol => "☢");

   begin
      --  Create a currency of every precision.
      for I in 0 .. Cashe.Max_Precision loop
         declare
            One : constant Custom_Currency :=
               Create (I'Wide_Wide_Image, I,
                        "Currency " & I'Wide_Wide_Image, I'Wide_Wide_Image);
            Two : Custom_Currency;
         begin
            Two.Set_Code   (One.Code);
            Two.Set_Name   (One.Name);
            Two.Set_Symbol (One.Symbol);
            Two.Set_Unit   (One.Unit);
            Assert (Two.Code = I'Wide_Wide_Image);
            Assert (Two.Name = "Currency " & I'Wide_Wide_Image);
            Assert (Two.Symbol = I'Wide_Wide_Image);
            Assert (Two.Unit = I);
         end;
      end loop;

   end Run_Tests;
end Cashe_Currency_Tests;