#define BOOST_TEST_MODULE StreamSupport #include #include #include "bitset.h" #include "dbTypes.h" #include "helpers.h" #include "mariadb_repl.h" #include #include #include #include #include #include #include #include struct timespec; struct tm; #include BOOST_FIXTURE_TEST_SUITE(stream, std::stringstream); template using ToStream = std::tuple; BOOST_DATA_TEST_CASE(bytes, boost::unit_test::data::make>({ //{0x00_b, "0x00"}, {0x10_b, "0x10"}, {0xFE_b, "0xfe"}, {0xff_b, "0xff"}, }), in, exp) { *this << in; BOOST_CHECK_EQUAL(this->str(), exp); } BOOST_DATA_TEST_CASE(tms, boost::unit_test::data::make>({ {make_tm(2016, 1, 4, 12, 13, 14), "2016-01-04 12:13:14"}, {make_tm(2016, 12, 31, 0, 0, 1), "2016-12-31 00:00:01"}, }), in, exp) { *this << in; BOOST_CHECK_EQUAL(this->str(), exp); } BOOST_DATA_TEST_CASE(rts, boost::unit_test::data::make>({ {{{2016, 1, 4}, {12, 13, 14}}, "2016-01-04 12:13:14"}, {{{2016, 12, 31}, {0, 0, 1}}, "2016-12-31 00:00:01"}, }), in, exp) { *this << in; BOOST_CHECK_EQUAL(this->str(), exp); } BOOST_DATA_TEST_CASE(tss, boost::unit_test::data::make>({ {{0, 0}, "0.000000000"}, {{0, 1}, "0.000000001"}, {{1, 0}, "1.000000000"}, {{123, 0}, "123.000000000"}, {{123, 999999999}, "123.999999999"}, }), in, exp) { *this << in; BOOST_CHECK_EQUAL(this->str(), exp); } constexpr std::array somebits {0x00_b, 0xFF_b, 0xa1_b}; BOOST_DATA_TEST_CASE(bss, boost::unit_test::data::make>({ {{MyGrate::BitSet {somebits}}, "[0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,1,0,1]"}, }), in, exp) { *this << in; BOOST_CHECK_EQUAL(this->str(), exp); } BOOST_AUTO_TEST_CASE(mariadb_string) { std::string buf {"test"}; MARIADB_STRING str {buf.data(), buf.length()}; *this << str; BOOST_CHECK_EQUAL(this->str(), buf); } BOOST_AUTO_TEST_CASE(array) { std::array arr {1, 123456, -78910}; *this << arr; BOOST_CHECK_EQUAL(this->str(), "[1,123456,-78910]"); } BOOST_AUTO_TEST_CASE(vector) { std::vector arr {1, 123456, -78910}; *this << arr; BOOST_CHECK_EQUAL(this->str(), "[1,123456,-78910]"); } BOOST_AUTO_TEST_SUITE_END();