From f3eded113aa82c84122e5a70a774b05ce548dd40 Mon Sep 17 00:00:00 2001 From: Adriano dos Santos Fernandes Date: Thu, 29 Sep 2022 08:20:54 -0300 Subject: [PATCH] Add tests for Clumplet InfoResponse kind. --- src/common/classes/tests/ClumpletTest.cpp | 60 +++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 src/common/classes/tests/ClumpletTest.cpp diff --git a/src/common/classes/tests/ClumpletTest.cpp b/src/common/classes/tests/ClumpletTest.cpp new file mode 100644 index 0000000000..0840598726 --- /dev/null +++ b/src/common/classes/tests/ClumpletTest.cpp @@ -0,0 +1,60 @@ +#include "firebird.h" +#include "boost/test/unit_test.hpp" +#include "../common/classes/ClumpletReader.h" +#include "../common/classes/ClumpletWriter.h" + +using namespace Firebird; + +BOOST_AUTO_TEST_SUITE(CommonSuite) +BOOST_AUTO_TEST_SUITE(ClumpletSuite) + + +BOOST_AUTO_TEST_CASE(ClumpletWriteAndReadInfoResponseTest) +{ + ClumpletWriter clumplet(ClumpletWriter::Kind::InfoResponse, MAX_DPB_SIZE); + clumplet.insertInt(isc_info_sql_stmt_type, isc_info_sql_stmt_select); + clumplet.insertInt(isc_info_sql_batch_fetch, 0); + clumplet.insertTag(isc_info_end); + + clumplet.rewind(); + BOOST_TEST(!clumplet.isEof()); + BOOST_TEST(clumplet.getClumpTag() == isc_info_sql_stmt_type); + BOOST_TEST(clumplet.getInt() == isc_info_sql_stmt_select); + + clumplet.moveNext(); + BOOST_TEST(!clumplet.isEof()); + BOOST_TEST(clumplet.getClumpTag() == isc_info_sql_batch_fetch); + BOOST_TEST(clumplet.getInt() == 0); + + clumplet.moveNext(); + BOOST_TEST(!clumplet.isEof()); + BOOST_TEST(clumplet.getClumpTag() == isc_info_end); + + clumplet.moveNext(); + BOOST_TEST(clumplet.isEof()); +} + + +BOOST_AUTO_TEST_CASE(ClumpletWriteAndSkipInfoResponseTest) +{ + ClumpletWriter clumplet(ClumpletWriter::Kind::InfoResponse, MAX_DPB_SIZE); + clumplet.insertInt(isc_info_sql_stmt_type, isc_info_sql_stmt_select); + clumplet.insertInt(isc_info_sql_batch_fetch, 0); + clumplet.insertTag(isc_info_end); + + clumplet.rewind(); + BOOST_TEST(!clumplet.isEof()); + + clumplet.moveNext(); + BOOST_TEST(!clumplet.isEof()); + + clumplet.moveNext(); + BOOST_TEST(!clumplet.isEof()); + + clumplet.moveNext(); + BOOST_TEST(clumplet.isEof()); +} + + +BOOST_AUTO_TEST_SUITE_END() // ClumpletSuite +BOOST_AUTO_TEST_SUITE_END() // CommonSuite