Skip to content

Commit 05e76be

Browse files
committed
Fixed bugs from v0.2.0 release.
- Added inline to `internal::ClientInterface::roles` definition (fixes #47) - Revised if conditions in `operator<<` for `Event`, `Result`, and `Invocation` (fixes #48) - Changed Real to JSON serialization format string to `"%.17e"` (fixes #49)
1 parent e71dc11 commit 05e76be

File tree

4 files changed

+10
-11
lines changed

4 files changed

+10
-11
lines changed

cppwamp/include/cppwamp/internal/clientinterface.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ namespace internal
3232
{
3333

3434
//------------------------------------------------------------------------------
35-
// Specifies the interface required for classes that implement the
36-
// wamp::Session class.
35+
// Specifies the interface required for classes that implement wamp::Session.
3736
//------------------------------------------------------------------------------
3837
class ClientInterface : public Callee, public Subscriber
3938
{
@@ -74,7 +73,7 @@ class ClientInterface : public Callee, public Subscriber
7473
virtual void postpone(std::function<void ()> functor) = 0;
7574
};
7675

77-
const Object& ClientInterface::roles()
76+
inline const Object& ClientInterface::roles()
7877
{
7978
static const Object roles =
8079
{

cppwamp/include/cppwamp/internal/json.ipp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ struct EncodeJson : public Visitor<>
9696
void operator()(Real x, TBuffer& buf) const
9797
{
9898
char str[32];
99-
auto length = std::snprintf(str, sizeof(str), "%e.17", x);
99+
auto length = std::snprintf(str, sizeof(str), "%.17e", x);
100100
assert(length < sizeof(str));
101101
buf.write(str, length);
102102
}

cppwamp/include/cppwamp/internal/sessiondata.ipp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ CPPWAMP_INLINE std::ostream& operator<<(std::ostream& out, const Event& event)
283283
out << ", Details|dict = " << event.options();
284284
if (!event.args().empty())
285285
out << ", Arguments|list = " << event.args();
286-
if (!event.args().empty())
286+
if (!event.kwargs().empty())
287287
out << ", ArgumentsKw|dict = " << event.kwargs();
288288
return out << " ]";
289289
}
@@ -427,7 +427,7 @@ CPPWAMP_INLINE std::ostream& operator<<(std::ostream& out, const Result& result)
427427
out << ", Details|dict = " << result.options();
428428
if (!result.args().empty())
429429
out << ", Arguments|list = " << result.args();
430-
if (!result.args().empty())
430+
if (!result.kwargs().empty())
431431
out << ", ArgumentsKw|dict = " << result.kwargs();
432432
return out << " ]";
433433
}
@@ -524,7 +524,7 @@ CPPWAMP_INLINE std::ostream& operator<<(std::ostream& out,
524524
out << ", Details|dict = " << inv.options();
525525
if (!inv.args().empty())
526526
out << ", Arguments|list = " << inv.args();
527-
if (!inv.args().empty())
527+
if (!inv.kwargs().empty())
528528
out << ", ArgumentsKw|dict = " << inv.kwargs();
529529
return out << " ]";
530530
}

test/codectestjson.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,20 +93,20 @@ void checkInteger(const std::string& json, TInteger n)
9393
void checkReal(const std::string& json, double x)
9494
{
9595
INFO( "For JSON string \"" << json << "\"" );
96-
96+
auto epsilon = std::numeric_limits<Real>::epsilon()*10.0;
9797
{
9898
Variant v;
9999
CHECK_NOTHROW( Json::decode(json, v) );
100100
REQUIRE( v.is<Real>() );
101-
CHECK( v.as<Real>() == Approx(x).epsilon(0.001) );
101+
CHECK( v.as<Real>() == Approx(x).epsilon(epsilon) );
102102
}
103103

104104
{
105105
Variant v;
106106
std::istringstream iss(json);
107107
CHECK_NOTHROW( Json::decode(iss, v) );
108108
REQUIRE( v.is<Real>() );
109-
CHECK( v.as<Real>() == Approx(x).epsilon(0.001) );
109+
CHECK( v.as<Real>() == Approx(x).epsilon(epsilon) );
110110
}
111111
}
112112

@@ -145,7 +145,7 @@ GIVEN( "valid JSON numeric strings" )
145145
checkReal("0.0", 0.0);
146146
checkReal("1.0", 1.0);
147147
checkReal("-1.0", -1.0);
148-
checkReal("3.14", 3.14);
148+
checkReal("3.14159265358979324", 3.14159265358979324);
149149
checkReal("2.9979e8", 2.9979e8);
150150
}
151151
GIVEN( "valid JSON strings" )

0 commit comments

Comments
 (0)