/[projet1]/public/pc/tools/osdk/main/pictconv/sources/Tests/colortest.cpp
Defence Force logotype

Contents of /public/pc/tools/osdk/main/pictconv/sources/Tests/colortest.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 878 - (show annotations)
Tue Sep 25 23:15:36 2012 UTC (6 years, 11 months ago) by mmu_man
File size: 3576 byte(s)
Fix absolute windows paths in #include

GRMBL

1
2 #include "../../../../shared_libraries/unittestcpp/v1.4/src/UnitTest++.h"
3
4 #include "shifter_color.h"
5 #include "getpixel.h"
6
7
8 TEST(ColorTest)
9 {
10 // Test the STE bit conversion tables
11 CHECK_EQUAL( 0,ShifterColor::ValueToSte(0));
12 CHECK_EQUAL( 8,ShifterColor::ValueToSte(1));
13 CHECK_EQUAL( 1,ShifterColor::ValueToSte(2));
14 CHECK_EQUAL( 9,ShifterColor::ValueToSte(3));
15 CHECK_EQUAL( 2,ShifterColor::ValueToSte(4));
16 CHECK_EQUAL(10,ShifterColor::ValueToSte(5));
17 CHECK_EQUAL( 3,ShifterColor::ValueToSte(6));
18 CHECK_EQUAL(11,ShifterColor::ValueToSte(7));
19 CHECK_EQUAL( 4,ShifterColor::ValueToSte(8));
20 CHECK_EQUAL(12,ShifterColor::ValueToSte(9));
21 CHECK_EQUAL( 5,ShifterColor::ValueToSte(10));
22 CHECK_EQUAL(13,ShifterColor::ValueToSte(11));
23 CHECK_EQUAL( 6,ShifterColor::ValueToSte(12));
24 CHECK_EQUAL(14,ShifterColor::ValueToSte(13));
25 CHECK_EQUAL( 7,ShifterColor::ValueToSte(14));
26 CHECK_EQUAL(15,ShifterColor::ValueToSte(15));
27
28 // Test the reversed STE bit conversion tables
29 CHECK_EQUAL( 0,ShifterColor::ValueFromSte( 0));
30 CHECK_EQUAL( 1,ShifterColor::ValueFromSte( 8));
31 CHECK_EQUAL( 2,ShifterColor::ValueFromSte( 1));
32 CHECK_EQUAL( 3,ShifterColor::ValueFromSte( 9));
33 CHECK_EQUAL( 4,ShifterColor::ValueFromSte( 2));
34 CHECK_EQUAL( 5,ShifterColor::ValueFromSte(10));
35 CHECK_EQUAL( 6,ShifterColor::ValueFromSte( 3));
36 CHECK_EQUAL( 7,ShifterColor::ValueFromSte(11));
37 CHECK_EQUAL( 8,ShifterColor::ValueFromSte( 4));
38 CHECK_EQUAL( 9,ShifterColor::ValueFromSte(12));
39 CHECK_EQUAL(10,ShifterColor::ValueFromSte( 5));
40 CHECK_EQUAL(11,ShifterColor::ValueFromSte(13));
41 CHECK_EQUAL(12,ShifterColor::ValueFromSte( 6));
42 CHECK_EQUAL(13,ShifterColor::ValueFromSte(14));
43 CHECK_EQUAL(14,ShifterColor::ValueFromSte( 7));
44 CHECK_EQUAL(15,ShifterColor::ValueFromSte(15));
45
46 // Test the big endian conversion
47 CHECK_EQUAL(0x0000,ShifterColor(RgbColor(0,0,0)).GetBigEndianValue());
48 CHECK_EQUAL(0x000F,ShifterColor(RgbColor(255,0,0)).GetBigEndianValue());
49 CHECK_EQUAL(0xF000,ShifterColor(RgbColor(0,255,0)).GetBigEndianValue());
50 CHECK_EQUAL(0x0F00,ShifterColor(RgbColor(0,0,255)).GetBigEndianValue());
51 CHECK_EQUAL(0xFF0F,ShifterColor(RgbColor(255,255,255)).GetBigEndianValue());
52
53 // Test the RGB conversion
54 CHECK(RgbColor(0,0,0)==ShifterColor(RgbColor(0,0,0)).GetRgb());
55 CHECK(RgbColor(255,0,0)==ShifterColor(RgbColor(255,0,0)).GetRgb());
56 CHECK(RgbColor(0,255,0)==ShifterColor(RgbColor(0,255,0)).GetRgb());
57 CHECK(RgbColor(0,0,255)==ShifterColor(RgbColor(0,0,255)).GetRgb());
58 CHECK(RgbColor(255,255,255)==ShifterColor(RgbColor(255,255,255)).GetRgb());
59
60 // Test the error computation
61 CHECK_EQUAL( 0,ShifterColor(RgbColor(0,0,0)).ComputeDifference(ShifterColor(RgbColor(0,0,0))));
62 CHECK_EQUAL( 0,ShifterColor(RgbColor(255,0,0)).ComputeDifference(ShifterColor(RgbColor(255,0,0))));
63 CHECK_EQUAL( 0,ShifterColor(RgbColor(255,255,255)).ComputeDifference(ShifterColor(RgbColor(255,255,255))));
64 CHECK_EQUAL( 49,ShifterColor(RgbColor(128,0,0)).ComputeDifference(ShifterColor(RgbColor(0,0,0))));
65 CHECK_EQUAL(675,ShifterColor(RgbColor(255,255,255)).ComputeDifference(ShifterColor(RgbColor(0,0,0))));
66
67 // Test the RGB color operators
68 CHECK(RgbColor(0,0,0)==RgbColor(0,0,0));
69 CHECK(RgbColor(255,0,0)==RgbColor(255,0,0));
70 CHECK(RgbColor(0,255,0)==RgbColor(0,255,0));
71 CHECK(RgbColor(0,0,255)==RgbColor(0,0,255));
72 CHECK(RgbColor(255,255,255)==RgbColor(255,255,255));
73
74 CHECK(RgbColor(0,0,0)!=RgbColor(1,0,0));
75 CHECK(RgbColor(255,0,0)!=RgbColor(23,0,0));
76 CHECK(RgbColor(48,0,0)!=RgbColor(48,1,0));
77 }
78
79

  ViewVC Help
Powered by ViewVC 1.1.26