Commit da72b576 authored by Davis King's avatar Davis King

Added more tests

parent 8b22c913
...@@ -38,7 +38,7 @@ namespace ...@@ -38,7 +38,7 @@ namespace
{ {
try try
{ {
dlog << LINFO << "serving connection"; dlog << LINFO << "serv1: serving connection";
std::string temp; std::string temp;
in >> temp; in >> temp;
...@@ -62,19 +62,40 @@ namespace ...@@ -62,19 +62,40 @@ namespace
}; };
// ---------------------------------------------------------------------------------------- class serv2 : public server_iostream
{
virtual void on_connect (
std::istream& ,
std::ostream& out,
const std::string& ,
const std::string& ,
unsigned short ,
unsigned short ,
uint64
)
{
try
{
dlog << LINFO << "serv2: serving connection";
class test_iosockstream : public tester out << "one two three four five";
}
catch (error& e)
{ {
error_string = e.what();
}
}
public: public:
test_iosockstream ( std::string error_string;
) :
tester ("test_iosockstream",
"Runs tests on the iosockstream component.")
{}
void perform_test ( };
)
// ----------------------------------------------------------------------------------------
void test1()
{ {
serv theserv; serv theserv;
theserv.set_listening_port(12345); theserv.set_listening_port(12345);
...@@ -101,6 +122,46 @@ namespace ...@@ -101,6 +122,46 @@ namespace
if (theserv.error_string.size() != 0) if (theserv.error_string.size() != 0)
throw error(theserv.error_string); throw error(theserv.error_string);
} }
// ----------------------------------------------------------------------------------------
void test2()
{
serv2 theserv;
theserv.set_listening_port(12345);
theserv.start_async();
for (int i = 0; i < 1001; ++i)
{
print_spinner();
iosockstream stream("localhost:12345");
std::string temp;
stream >> temp; DLIB_TEST(temp == "one");
stream >> temp; DLIB_TEST(temp == "two");
stream >> temp; DLIB_TEST(temp == "three");
stream >> temp; DLIB_TEST(temp == "four");
stream >> temp; DLIB_TEST(temp == "five");
}
}
// ----------------------------------------------------------------------------------------
class test_iosockstream : public tester
{
public:
test_iosockstream (
) :
tester ("test_iosockstream",
"Runs tests on the iosockstream component.")
{}
void perform_test (
)
{
test1();
test2();
}
} a; } a;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment