919 |
30 Nov 09 |
jari |
// $Id$ |
919 |
30 Nov 09 |
jari |
2 |
|
919 |
30 Nov 09 |
jari |
3 |
/* |
978 |
12 Dec 09 |
peter |
Copyright (C) 2009 Jari Häkkinen, Peter Johansson |
1635 |
30 Mar 23 |
peter |
Copyright (C) 2010, 2023 Peter Johansson |
919 |
30 Nov 09 |
jari |
6 |
|
919 |
30 Nov 09 |
jari |
This file is part of svndigest, http://dev.thep.lu.se/svndigest |
919 |
30 Nov 09 |
jari |
8 |
|
919 |
30 Nov 09 |
jari |
svndigest is free software; you can redistribute it and/or modify it |
919 |
30 Nov 09 |
jari |
under the terms of the GNU General Public License as published by |
919 |
30 Nov 09 |
jari |
the Free Software Foundation; either version 3 of the License, or |
919 |
30 Nov 09 |
jari |
(at your option) any later version. |
919 |
30 Nov 09 |
jari |
13 |
|
919 |
30 Nov 09 |
jari |
svndigest is distributed in the hope that it will be useful, but |
919 |
30 Nov 09 |
jari |
WITHOUT ANY WARRANTY; without even the implied warranty of |
919 |
30 Nov 09 |
jari |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
919 |
30 Nov 09 |
jari |
General Public License for more details. |
919 |
30 Nov 09 |
jari |
18 |
|
919 |
30 Nov 09 |
jari |
You should have received a copy of the GNU General Public License |
919 |
30 Nov 09 |
jari |
along with svndigest. If not, see <http://www.gnu.org/licenses/>. |
919 |
30 Nov 09 |
jari |
21 |
*/ |
919 |
30 Nov 09 |
jari |
22 |
|
1619 |
12 Mar 23 |
peter |
23 |
#include <config.h> |
1619 |
12 Mar 23 |
peter |
24 |
|
1162 |
13 Aug 10 |
peter |
25 |
#include "Suite.h" |
1162 |
13 Aug 10 |
peter |
26 |
|
1119 |
04 Jul 10 |
peter |
27 |
#include "lib/Colors.h" |
919 |
30 Nov 09 |
jari |
28 |
|
919 |
30 Nov 09 |
jari |
29 |
#include <iostream> |
919 |
30 Nov 09 |
jari |
30 |
#include <sstream> |
919 |
30 Nov 09 |
jari |
31 |
|
919 |
30 Nov 09 |
jari |
32 |
int main(int argc, char* argv[]) |
919 |
30 Nov 09 |
jari |
33 |
{ |
919 |
30 Nov 09 |
jari |
34 |
using namespace theplu::svndigest; |
1162 |
13 Aug 10 |
peter |
35 |
test::Suite suite(argc, argv); |
919 |
30 Nov 09 |
jari |
36 |
|
929 |
02 Dec 09 |
jari |
// The loop adds new authors to the author color map until all |
929 |
02 Dec 09 |
jari |
// colors are use. The color map contains 12 colors and black |
919 |
30 Nov 09 |
jari |
// (total 13). The loop is 14 iterations and therefore the first |
929 |
02 Dec 09 |
jari |
// color is reused for the last author. This test checks that |
929 |
02 Dec 09 |
jari |
// colors are reused. If the color map size changes, then the loop |
919 |
30 Nov 09 |
jari |
// must be adjusted accordingly |
919 |
30 Nov 09 |
jari |
43 |
unsigned char r_first, g_first, b_first; |
962 |
09 Dec 09 |
peter |
44 |
r_first = g_first = b_first = '\0'; |
919 |
30 Nov 09 |
jari |
45 |
unsigned char r, g, b; |
919 |
30 Nov 09 |
jari |
46 |
for (unsigned int i=0; i<14; ++i) { |
919 |
30 Nov 09 |
jari |
47 |
std::stringstream ss; |
919 |
30 Nov 09 |
jari |
48 |
ss << i; |
929 |
02 Dec 09 |
jari |
49 |
Colors::instance().get_color(ss.str(), r, g, b); |
929 |
02 Dec 09 |
jari |
50 |
if (!i) r_first=r, g_first=g, b_first=b; // remember first color |
919 |
30 Nov 09 |
jari |
51 |
} |
929 |
02 Dec 09 |
jari |
// Test first and last color, expected to be the same. |
919 |
30 Nov 09 |
jari |
53 |
if (r!=r_first || g!=g_first || b!=b_first) { |
1162 |
13 Aug 10 |
peter |
54 |
suite.add(false); |
919 |
30 Nov 09 |
jari |
55 |
std::cerr << "Expected r,g,b " |
919 |
30 Nov 09 |
jari |
56 |
<< static_cast<int>(r_first) << ',' |
919 |
30 Nov 09 |
jari |
57 |
<< static_cast<int>(g_first) << ',' |
919 |
30 Nov 09 |
jari |
58 |
<< static_cast<int>(b_first) << std::endl; |
919 |
30 Nov 09 |
jari |
59 |
std::cerr << " got r,g,b " |
919 |
30 Nov 09 |
jari |
60 |
<< static_cast<int>(r) << ',' |
919 |
30 Nov 09 |
jari |
61 |
<< static_cast<int>(g) << ',' |
919 |
30 Nov 09 |
jari |
62 |
<< static_cast<int>(b) << std::endl; |
919 |
30 Nov 09 |
jari |
63 |
} |
919 |
30 Nov 09 |
jari |
64 |
|
1162 |
13 Aug 10 |
peter |
65 |
|
1162 |
13 Aug 10 |
peter |
66 |
return suite.exit_status(); |
919 |
30 Nov 09 |
jari |
67 |
} |