| 25 | typename cc2 |
| 26 | > |
| 27 | void conditioning_class_kernel_test ( |
| 28 | ) |
| 29 | /*! |
| 30 | requires |
| 31 | - cc is an implementation of conditioning_class/conditioning_class_kernel_abstract.h |
| 32 | the alphabet_size for cc is 256 |
| 33 | - cc2 is an implementation of conditioning_class/conditioning_class_kernel_abstract.h |
| 34 | the alphabet_size for cc2 is 2 |
| 35 | ensures |
| 36 | - runs tests on cc for compliance with the specs |
| 37 | !*/ |
| 38 | { |
| 39 | |
| 40 | srand(static_cast<unsigned int>(time(0))); |
| 41 | |
| 42 | |
| 43 | |
| 44 | typename cc::global_state_type gs; |
| 45 | typename cc2::global_state_type gs2; |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | for (int g = 0; g < 2; ++g) |
| 51 | { |
| 52 | print_spinner(); |
| 53 | unsigned long amount=g+1; |
| 54 | cc2 test(gs2); |
| 55 | cc2 test2(gs2); |
| 56 | |
| 57 | |
| 58 | DLIB_TEST(test.get_memory_usage() != 0); |
| 59 | |
| 60 | const unsigned long alphabet_size = 2; |
| 61 | |
| 62 | |
| 63 | DLIB_TEST(test.get_total() == 1); |
| 64 | |
| 65 | DLIB_TEST(test.get_count(alphabet_size-1)==1); |
| 66 | for (unsigned long i = 0; i < alphabet_size-1; ++i) |
| 67 | { |
| 68 | unsigned long low_count, high_count, total_count; |
| 69 | DLIB_TEST_MSG(test.get_range(i,low_count,high_count,total_count) == 0,i); |
| 70 | DLIB_TEST(test.get_count(i) == 0); |
| 71 | DLIB_TEST(test.get_total() == 1); |
| 72 | } |
| 73 | |
| 74 | |
| 75 | |
| 76 | for (unsigned long i = 0; i < alphabet_size; ++i) |
| 77 | { |
| 78 | test.increment_count(i,static_cast<unsigned short>(amount)); |
| 79 | unsigned long low_count = 0, high_count = 0, total_count = 0; |
| 80 | |
| 81 | if (i ==alphabet_size-1) |
| 82 | { |
| 83 | DLIB_TEST(test.get_range(i,low_count,high_count,total_count) == 1+amount); |
| 84 |
nothing calls this directly
no test coverage detected