]> git.mxchange.org Git - simgear.git/blob - simgear/misc/parse_color_test.cxx
Remove OpenVG dependency from header file
[simgear.git] / simgear / misc / parse_color_test.cxx
1 #include <simgear/compiler.h>
2
3 #include "parse_color.hxx"
4
5 #include <iostream>
6
7 #define COMPARE(a, b) \
8   if( (a) != (b) ) \
9   { \
10     std::cerr << "failed:" << #a << " != " << #b << std::endl; \
11     return 1; \
12   }
13
14 #define VERIFY(a) \
15   if( !(a) ) \
16   { \
17     std::cerr << "failed:" << #a << std::endl; \
18     return 1; \
19   }
20
21 #define VERIFY_COLOR(str, r, g, b, a) \
22   VERIFY(simgear::parseColor(str, color)) \
23   COMPARE(color, osg::Vec4(r, g, b, a))
24     
25 int main (int ac, char ** av)
26 {
27   osg::Vec4 color;
28   VERIFY_COLOR("#ff0000", 1,0,0,1);
29   VERIFY_COLOR("#00ff00", 0,1,0,1);
30   VERIFY_COLOR("#0000ff", 0,0,1,1);
31   VERIFY_COLOR("rgb( 255,\t127.5,0)", 1, 0.5, 0, 1);
32   VERIFY_COLOR("rgba(255,  127.5,0, 0.5)", 1, 0.5, 0, 0.5);
33   std::cout << "all tests passed successfully!" << std::endl;
34   return 0;
35 }