text
stringlengths 0
2.2M
|
---|
do { \
|
MESSAGE(#pred "(" #value ")"); \
|
CHECK(pred(roundtrip(value, false))); \
|
} while (false)
|
#define CHECK_SIGN_RT(value) \
|
CHECK_EQ(std::signbit(roundtrip(value, false)), std::signbit(value))
|
#define CHECK_MSG_RT(val) CHECK_EQ(val, msg_roundtrip(val))
|
#define CHECK_PRED_MSG_RT(pred, value) CHECK(pred(msg_roundtrip(value)))
|
#define CHECK_SIGN_MSG_RT(value) \
|
CHECK_EQ(std::signbit(msg_roundtrip(value)), std::signbit(value))
|
BEGIN_FIXTURE_SCOPE(fixture)
|
CAF_TEST(serializing and then deserializing produces the same value) {
|
CHECK_RT(i32);
|
CHECK_RT(i64);
|
CHECK_RT(f32);
|
CHECK_RT(f64);
|
CHECK_RT(ts);
|
CHECK_RT(te);
|
CHECK_RT(str);
|
CHECK_RT(rs);
|
CHECK_PRED_RT(std::isnan, f32_nan);
|
CHECK_PRED_RT(std::isinf, f32_pos_inf);
|
CHECK_PRED_RT(std::isinf, f32_neg_inf);
|
CHECK_PRED_RT(std::isnan, f64_nan);
|
CHECK_PRED_RT(std::isinf, f64_pos_inf);
|
CHECK_PRED_RT(std::isinf, f64_neg_inf);
|
CHECK_SIGN_RT(f32_pos_inf);
|
CHECK_SIGN_RT(f32_neg_inf);
|
CHECK_SIGN_RT(f64_pos_inf);
|
CHECK_SIGN_RT(f64_neg_inf);
|
}
|
CAF_TEST(messages serialize and deserialize their content) {
|
CHECK_MSG_RT(i32);
|
CHECK_MSG_RT(i64);
|
CHECK_MSG_RT(f32);
|
CHECK_MSG_RT(f64);
|
CHECK_MSG_RT(ts);
|
CHECK_MSG_RT(te);
|
CHECK_MSG_RT(str);
|
CHECK_MSG_RT(rs);
|
CHECK_PRED_MSG_RT(std::isnan, f32_nan);
|
CHECK_PRED_MSG_RT(std::isinf, f32_pos_inf);
|
CHECK_PRED_MSG_RT(std::isinf, f32_neg_inf);
|
CHECK_PRED_MSG_RT(std::isnan, f64_nan);
|
CHECK_PRED_MSG_RT(std::isinf, f64_pos_inf);
|
CHECK_PRED_MSG_RT(std::isinf, f64_neg_inf);
|
CHECK_SIGN_MSG_RT(f32_pos_inf);
|
CHECK_SIGN_MSG_RT(f32_neg_inf);
|
CHECK_SIGN_MSG_RT(f64_pos_inf);
|
CHECK_SIGN_MSG_RT(f64_neg_inf);
|
}
|
CAF_TEST(raw_arrays) {
|
auto buf = serialize(ra);
|
int x[3];
|
deserialize(buf, x);
|
for (auto i = 0; i < 3; ++i)
|
CHECK_EQ(ra[i], x[i]);
|
}
|
CAF_TEST(arrays) {
|
auto buf = serialize(ta);
|
test_array x;
|
deserialize(buf, x);
|
for (auto i = 0; i < 4; ++i)
|
CHECK_EQ(ta.value[i], x.value[i]);
|
for (auto i = 0; i < 2; ++i)
|
for (auto j = 0; j < 4; ++j)
|
CHECK_EQ(ta.value2[i][j], x.value2[i][j]);
|
}
|
CAF_TEST(empty_non_pods) {
|
test_empty_non_pod x;
|
auto buf = serialize(x);
|
CAF_REQUIRE(buf.empty());
|
deserialize(buf, x);
|
}
|
std::string hexstr(const std::vector<char>& buf) {
|
using namespace std;
|
ostringstream oss;
|
oss << hex;
|
oss.fill('0');
|
for (auto& c : buf) {
|
oss.width(2);
|
oss << int{c};
|
}
|
return oss.str();
|
}
|
CAF_TEST(messages) {
|
// serialize original message which uses tuple_vals internally and
|
// deserialize into a message which uses type_erased_value pointers
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.