This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
- Author
- David Coeurjolly (
david.nosp@m..coe.nosp@m.urjol.nosp@m.ly@l.nosp@m.iris..nosp@m.cnrs.nosp@m..fr ) Laboratoire d'InfoRmatique en Image et Systemes d'information - LIRIS (CNRS, UMR 5205), CNRS, France
- Date
- 2014/11/16
Functions for testing class Color.
This file is part of the DGtal library.
Definition in file testColor.cpp.
Example of a test. To be completed.
Definition at line 48 of file testColor.cpp.
49{
50 unsigned int nbok = 0;
51 unsigned int nb = 0;
52
54
57 Color gg(64,64,64,255);
58 Color w(255,255,255,255);
59
61 nbok += ((b+
g)==
g) ? 1 : 0;
62 nb++;
63 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
64 << "add" << std::endl;
65
66 trace.
info() <<
" g+g = gg "<<
g*2<<
" expected ="<<gg<<std::endl;
67 nbok += ((
g+
g)==gg) ? 1 : 0;
68 nb++;
69 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
70 << "add (bis)" << std::endl;
71
72 trace.
info() <<
" W+W = w "<< w+w<<std::endl;
73 nbok += ((w+w)==w) ? 1 : 0;
74 nb++;
75 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
76 << "max " << std::endl;
77
78 trace.
info() <<
" g*2 = gg "<<
g*2<<
" expected ="<<gg<<std::endl;
79 nbok += ((
g*2)==gg) ? 1 : 0;
80 nb++;
81 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
82 << "coeff" << std::endl;
83
86 nb++;
87 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
88 << "coeff" << std::endl;
89
90 trace.
info() <<
" 2*g = gg "<< 2.0*
g<<
" expected ="<<gg<<std::endl;
91 nbok += ((2*
g)==gg) ? 1 : 0;
92 nb++;
93 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
94 << "coeff" << std::endl;
95
96
100#ifdef COLOR_WITH_ALPHA_ARITH
101 trace.
info() <<
" a+aa = "<< a+aa<<std::endl;
102 nbok += (c ==
Color(0,0,0,96)) ? 1 : 0;
103 nb++;
104 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
105 << "alpha arith (enabled)" << std::endl;
106#else
107 trace.
info() <<
" a+aa = "<< a+aa<<std::endl;
108 nbok += (c ==
Color(0,0,0,64)) ? 1 : 0;
109 nb++;
110 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
111 << "alpha arith (disabled)" << std::endl;
112#endif
113
117 trace.
info() <<
" val == Color::Red "<< val<<std::endl;
119 nb++;
120
121 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
122 << "red" << std::endl;
123
124
125 const auto is_trivially_copyable_ = std::is_trivially_copyable<Color>::value;
126 trace.
info() <<
"is_trivially_copyable: "<< is_trivially_copyable_ <<std::endl;
127 nbok += (is_trivially_copyable_) ? 1 : 0;
128 nb++;
129 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
130 << "is_trivially_copyable" << std::endl;
131
133
134 return nbok == nb;
135}
Structure representing an RGB triple with alpha component.
Color & setRGBi(const unsigned char aRedValue, const unsigned char aGreenValue, const unsigned char aBlueValue, const unsigned char aAlphaValue=255)
References DGtal::Trace::beginBlock(), DGtal::Trace::endBlock(), g(), DGtal::Trace::info(), DGtal::Color::Red, DGtal::Color::setRGBi(), and DGtal::trace.
Referenced by main().