Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
da72b576
Commit
da72b576
authored
Nov 17, 2012
by
Davis King
Browse files
Added more tests
parent
8b22c913
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
86 additions
and
25 deletions
+86
-25
dlib/test/iosockstream.cpp
dlib/test/iosockstream.cpp
+86
-25
No files found.
dlib/test/iosockstream.cpp
View file @
da72b576
...
@@ -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,6 +62,89 @@ namespace
...
@@ -62,6 +62,89 @@ 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"
;
out
<<
"one two three four five"
;
}
catch
(
error
&
e
)
{
error_string
=
e
.
what
();
}
}
public:
std
::
string
error_string
;
};
// ----------------------------------------------------------------------------------------
void
test1
()
{
serv
theserv
;
theserv
.
set_listening_port
(
12345
);
theserv
.
start_async
();
for
(
int
i
=
0
;
i
<
1001
;
++
i
)
{
print_spinner
();
iosockstream
stream
(
"localhost:12345"
);
stream
<<
"word another "
;
std
::
string
temp
;
stream
>>
temp
;
DLIB_TEST
(
temp
==
"yay"
);
stream
>>
temp
;
DLIB_TEST
(
temp
==
"words"
);
stream
<<
"yep "
;
}
// Just to make sure the server finishes processing the last connection before
// we kill it and accidentally trigger a DLIB_TEST().
dlib
::
sleep
(
500
);
if
(
theserv
.
error_string
.
size
()
!=
0
)
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
class
test_iosockstream
:
public
tester
...
@@ -76,30 +159,8 @@ namespace
...
@@ -76,30 +159,8 @@ namespace
void
perform_test
(
void
perform_test
(
)
)
{
{
serv
theserv
;
test1
();
theserv
.
set_listening_port
(
12345
);
test2
();
theserv
.
start_async
();
for
(
int
i
=
0
;
i
<
1001
;
++
i
)
{
print_spinner
();
iosockstream
stream
(
"localhost:12345"
);
stream
<<
"word another "
;
std
::
string
temp
;
stream
>>
temp
;
DLIB_TEST
(
temp
==
"yay"
);
stream
>>
temp
;
DLIB_TEST
(
temp
==
"words"
);
stream
<<
"yep "
;
}
// Just to make sure the server finishes processing the last connection before
// we kill it and accidentally trigger a DLIB_TEST().
dlib
::
sleep
(
500
);
if
(
theserv
.
error_string
.
size
()
!=
0
)
throw
error
(
theserv
.
error_string
);
}
}
}
a
;
}
a
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment