Pol  Revision:4b29d2b
testskill.cpp
Go to the documentation of this file.
1 
9 #include "testenv.h"
10 
11 #include "../../clib/logfacility.h"
12 #include "../skilladv.h"
13 
14 namespace Pol
15 {
16 namespace Testing
17 {
18 namespace
19 {
20 void test_skilladv( unsigned int raw, unsigned short base )
21 {
22  INFO_PRINT << "Raw " << raw << ", base " << base << ": ";
23  if ( Core::raw_to_base( raw ) != base )
24  {
25  INFO_PRINT << "raw_to_base failed!\n";
26  inc_failures();
27  }
28  if ( Core::base_to_raw( base ) != raw )
29  {
30  INFO_PRINT << "base_to_raw failed!\n";
31  inc_failures();
32  }
33  INFO_PRINT << "Passed\n";
34  inc_successes();
35 }
36 } // namespace
37 
39 {
40  INFO_PRINT << "Skill advancement tests:\n";
41  test_skilladv( 20, 1 );
42  test_skilladv( 512, 25 );
43  test_skilladv( 1024, 50 );
44  test_skilladv( 2048, 100 );
45  test_skilladv( 3072, 150 );
46  test_skilladv( 4096, 200 );
47  test_skilladv( 5120, 225 );
48  test_skilladv( 6144, 250 );
49  test_skilladv( 7168, 275 );
50  test_skilladv( 8192, 300 );
51  test_skilladv( 16384, 400 );
52  test_skilladv( 32768, 500 );
53  test_skilladv( 65536, 600 );
54  test_skilladv( 131072, 700 );
55  test_skilladv( 262144, 800 );
56  test_skilladv( 524288, 900 );
57  test_skilladv( 1048576, 1000 );
58  test_skilladv( 2097152, 1100 );
59  test_skilladv( 4194304, 1200 );
60  test_skilladv( 8388608, 1300 );
61  test_skilladv( 16777216, 1400 );
62  test_skilladv( 33554432, 1500 );
63  test_skilladv( 67108864, 1600 );
64  test_skilladv( 134217728, 1700 );
65  test_skilladv( 268435456, 1800 );
66  test_skilladv( 536870912, 1900 );
67 
68  for ( unsigned short base = 0; base < 2000; ++base )
69  {
70  INFO_PRINT << "Base " << base << ": Raw=";
71  unsigned int raw = Core::base_to_raw( base );
72  INFO_PRINT << raw << ": ";
73  unsigned short calcbase = Core::raw_to_base( raw );
74  if ( calcbase != base )
75  {
76  INFO_PRINT << "Failed (" << calcbase << ")\n";
77  inc_failures();
78  }
79  else
80  {
81  INFO_PRINT << "Passed\n";
82  inc_successes();
83  }
84  }
85 
86  for ( unsigned int raw = 0; raw < 2500; ++raw )
87  {
88  INFO_PRINT << "Raw " << raw << ": Base=";
89  unsigned short base = Core::raw_to_base( raw );
90  INFO_PRINT << base << ": ";
91  unsigned int calcraw = Core::base_to_raw( base );
92  if ( calcraw != raw )
93  {
94  INFO_PRINT << "Failed (" << calcraw << ")\n";
95  inc_failures();
96  }
97  else
98  {
99  INFO_PRINT << "Passed\n";
100  inc_successes();
101  }
102  }
103 }
104 
105 } // namespace Testing
106 } // namespace Pol
unsigned int base_to_raw(unsigned short base)
Definition: skilladv.cpp:72
void inc_failures()
Definition: testenv.cpp:33
unsigned short raw_to_base(unsigned int raw)
Definition: skilladv.cpp:45
void skilladv_test()
Definition: testskill.cpp:38
void inc_successes()
Definition: testenv.cpp:38
#define INFO_PRINT
Definition: logfacility.h:223
Definition: berror.cpp:12