-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Mark external includes as SYSTEM - Match function names between classes - Extend test and convert it to gtest - Apply catkin_lint_cmake and fixed issues
- Loading branch information
Showing
6 changed files
with
139 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
<package format="3"> | ||
<name>tue_serialization</name> | ||
<version>0.0.0</version> | ||
<description>The tue_serialization package</description> | ||
<description>Simple library for serialization of datastreams</description> | ||
|
||
<author email="[email protected]">Sjoerd van den Dries</author> | ||
|
||
|
@@ -20,6 +20,8 @@ | |
<build_export_depend>message_runtime</build_export_depend> | ||
<exec_depend>message_runtime</exec_depend> | ||
|
||
<test_depend>catkin_lint_cmake</test_depend> | ||
|
||
<doc_depend>doxygen</doc_depend> | ||
|
||
<export> | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
#include <gtest/gtest.h> | ||
|
||
#include <tue/serialization/archive.h> | ||
#include <tue/serialization/input_archive.h> | ||
#include <tue/serialization/output_archive.h> | ||
|
||
#include <tue/serialization/filesystem.h> | ||
#include <tue/serialization/version.h> | ||
|
||
#include <fstream> | ||
#include <sstream> | ||
|
||
// example | ||
|
||
|
||
class tue_serialization : public testing::Test | ||
{ | ||
protected: | ||
const double d_c = 3.15; | ||
const float f_c = 5.0; | ||
const int i_c = 123; | ||
const std::string s_c = "Hello, this is just a simple test"; | ||
}; | ||
|
||
TEST_F(tue_serialization, OutputArchive_InputArchive) | ||
{ | ||
std::stringstream ss; | ||
tue::serialization::OutputArchive a_out(ss); | ||
a_out << d_c << f_c << i_c << s_c; | ||
|
||
// read | ||
double d; | ||
float f; | ||
int i; | ||
std::string s; | ||
|
||
tue::serialization::InputArchive a_in(ss); | ||
a_in >> d >> f >> i >> s; | ||
EXPECT_DOUBLE_EQ(d, d_c); | ||
EXPECT_FLOAT_EQ(f, f_c); | ||
EXPECT_EQ(i, i_c); | ||
EXPECT_EQ(s, s_c); | ||
std::cout << "OutputArchive -> InputArchive:" << std::endl; | ||
std::cout << d << ", " << f << ", " << i << ", \"" << s << "\"" << std::endl; | ||
std::cout << "version: " << a_in.version() << std::endl; | ||
} | ||
|
||
TEST_F(tue_serialization, toFile_fromFile) | ||
{ | ||
std::string test_filename = "/tmp/tue_test_serialization"; | ||
|
||
{ | ||
tue::serialization::Archive a_out; | ||
a_out << d_c << f_c << i_c << s_c; | ||
|
||
tue::serialization::toFile(a_out, test_filename); | ||
} | ||
|
||
{ | ||
tue::serialization::Archive a_in; | ||
tue::serialization::fromFile(test_filename, a_in); | ||
|
||
// read | ||
double d; | ||
float f; | ||
int i; | ||
std::string s; | ||
|
||
a_in >> d >> f >> i >> s; | ||
|
||
EXPECT_DOUBLE_EQ(d, d_c); | ||
EXPECT_FLOAT_EQ(f, f_c); | ||
EXPECT_EQ(i, i_c); | ||
EXPECT_EQ(s, s_c); | ||
std::cout << "toFile -> fromFile:" << std::endl; | ||
std::cout << d << ", " << f << ", " << i << ", \"" << s << "\"" << std::endl; | ||
std::cout << "version: " << a_in.version() << std::endl; | ||
} | ||
} | ||
|
||
TEST_F(tue_serialization, Archive) | ||
{ | ||
tue::serialization::Archive a; | ||
|
||
a << d_c << f_c << i_c << s_c; | ||
|
||
// read | ||
double d; | ||
float f; | ||
int i; | ||
std::string s; | ||
|
||
a >> d >> f >> i >> s; | ||
|
||
EXPECT_DOUBLE_EQ(d, d_c); | ||
EXPECT_FLOAT_EQ(f, f_c); | ||
EXPECT_EQ(i, i_c); | ||
EXPECT_EQ(s, s_c); | ||
std::cout << "Archive:" << std::endl; | ||
std::cout << d << ", " << f << ", " << i << ", \"" << s << "\"" << std::endl; | ||
std::cout << "version: " << a.version() << std::endl; | ||
} | ||
|
||
// Run all the tests that were declared with TEST() | ||
int main(int argc, char **argv) | ||
{ | ||
testing::InitGoogleTest(&argc, argv); | ||
return RUN_ALL_TESTS(); | ||
} |