Skip to content

Commit bd7f6dd

Browse files
author
pfeatherstone
committed
Added small map test
1 parent 236b854 commit bd7f6dd

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

test.cpp

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@ struct vector_sink
2020
{
2121
buf.insert(end(buf), data, data + len);
2222
}
23-
24-
void operator()(const char* data, size_t len)
25-
{
26-
write(data, len);
27-
}
2823
};
2924

3025
const auto num_errors = [](const auto& buf1, const auto& buf2)
@@ -196,4 +191,31 @@ TEST_SUITE("[MSGPACK]")
196191

197192
REQUIRE(num_errors(buf1, buf2) == 0);
198193
}
194+
195+
TEST_CASE("map")
196+
{
197+
std::mt19937 eng(std::random_device{}());
198+
199+
std::map<std::string, int> a;
200+
a["a"] = 1;
201+
a["b"] = 2;
202+
a["c"] = 70000;
203+
a["d"] = 1000000000;
204+
205+
std::vector<uint8_t> buf1, buf2;
206+
207+
{
208+
// using msgpack-c library
209+
vector_sink sink{buf1};
210+
msgpack::pack(sink, a);
211+
}
212+
213+
{
214+
// using custom library
215+
using namespace msgpackcpp;
216+
serialize(sink(buf2), a);
217+
}
218+
219+
REQUIRE(num_errors(buf1, buf2) == 0);
220+
}
199221
}

0 commit comments

Comments
 (0)