| 23 | typename hash_table |
| 24 | > |
| 25 | void hash_table_kernel_test ( |
| 26 | ) |
| 27 | /*! |
| 28 | requires |
| 29 | - hash_table is an implementation of hash_table/hash_table_kernel_abstract.h |
| 30 | and is instantiated to map ints to ints |
| 31 | ensures |
| 32 | - runs tests on hash_table for compliance with the specs |
| 33 | !*/ |
| 34 | { |
| 35 | |
| 36 | srand(static_cast<unsigned int>(time(0))); |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | { |
| 42 | hash_table test(16); |
| 43 | |
| 44 | DLIB_TEST(test.count(3) == 0); |
| 45 | |
| 46 | enumerable<map_pair<int,int> >& e = test; |
| 47 | DLIB_TEST(e.at_start() == true); |
| 48 | |
| 49 | hash_table test2(16); |
| 50 | |
| 51 | hash_table test3(0); |
| 52 | hash_table test4(0); |
| 53 | |
| 54 | |
| 55 | print_spinner(); |
| 56 | |
| 57 | int b; |
| 58 | for (int j = 0; j < 4; ++j) |
| 59 | { |
| 60 | int a = 4; |
| 61 | b = 5; |
| 62 | test2.add(a,b); |
| 63 | DLIB_TEST(test2.size() == 1); |
| 64 | DLIB_TEST(*test2[4] == 5); |
| 65 | DLIB_TEST(test2[99] == 0); |
| 66 | |
| 67 | DLIB_TEST(test2.move_next()); |
| 68 | DLIB_TEST(test2.element().key() == 4); |
| 69 | DLIB_TEST(test2.element().value() == 5); |
| 70 | |
| 71 | swap(test,test2); |
| 72 | DLIB_TEST(test.size() == 1); |
| 73 | DLIB_TEST(*test[4] == 5); |
| 74 | DLIB_TEST(test[99] == 0); |
| 75 | |
| 76 | test.swap(test2); |
| 77 | |
| 78 | a = 99; |
| 79 | b = 35; |
| 80 | test2.add(a,b); |
| 81 | DLIB_TEST(test2.size() == 2); |
| 82 | DLIB_TEST(*test2[4] == 5); |
nothing calls this directly
no test coverage detected