| 114 | |
| 115 | template <typename ssb> |
| 116 | void sockstreambuf_test ( |
| 117 | ) |
| 118 | /*! |
| 119 | requires |
| 120 | - ssb is an implementation of sockstreambuf/sockstreambuf_kernel_abstract.h |
| 121 | ensures |
| 122 | - runs tests on ssb for compliance with the specs |
| 123 | !*/ |
| 124 | { |
| 125 | char ch; |
| 126 | vector<char> vbuf; |
| 127 | vbuf.resize(1000000); |
| 128 | char* bigbuf = &vbuf[0]; |
| 129 | connection* con; |
| 130 | |
| 131 | print_spinner(); |
| 132 | thread_running = true; |
| 133 | listener* list; |
| 134 | if (create_listener(list,0)) |
| 135 | { |
| 136 | DLIB_TEST_MSG(false, "Unable to create a listener"); |
| 137 | } |
| 138 | |
| 139 | create_new_thread(&thread_proc_struct<ssb>::thread_proc,list); |
| 140 | |
| 141 | if (create_connection(con,list->get_listening_port(),"127.0.0.1")) |
| 142 | { |
| 143 | DLIB_TEST_MSG(false, "Unable to create a connection"); |
| 144 | } |
| 145 | |
| 146 | // make sure con gets deleted |
| 147 | std::unique_ptr<connection> del_con(con); |
| 148 | |
| 149 | ssb buf(con); |
| 150 | istream in(&buf); |
| 151 | |
| 152 | |
| 153 | |
| 154 | for (int i = 'a'; i < 'z'; ++i) |
| 155 | { |
| 156 | in >> ch; |
| 157 | char c = i; |
| 158 | DLIB_TEST_MSG(ch == c,"ch: " << (int)ch << " c: " << (int)c); |
| 159 | } |
| 160 | |
| 161 | in.get(); |
| 162 | DLIB_TEST_MSG(in.peek() == 'A', "*" << in.peek() << "*"); |
| 163 | in.get(); |
| 164 | |
| 165 | for (int i = 0; i < 256; ++i) |
| 166 | { |
| 167 | in.read(&ch,1); |
| 168 | char c = i; |
| 169 | DLIB_TEST_MSG(ch == c,"ch: " << (int)ch << " c: " << (int)c ); |
| 170 | } |
| 171 | |
| 172 | for (int i = -100; i < 25600; ++i) |
| 173 | { |
nothing calls this directly
no test coverage detected