OSDN Git Service

merge src/ and test/ at driver/
[happyabc/happyabc.git] / driver / colorTest.ml
1 open Base
2 open Color
3 open OUnit
4
5 let ok ?msg x y =
6   OUnit.assert_equal ~printer:Std.dump ?msg
7     x y
8
9 let _  = ("color.ml" >::: [
10             "rgb" >::
11               (fun () ->
12                  ok Color.red @@ Color.rgb 255 0 0
13               );
14             "#-format" >::
15               (fun () ->
16                  ok {Color.red=255;
17                      green=255;
18                      blue=255;
19                      alpha=1.0} @@
20                    Color.parse "#ffffFF";
21                  ok {Color.red=0x00;
22                      green=0x22;
23                      blue=0x33;
24                      alpha=1.0} @@
25                    Color.parse "#002233";
26               );
27             "rgb-format" >::
28               (fun () ->
29                  ok {Color.red=255;
30                      green=255;
31                      blue=255;
32                      alpha=1.0} @@
33                    Color.parse "rgb(255,255,255)";
34                  ok {Color.red=00;
35                      green=22;
36                      blue=33;
37                      alpha=1.0} @@
38                    Color.parse "rgb(00, 22 , 33)";
39               );
40             "name" >::
41               (fun () ->
42                  List.iter (fun (c,name) ->
43                               ok ~msg:name c @@ Color.parse name;
44                               ok ~msg:name c @@ Color.parse @@ String.uppercase name;
45                               ok ~msg:name c @@ Color.parse @@ String.capitalize name)
46                    [red,"red";
47                     lime,"lime";
48                     blue,"blue";
49                     white,"white";
50                     maroon,"maroon";
51                     green,"green";
52                     navy,"navy";
53                     silver,"silver";
54                     yellow,"yellow";
55                     aqua,"aqua";
56                     fuchsia,"fuchsia";
57                     gray,"gray";
58                     olive,"olive";
59                     teal,"teal";
60                     purple,"purple";
61                     black,"black"]);
62             "of_int" >::
63               (fun () ->
64                  ok {red=0x12; green=0x34; blue=0x56; alpha=1.0} @@
65                    Color.of_int 0x123456);
66             "to_int" >::
67               (fun () ->
68                  ok 0x123456 @@
69                    Color.to_int {red=0x12; green=0x34; blue=0x56; alpha=1.0})
70           ]) +> run_test_tt_main