1 | // $Id: utility_test.cc 731 2008-12-15 19:03:04Z peter $ |
---|
2 | |
---|
3 | /* |
---|
4 | Copyright (C) 2007 Peter Johansson |
---|
5 | Copyright (C) 2008 Jari Häkkinen, Peter Johansson |
---|
6 | |
---|
7 | |
---|
8 | This file is part of svndigest, http://dev.thep.lu.se/svndigest |
---|
9 | |
---|
10 | svndigest is free software; you can redistribute it and/or modify it |
---|
11 | under the terms of the GNU General Public License as published by |
---|
12 | the Free Software Foundation; either version 2 of the License, or |
---|
13 | (at your option) any later version. |
---|
14 | |
---|
15 | svndigest is distributed in the hope that it will be useful, but |
---|
16 | WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
18 | General Public License for more details. |
---|
19 | |
---|
20 | You should have received a copy of the GNU General Public License |
---|
21 | along with this program; if not, write to the Free Software |
---|
22 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
---|
23 | 02111-1307, USA. |
---|
24 | */ |
---|
25 | |
---|
26 | #include "utility.h" |
---|
27 | |
---|
28 | #include <iostream> |
---|
29 | #include <string> |
---|
30 | |
---|
31 | bool test_hex(int, unsigned int, std::string); |
---|
32 | |
---|
33 | int main(const int argc,const char* argv[]) |
---|
34 | { |
---|
35 | bool ok=true; |
---|
36 | |
---|
37 | ok &= test_hex(15,2, "0f"); |
---|
38 | ok &= test_hex(17,1, "1"); |
---|
39 | ok &= test_hex(16,2, "10"); |
---|
40 | |
---|
41 | if (ok) |
---|
42 | return 0; |
---|
43 | return 1; |
---|
44 | } |
---|
45 | |
---|
46 | bool test_hex(int x, unsigned int w, std::string facit) |
---|
47 | { |
---|
48 | if (theplu::svndigest::hex(x,w)==facit) |
---|
49 | return true; |
---|
50 | std::cerr << "hex(" << x << ", " << w << ") results " |
---|
51 | << theplu::svndigest::hex(x,w) << ". Expects " << facit |
---|
52 | << std::endl; |
---|
53 | return false; |
---|
54 | } |
---|