MCPcopy Create free account
hub / github.com/davisking/dlib / test1

Function test1

dlib/test/iosockstream.cpp:98–130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

96// ----------------------------------------------------------------------------------------
97
98 void test1()
99 {
100 dlog << LINFO << "in test1()";
101 serv theserv;
102 theserv.set_listening_port(12345);
103 theserv.start_async();
104
105 // wait a little bit to make sure the server has started listening before we try
106 // to connect to it.
107 dlib::sleep(500);
108
109 for (int i = 0; i < 200; ++i)
110 {
111 dlog << LINFO << "i: " << i;
112 print_spinner();
113 iosockstream stream("localhost:12345");
114
115 stream << "word another ";
116 std::string temp;
117 stream >> temp;
118 DLIB_TEST(temp == "yay");
119 stream >> temp;
120 DLIB_TEST(temp == "words");
121 stream << "yep ";
122 }
123
124 // Just to make sure the server finishes processing the last connection before
125 // we kill it and accidentally trigger a DLIB_TEST().
126 dlib::sleep(500);
127
128 if (theserv.error_string.size() != 0)
129 throw error(theserv.error_string);
130 }
131
132// ----------------------------------------------------------------------------------------
133

Callers 1

perform_testMethod · 0.70

Calls 4

print_spinnerFunction · 0.85
errorClass · 0.85
sleepFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected