| 24 | typename buf |
| 25 | > |
| 26 | void lz77_buffer_kernel_test ( |
| 27 | ) |
| 28 | /*! |
| 29 | requires |
| 30 | - buf is an implementation of lz77_buffer/lz77_buffer_kernel_abstract.h |
| 31 | ensures |
| 32 | - runs tests on buf for compliance with the specs |
| 33 | !*/ |
| 34 | { |
| 35 | typedef dlib::sliding_buffer<unsigned char>::kernel_1a sbuf; |
| 36 | |
| 37 | buf test(8,20); |
| 38 | srand(static_cast<unsigned int>(time(0))); |
| 39 | |
| 40 | DLIB_TEST(test.get_lookahead_buffer_size() == 0); |
| 41 | DLIB_TEST(test.get_history_buffer_size() == 0); |
| 42 | DLIB_TEST_MSG(test.get_history_buffer_limit() == 256-20,test.get_history_buffer_limit()); |
| 43 | DLIB_TEST(test.get_lookahead_buffer_limit() == 20); |
| 44 | |
| 45 | |
| 46 | for (int g = 0; g < 2; ++g) |
| 47 | { |
| 48 | test.clear(); |
| 49 | |
| 50 | for (int i = 0; i < 1000; ++i) |
| 51 | { |
| 52 | test.add('a'); |
| 53 | } |
| 54 | DLIB_TEST(test.get_lookahead_buffer_size() == 20); |
| 55 | |
| 56 | |
| 57 | test.shift_buffers(5); |
| 58 | |
| 59 | DLIB_TEST(test.get_lookahead_buffer_size() == 15); |
| 60 | |
| 61 | |
| 62 | |
| 63 | unsigned long index, length, temp; |
| 64 | temp = test.get_lookahead_buffer_size(); |
| 65 | test.find_match(index,length,5); |
| 66 | |
| 67 | |
| 68 | DLIB_TEST_MSG(length <= temp, |
| 69 | "length: " << length << |
| 70 | "\ntemp: " << temp); |
| 71 | DLIB_TEST(test.get_lookahead_buffer_size() <= 15); |
| 72 | |
| 73 | |
| 74 | } |
| 75 | |
| 76 | |
| 77 | for (int g = 0; g < 2; ++g) |
| 78 | { |
| 79 | |
| 80 | |
| 81 | |
| 82 | test.clear(); |
| 83 |
nothing calls this directly
no test coverage detected