From 01bc7c8245c1b59f2ffe8ceccd41fc2358e008cd Mon Sep 17 00:00:00 2001 From: "Zezheng.Li" Date: Tue, 10 Oct 2023 11:01:42 +0800 Subject: [PATCH] fix --- src/struct_pack/tests/BUILD.bazel | 4 +++ src/struct_pack/tests/binary_data/BUILD.bazel | 1 + .../tests/binary_data/test_cross_platform.dat | Bin 263 -> 253 bytes ...test_cross_platform_without_debug_info.dat | Bin 192 -> 182 bytes src/struct_pack/tests/test_cross_platform.cpp | 32 ++++++++++++++++++ src/struct_pack/tests/test_struct.hpp | 4 +-- 6 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 src/struct_pack/tests/binary_data/BUILD.bazel diff --git a/src/struct_pack/tests/BUILD.bazel b/src/struct_pack/tests/BUILD.bazel index efa25b89c..211717cd2 100644 --- a/src/struct_pack/tests/BUILD.bazel +++ b/src/struct_pack/tests/BUILD.bazel @@ -8,4 +8,8 @@ cc_test( deps = [ "//:ylt" ], + data = [ + "//src/struct_pack/tests/binary_data:test_cross_platform.dat", + "//src/struct_pack/tests/binary_data:test_cross_platform_without_debug_info.dat" + ], ) diff --git a/src/struct_pack/tests/binary_data/BUILD.bazel b/src/struct_pack/tests/binary_data/BUILD.bazel new file mode 100644 index 000000000..9a0ce2ba0 --- /dev/null +++ b/src/struct_pack/tests/binary_data/BUILD.bazel @@ -0,0 +1 @@ +exports_files(["test_cross_platform.dat","test_cross_platform_without_debug_info.dat"]) \ No newline at end of file diff --git a/src/struct_pack/tests/binary_data/test_cross_platform.dat b/src/struct_pack/tests/binary_data/test_cross_platform.dat index 959613173bea905eee220517861792bd53e1ffae..5b2eaf49550f13c57e717c0ba83b6158feecf289 100644 GIT binary patch delta 36 fcmZo?`pY=sfh+?ENC7c(Nq#Pv!<3jP0_6h$ik1eg delta 46 mcmey%*v>TJfw~w20|RSTYEe<82$02GlAntZVM{ifs}, + std::istreambuf_iterator{}); + auto object = create_complicated_object(); + auto buffer = + struct_pack::serialize(object); + CHECK(buffer == content); +} + +TEST_CASE("testing serialize other platform data") { + std::ifstream ifs("binary_data/test_cross_platform_without_debug_info.dat"); + if (!ifs.is_open()) { + ifs.open( + "src/struct_pack/tests/binary_data/" + "test_cross_platform_without_debug_info.dat"); + } + REQUIRE(ifs.is_open()); + std::string content(std::istreambuf_iterator{ifs}, + std::istreambuf_iterator{}); + auto object = create_complicated_object(); + auto buffer = + struct_pack::serialize(object); + CHECK(buffer == content); } \ No newline at end of file diff --git a/src/struct_pack/tests/test_struct.hpp b/src/struct_pack/tests/test_struct.hpp index c78081a5f..9dc86b3cb 100644 --- a/src/struct_pack/tests/test_struct.hpp +++ b/src/struct_pack/tests/test_struct.hpp @@ -77,8 +77,8 @@ inline complicated_object create_complicated_object() { {1, 2}, {{1, {20, "tom"}}, {1, {22, "jerry"}}}, {{1, 2}, {1, 3}}, - {person{20, "tom"}, {22, "jerry"}}, - {person{20, "tom"}, {22, "jerry"}}, + {person{20, "tom"}}, + {person{26, "tom"}}, std::make_pair("aa", person{20, "tom"})}; }