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
c82e003e
Commit
c82e003e
authored
Apr 06, 2013
by
Davis King
Browse files
Added serialization unit tests to cover the new format
parent
5c81b598
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
1 deletion
+42
-1
dlib/test/serialize.cpp
dlib/test/serialize.cpp
+42
-1
No files found.
dlib/test/serialize.cpp
View file @
c82e003e
...
...
@@ -402,7 +402,8 @@ namespace
// ----------------------------------------------------------------------------------------
// This function returns the contents of the file 'stuff.bin'
// This function returns the contents of the file 'stuff.bin' but using the old
// floating point serialization format.
const
std
::
string
get_decoded_string
()
{
dlib
::
base64
::
kernel_1a
base64_coder
;
...
...
@@ -436,6 +437,38 @@ namespace
return
sout
.
str
();
}
// This function returns the contents of the file 'stuff.bin' but using the new
// floating point serialization format.
const
std
::
string
get_decoded_string2
()
{
dlib
::
base64
base64_coder
;
dlib
::
compress_stream
::
kernel_1ea
compressor
;
std
::
ostringstream
sout
;
std
::
istringstream
sin
;
// The base64 encoded data from the file 'stuff.bin' we want to decode and return.
sout
<<
"AVaifX9zEbXa9aocsrcRuvnNqzZLptZ5mRd46xScCIfX6sq/46hG9JwIInElG50EtJKJY/+jAWit"
;
sout
<<
"TpDBWrxBz124JRLsBz62h0D3Tqgnd8zygRx7t33Ybw40o07MrhzNEHgYavUukaPje5by78JIWHgk"
;
sout
<<
"l7nb/TK+9ndVLrAThJ4v+GiPT3kh9H1tAAAAAQhbLa06pQjhrnjTXcRox1ZBEAV9/q1zAA=="
;
// Put the data into the istream sin
sin
.
str
(
sout
.
str
());
sout
.
str
(
""
);
// Decode the base64 text into its compressed binary form
base64_coder
.
decode
(
sin
,
sout
);
sin
.
clear
();
sin
.
str
(
sout
.
str
());
sout
.
str
(
""
);
// Decompress the data into its original form
compressor
.
decompress
(
sin
,
sout
);
// Return the decoded and decompressed data
return
sout
.
str
();
}
// ----------------------------------------------------------------------------------------
// Declare the logger we will use in this test. The name of the tester
...
...
@@ -481,12 +514,20 @@ namespace
sin
.
clear
();
sin
.
str
(
get_decoded_string
());
deserialize
(
obj
,
sin
);
obj
.
assert_in_state_1
();
deserialize
(
obj
,
sin
);
obj
.
assert_in_state_2
();
sin
.
clear
();
sin
.
str
(
get_decoded_string2
());
deserialize
(
obj
,
sin
);
obj
.
assert_in_state_1
();
deserialize
(
obj
,
sin
);
obj
.
assert_in_state_2
();
/*
// This is the code that produced the encoded data stored in the get_decoded_string() function
ofstream fout("stuff.bin",ios::binary);
...
...
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