Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix marshaller #966

Merged
merged 1 commit into from
Jul 7, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/autowiring/marshaller.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ namespace autowiring {
std::string retVal;
type val = *static_cast<const type*>(ptr);
bool pos = 0 < val;
if (!pos)
val *= ~0;
for (; val; val /= 10) {
retVal.push_back(static_cast<char>(val % 10 + '0'));
}
Expand Down
15 changes: 14 additions & 1 deletion src/autowiring/test/MarshallerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,22 @@ class MarshallerTest:
{};

TEST_F(MarshallerTest, DoubleMarshalTest) {
autowiring::builtin_marshaller<double, void> b;
autowiring::marshaller<double> b;

double x = -0.00899999999999999;
std::string val = b.marshal(&x);
ASSERT_STREQ("-0.00899999999999999", val.c_str());
}

TEST_F(MarshallerTest, NegativeValues) {
autowiring::marshaller<int> b;

int x = -9;
std::string valX = b.marshal(&x);
ASSERT_STREQ("-9", valX.c_str());

int y = 0xCDCDCDCD;
std::string valY = b.marshal(&y);
ASSERT_STREQ("-842150451", valY.c_str());
}