From d1586f587531e6419415f0877937a04f99d9d3a1 Mon Sep 17 00:00:00 2001 From: Mingun Date: Sat, 6 Apr 2024 20:43:08 +0500 Subject: [PATCH] C++: do not cast numerical expected values of enums to the enum type The test was initially introduced with that logic in 3bdfb59642dc60b8abd98bb9455cda94235df3d3, however the similar tests `enum_invalid` and `enum_to_i_invalid` uses the numerical values and passes successfully, which means that such manual edits in tests are not required. Regenerate those tests from KST with command: ./spec_kst_to_all -t cpp_stl_98 -t cpp_stl_11 --all-specs -f --- spec/cpp_stl_11/test_switch_manual_enum_invalid.cpp | 8 ++++---- spec/cpp_stl_11/test_switch_manual_enum_invalid_else.cpp | 8 ++++---- spec/cpp_stl_98/test_switch_manual_enum_invalid.cpp | 8 ++++---- spec/cpp_stl_98/test_switch_manual_enum_invalid_else.cpp | 8 ++++---- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/spec/cpp_stl_11/test_switch_manual_enum_invalid.cpp b/spec/cpp_stl_11/test_switch_manual_enum_invalid.cpp index 9345c016d..31a723355 100644 --- a/spec/cpp_stl_11/test_switch_manual_enum_invalid.cpp +++ b/spec/cpp_stl_11/test_switch_manual_enum_invalid.cpp @@ -1,20 +1,20 @@ +// Autogenerated from KST: please remove this line if doing any edits by hand! + #include #include "switch_manual_enum_invalid.h" #include #include #include - BOOST_AUTO_TEST_CASE(test_switch_manual_enum_invalid) { std::ifstream ifs("src/enum_negative.bin", std::ifstream::binary); kaitai::kstream ks(&ifs); switch_manual_enum_invalid_t* r = new switch_manual_enum_invalid_t(&ks); - BOOST_CHECK_EQUAL(r->opcodes()->size(), 2); - BOOST_CHECK_EQUAL(r->opcodes()->at(0)->code(), static_cast(255)); + BOOST_CHECK_EQUAL(r->opcodes()->at(0)->code(), 255); BOOST_CHECK(r->opcodes()->at(0)->_is_null_body()); - BOOST_CHECK_EQUAL(r->opcodes()->at(1)->code(), static_cast(1)); + BOOST_CHECK_EQUAL(r->opcodes()->at(1)->code(), 1); BOOST_CHECK(r->opcodes()->at(1)->_is_null_body()); delete r; diff --git a/spec/cpp_stl_11/test_switch_manual_enum_invalid_else.cpp b/spec/cpp_stl_11/test_switch_manual_enum_invalid_else.cpp index 2445d0156..df686e170 100644 --- a/spec/cpp_stl_11/test_switch_manual_enum_invalid_else.cpp +++ b/spec/cpp_stl_11/test_switch_manual_enum_invalid_else.cpp @@ -1,20 +1,20 @@ +// Autogenerated from KST: please remove this line if doing any edits by hand! + #include #include "switch_manual_enum_invalid_else.h" #include #include #include - BOOST_AUTO_TEST_CASE(test_switch_manual_enum_invalid_else) { std::ifstream ifs("src/enum_negative.bin", std::ifstream::binary); kaitai::kstream ks(&ifs); switch_manual_enum_invalid_else_t* r = new switch_manual_enum_invalid_else_t(&ks); - BOOST_CHECK_EQUAL(r->opcodes()->size(), 2); - BOOST_CHECK_EQUAL(r->opcodes()->at(0)->code(), static_cast(255)); + BOOST_CHECK_EQUAL(r->opcodes()->at(0)->code(), 255); BOOST_CHECK_EQUAL(static_cast(r->opcodes()->at(0)->body())->value(), 123); - BOOST_CHECK_EQUAL(r->opcodes()->at(1)->code(), static_cast(1)); + BOOST_CHECK_EQUAL(r->opcodes()->at(1)->code(), 1); BOOST_CHECK_EQUAL(static_cast(r->opcodes()->at(1)->body())->value(), 123); delete r; diff --git a/spec/cpp_stl_98/test_switch_manual_enum_invalid.cpp b/spec/cpp_stl_98/test_switch_manual_enum_invalid.cpp index 9345c016d..31a723355 100644 --- a/spec/cpp_stl_98/test_switch_manual_enum_invalid.cpp +++ b/spec/cpp_stl_98/test_switch_manual_enum_invalid.cpp @@ -1,20 +1,20 @@ +// Autogenerated from KST: please remove this line if doing any edits by hand! + #include #include "switch_manual_enum_invalid.h" #include #include #include - BOOST_AUTO_TEST_CASE(test_switch_manual_enum_invalid) { std::ifstream ifs("src/enum_negative.bin", std::ifstream::binary); kaitai::kstream ks(&ifs); switch_manual_enum_invalid_t* r = new switch_manual_enum_invalid_t(&ks); - BOOST_CHECK_EQUAL(r->opcodes()->size(), 2); - BOOST_CHECK_EQUAL(r->opcodes()->at(0)->code(), static_cast(255)); + BOOST_CHECK_EQUAL(r->opcodes()->at(0)->code(), 255); BOOST_CHECK(r->opcodes()->at(0)->_is_null_body()); - BOOST_CHECK_EQUAL(r->opcodes()->at(1)->code(), static_cast(1)); + BOOST_CHECK_EQUAL(r->opcodes()->at(1)->code(), 1); BOOST_CHECK(r->opcodes()->at(1)->_is_null_body()); delete r; diff --git a/spec/cpp_stl_98/test_switch_manual_enum_invalid_else.cpp b/spec/cpp_stl_98/test_switch_manual_enum_invalid_else.cpp index 2445d0156..df686e170 100644 --- a/spec/cpp_stl_98/test_switch_manual_enum_invalid_else.cpp +++ b/spec/cpp_stl_98/test_switch_manual_enum_invalid_else.cpp @@ -1,20 +1,20 @@ +// Autogenerated from KST: please remove this line if doing any edits by hand! + #include #include "switch_manual_enum_invalid_else.h" #include #include #include - BOOST_AUTO_TEST_CASE(test_switch_manual_enum_invalid_else) { std::ifstream ifs("src/enum_negative.bin", std::ifstream::binary); kaitai::kstream ks(&ifs); switch_manual_enum_invalid_else_t* r = new switch_manual_enum_invalid_else_t(&ks); - BOOST_CHECK_EQUAL(r->opcodes()->size(), 2); - BOOST_CHECK_EQUAL(r->opcodes()->at(0)->code(), static_cast(255)); + BOOST_CHECK_EQUAL(r->opcodes()->at(0)->code(), 255); BOOST_CHECK_EQUAL(static_cast(r->opcodes()->at(0)->body())->value(), 123); - BOOST_CHECK_EQUAL(r->opcodes()->at(1)->code(), static_cast(1)); + BOOST_CHECK_EQUAL(r->opcodes()->at(1)->code(), 1); BOOST_CHECK_EQUAL(static_cast(r->opcodes()->at(1)->body())->value(), 123); delete r;