Revert "Device/Driver/LX: Add small delay after baud rate change"
[xcsoar.git] / test / src / TestColorRamp.cpp
blob83f7ab43106fda3f0a48f8629ed82796d85337bd
1 /* Copyright_License {
3 XCSoar Glide Computer - http://www.xcsoar.org/
4 Copyright (C) 2000-2013 The XCSoar Project
5 A detailed list of copyright holders can be found in the file "AUTHORS".
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; either version 2
10 of the License, or (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #include "Screen/Ramp.hpp"
24 #include "Screen/Color.hpp"
25 #include "TestUtil.hpp"
27 int main(int argc, char **argv)
29 const ColorRamp ramp[] = {
30 {0, 0xff, 0x80, 0x00},
31 {1000, 0x00, 0x40, 0xcc},
33 const ColorRamp ramp2[] = {
34 {-1000, 0x00, 0x00, 0xff},
35 { -1, 0x00, 0xff, 0xff},
36 { 0, 0xff, 0xff, 0x00},
37 { 1000, 0xff, 0x00, 0x00},
39 Color color;
41 plan_tests(39);
43 // Test lower limit
44 color = ColorRampLookup(0, ramp, 2);
45 ok1(color.Red() == 0xff);
46 ok1(color.Green() == 0x80);
47 ok1(color.Blue() == 0x00);
49 // Test below lower limit
50 color = ColorRampLookup(-100, ramp, 2);
51 ok1(color.Red() == 0xff);
52 ok1(color.Green() == 0x80);
53 ok1(color.Blue() == 0x00);
55 // Test upper limit
56 color = ColorRampLookup(1000, ramp, 2);
57 ok1(color.Red() == 0x00);
58 ok1(color.Green() == 0x40);
59 ok1(color.Blue() == 0xcc);
61 // Test above upper limit
62 color = ColorRampLookup(1500, ramp, 2);
63 ok1(color.Red() == 0x00);
64 ok1(color.Green() == 0x40);
65 ok1(color.Blue() == 0xcc);
67 // Test middle
68 color = ColorRampLookup(500, ramp, 2);
69 ok1(color.Red() == 0x7f);
70 ok1(color.Green() == 0x60);
71 ok1(color.Blue() == 0x66);
75 // Test lower limit
76 color = ColorRampLookup(-1000, ramp2, 4);
77 ok1(color.Red() == 0x00);
78 ok1(color.Green() == 0x00);
79 ok1(color.Blue() == 0xff);
81 // Test below lower limit
82 color = ColorRampLookup(-2000, ramp2, 4);
83 ok1(color.Red() == 0x00);
84 ok1(color.Green() == 0x00);
85 ok1(color.Blue() == 0xff);
87 // Test upper limit
88 color = ColorRampLookup(1000, ramp2, 4);
89 ok1(color.Red() == 0xff);
90 ok1(color.Green() == 0x00);
91 ok1(color.Blue() == 0x00);
93 // Test above upper limit
94 color = ColorRampLookup(2000, ramp2, 4);
95 ok1(color.Red() == 0xff);
96 ok1(color.Green() == 0x00);
97 ok1(color.Blue() == 0x00);
99 // Test interpolation point 1
100 color = ColorRampLookup(0, ramp2, 4);
101 ok1(color.Red() == 0xff);
102 ok1(color.Green() == 0xff);
103 ok1(color.Blue() == 0x00);
105 // Test interpolation point 2
106 color = ColorRampLookup(-1, ramp2, 4);
107 ok1(color.Red() == 0x00);
108 ok1(color.Green() == 0xff);
109 ok1(color.Blue() == 0xff);
111 // Test intermediate point 1
112 color = ColorRampLookup(500, ramp2, 4);
113 ok1(color.Red() == 0xff);
114 ok1(color.Green() == 0x7f);
115 ok1(color.Blue() == 0x00);
117 // Test intermediate point 2
118 color = ColorRampLookup(-500, ramp2, 4);
119 ok1(color.Red() == 0x00);
120 ok1(color.Green() == 0x7f);
121 ok1(color.Blue() == 0xff);
123 return exit_status();