diff --git a/.drone.jsonnet b/.drone.jsonnet index 9b0e3ec83..31fe66b61 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -29,7 +29,7 @@ local builddir = 'verylongdirnameforverystrangecpackbehavior'; local cmakeflags = '-DCMAKE_BUILD_TYPE=RelWithDebInfo -DPLUGIN_COLUMNSTORE=YES -DPLUGIN_XPAND=NO -DPLUGIN_MROONGA=NO -DPLUGIN_ROCKSDB=NO ' + '-DPLUGIN_TOKUDB=NO -DPLUGIN_CONNECT=NO -DPLUGIN_SPIDER=NO -DPLUGIN_OQGRAPH=NO -DPLUGIN_SPHINX=NO ' + '-DWITH_EMBEDDED_SERVER=OFF -DWITH_WSREP=OFF ' + - '-DBUILD_CONFIG=mysql_release'; + '-DBUILD_CONFIG=mysql_release -DWITH_UNITTESTS=YES'; local rpm_build_deps = 'install -y lz4 systemd-devel git make gcc gcc-c++ libaio-devel openssl-devel boost-devel bison snappy-devel flex libcurl-devel libxml2-devel ncurses-devel automake libtool policycoreutils-devel rpm-build lsof iproute pam-devel perl-DBI cracklib-devel expect createrepo'; @@ -37,7 +37,6 @@ local deb_build_deps = 'apt update && apt install --yes --no-install-recommends '&& mk-build-deps debian/control -t "apt-get -y -o Debug::pkgProblemResolver=yes --no-install-recommends" -r -i'; local platformMap(platform) = - local platform_map = { 'opensuse/leap:15': 'zypper ' + rpm_build_deps + ' liblz4-devel cmake libboost_system-devel libboost_filesystem-devel libboost_thread-devel libboost_regex-devel libboost_date_time-devel libboost_chrono-devel libboost_atomic-devel gcc-fortran && cmake ' + cmakeflags + ' -DRPM=sles15 && make -j$(nproc) package', 'centos:7': 'yum install -y epel-release && yum install -y cmake3 && ln -s /usr/bin/cmake3 /usr/bin/cmake && yum ' + rpm_build_deps + ' lz4-devel && cmake ' + cmakeflags + ' -DRPM=centos7 && make -j$(nproc) package', @@ -46,9 +45,33 @@ local platformMap(platform) = 'ubuntu:18.04': deb_build_deps + " && CMAKEFLAGS='" + cmakeflags + " -DDEB=bionic' debian/autobake-deb.sh", 'ubuntu:20.04': deb_build_deps + " && CMAKEFLAGS='" + cmakeflags + " -DDEB=focal' debian/autobake-deb.sh", }; - platform_map[platform]; + +local testRun(platform) = + local platform_map = { + 'opensuse/leap:15': 'ctest -R columnstore: -j $(nproc) --output-on-failure', + 'centos:7': 'ctest3 -R columnstore: -j $(nproc) --output-on-failure', + 'centos:8': 'ctest3 -R columnstore: -j $(nproc) --output-on-failure', + 'debian:10': 'cd builddir; ctest -R columnstore: -j $(nproc) --output-on-failure', + 'ubuntu:18.04': 'cd builddir; ctest -R columnstore: -j $(nproc) --output-on-failure', + 'ubuntu:20.04': 'cd builddir; ctest -R columnstore: -j $(nproc) --output-on-failure', + }; + platform_map[platform]; + + +local testPreparation(platform) = + local platform_map = { + 'opensuse/leap:15': 'zypper install -y gtest boost-devel libboost_system-devel libboost_filesystem-devel libboost_thread-devel libboost_regex-devel libboost_date_time-devel libboost_chrono-devel libboost_atomic-devel cppunit-devel snappy-devel cmake', + 'centos:7': 'yum -y install epel-release && yum install -y gtest-devel cppunit-devel cmake3 boost-devel snappy-devel', + 'centos:8': 'yum install -y dnf-plugins-core libarchive && yum config-manager --set-enabled powertools && yum install -y lz4 gtest-devel cppunit-devel cmake3 boost-devel snappy-devel', + 'debian:10': 'apt update && apt install --yes libboost-all-dev libgtest-dev libcppunit-dev libsnappy-dev googletest cmake', + 'ubuntu:18.04': 'apt update && apt install --yes libboost-all-dev libgtest-dev libcppunit-dev googletest libsnappy-dev cmake g++ && cd /usr/src/googletest; cmake . && cmake --build . --target install; cd -' , + 'ubuntu:20.04': 'apt update && apt install --yes libboost-all-dev libgtest-dev libcppunit-dev googletest libsnappy-dev cmake', + }; + platform_map[platform]; + + local Pipeline(branch, platform, event, arch='amd64') = { local pkg_format = if (std.split(platform, ':')[0] == 'centos' || std.split(platform, ':')[0] == 'opensuse/leap') then 'rpm' else 'deb', local init = if (pkg_format == 'rpm') then '/usr/lib/systemd/systemd' else 'systemd', @@ -357,10 +380,24 @@ local Pipeline(branch, platform, event, arch='amd64') = { // "sed -i 's/BETA/GAMMA/' storage/columnstore/CMakeLists.txt", // Workaround till upstream removes 4535 workaround (workaround for workaround!) "sed -i '/MCOL-4535/,/^$/d' debian/autobake-deb.sh", + testPreparation(platform), platformMap(platform), if (pkg_format == 'rpm') then 'createrepo .' else 'dpkg-scanpackages ../ | gzip > ../Packages.gz', ], }, + { + name: 'unittests', + image: platform, + volumes: [pipeline._volumes.mdb], + environment: { + DEBIAN_FRONTEND: 'noninteractive', + }, + commands: [ + 'cd /mdb/' + builddir, + testPreparation(platform), + testRun(platform) + ], + }, { name: 'list pkgs', image: 'docker:git', diff --git a/CMakeLists.txt b/CMakeLists.txt index 2fdde8afc..4386ce527 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -150,7 +150,7 @@ if (NOT CURL_FOUND) return() endif() -IF (WITH_GTEST) +IF (WITH_UNITTESTS OR WITH_GTEST) INCLUDE (FindGTest) IF (NOT GTEST_FOUND) MESSAGE(FATAL_ERROR "GSuite libs not found but are requested. Please install them or build.") @@ -277,8 +277,8 @@ SET (ENGINE_UTILS_IDBDATAFILE_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/utils/idbdata SET (ENGINE_UTILS_LOGGINGCPP_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/utils/loggingcpp" "${CMAKE_CURRENT_BINARY_DIR}/utils/loggingcpp") SET (ENGINE_UTILS_CONFIGCPP_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/utils/configcpp") SET (ENGINE_UTILS_COMPRESS_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/utils/compress") -SET (ENGINE_VERSIONING_BRM_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/versioning/BRM") -SET (ENGINE_UTILS_ROWGROUP_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/utils/rowgroup") +SET (ENGINE_VERSIONING_BRM_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/versioning/BRM") +SET (ENGINE_UTILS_ROWGROUP_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/utils/rowgroup") SET (ENGINE_UTILS_COMMON_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/utils/common") SET (ENGINE_UTILS_DATACONVERT_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/utils/dataconvert") SET (ENGINE_UTILS_RWLOCK_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/utils/rwlock") diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 746d77124..09374649b 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,50 +1,43 @@ include_directories( ${ENGINE_COMMON_INCLUDES} ) -if (WITH_ROWGROUP_UT) +if (WITH_UNITTESTS) + enable_testing() + include(GoogleTest) + find_package(GTest REQUIRED) + + #GoogleTest tests add_executable(rowgroup_tests rowgroup-tests.cpp) - target_link_libraries(rowgroup_tests ${ENGINE_LDFLAGS} ${GTEST_LIBRARIES} ${ENGINE_EXEC_LIBS} ${MARIADB_CLIENT_LIBS}) - install(TARGETS rowgroup_tests DESTINATION ${ENGINE_BINDIR} COMPONENT columnstore-engine) -endif() + target_link_libraries(rowgroup_tests ${ENGINE_LDFLAGS} ${GTEST_LIBRARIES} ${ENGINE_EXEC_LIBS} ${MARIADB_CLIENT_LIBS}) + gtest_discover_tests(rowgroup_tests TEST_PREFIX columnstore:) -if (WITH_ARITHMETICOPERATOR_UT) add_executable(arithmeticoperator_tests arithmeticoperator-tests.cpp) - target_link_libraries(arithmeticoperator_tests ${ENGINE_LDFLAGS} ${GTEST_LIBRARIES} ${ENGINE_EXEC_LIBS} ${MARIADB_CLIENT_LIBS}) - install(TARGETS arithmeticoperator_tests DESTINATION ${ENGINE_BINDIR} COMPONENT columnstore-engine) -endif() + target_link_libraries(arithmeticoperator_tests ${ENGINE_LDFLAGS} ${GTEST_LIBRARIES} ${ENGINE_EXEC_LIBS} ${MARIADB_CLIENT_LIBS}) + gtest_discover_tests(arithmeticoperator_tests TEST_PREFIX columnstore:) -if (WITH_CSDECIMAL_UT) add_executable(mcs_decimal_tests mcs_decimal-tests.cpp) - target_link_libraries(mcs_decimal_tests ${ENGINE_LDFLAGS} ${GTEST_LIBRARIES} ${ENGINE_EXEC_LIBS} ${MARIADB_CLIENT_LIBS}) - install(TARGETS mcs_decimal_tests DESTINATION ${ENGINE_BINDIR} COMPONENT columnstore-engine) -endif() + target_link_libraries(mcs_decimal_tests ${ENGINE_LDFLAGS} ${GTEST_LIBRARIES} ${ENGINE_EXEC_LIBS} ${MARIADB_CLIENT_LIBS}) + gtest_discover_tests(mcs_decimal_tests TEST_PREFIX columnstore:) -if (WITH_DATACONVERT_UT) add_executable(dataconvert_tests dataconvert-tests.cpp) - target_link_libraries(dataconvert_tests ${ENGINE_LDFLAGS} ${GTEST_LIBRARIES} ${ENGINE_EXEC_LIBS} ${MARIADB_CLIENT_LIBS}) - install(TARGETS dataconvert_tests DESTINATION ${ENGINE_BINDIR} COMPONENT columnstore-engine) -endif() + target_link_libraries(dataconvert_tests ${ENGINE_LDFLAGS} ${GTEST_LIBRARIES} ${ENGINE_EXEC_LIBS} ${MARIADB_CLIENT_LIBS}) + gtest_discover_tests(dataconvert_tests TEST_PREFIX columnstore:) -if (WITH_SORTING_COMPARATORS_UT) - add_executable(comparators_tests comparators-tests.cpp) - target_link_libraries(comparators_tests ${ENGINE_LDFLAGS} ${MARIADB_CLIENT_LIBS} ${ENGINE_WRITE_LIBS} ${CPPUNIT_LIBRARIES} cppunit) - install(TARGETS comparators_tests DESTINATION ${ENGINE_BINDIR} COMPONENT columnstore-engine) -endif() + add_executable(rebuild_em_tests rebuild-em-tests.cpp) + target_link_libraries(rebuild_em_tests ${ENGINE_LDFLAGS} ${GTEST_LIBRARIES} ${MARIADB_CLIENT_LIBS} ${ENGINE_WRITE_LIBS}) + gtest_discover_tests(rebuild_em_tests TEST_PREFIX columnstore:) -if (WITH_SHARED_COMP_TESTS) + add_executable(compression_tests compression-tests.cpp) + target_link_libraries(compression_tests ${ENGINE_LDFLAGS} ${GTEST_LIBRARIES} ${MARIADB_CLIENT_LIBS} ${ENGINE_WRITE_LIBS}) + gtest_discover_tests(compression_tests TEST_PREFIX columnstore:) + + # CPPUNIT TESTS add_executable(we_shared_components_tests shared_components_tests.cpp) add_dependencies(we_shared_components_tests loggingcpp) target_link_libraries(we_shared_components_tests ${ENGINE_LDFLAGS} ${MARIADB_CLIENT_LIBS} ${ENGINE_WRITE_LIBS} cppunit) - install(TARGETS we_shared_components_tests DESTINATION ${ENGINE_BINDIR} COMPONENT columnstore-engine) -endif() + #Fix Test and uncomment + #add_test(NAME columnstore:we_shared_components_tests, COMMAND we_shared_components_tests) -if (WITH_REBUILD_EM_UT) - add_executable(rebuild_em_tests rebuild-em-tests.cpp) - target_link_libraries(rebuild_em_tests ${ENGINE_LDFLAGS} ${GTEST_LIBRARIES} ${MARIADB_CLIENT_LIBS} ${ENGINE_WRITE_LIBS}) - install(TARGETS rebuild_em_tests DESTINATION ${ENGINE_BINDIR} COMPONENT columnstore-engine) -endif() - -if (WITH_COMPRESSION_UT) - add_executable(compression_tests compression-tests.cpp) - target_link_libraries(compression_tests ${ENGINE_LDFLAGS} ${GTEST_LIBRARIES} ${MARIADB_CLIENT_LIBS} ${ENGINE_WRITE_LIBS}) - install(TARGETS compression_tests DESTINATION ${ENGINE_BINDIR} COMPONENT columnstore-engine) + add_executable(comparators_tests comparators-tests.cpp) + target_link_libraries(comparators_tests ${ENGINE_LDFLAGS} ${MARIADB_CLIENT_LIBS} ${ENGINE_WRITE_LIBS} ${CPPUNIT_LIBRARIES} cppunit) + add_test(NAME columnstore:comparators_tests, COMMAND comparators_tests) endif() diff --git a/tests/comparators-tests.cpp b/tests/comparators-tests.cpp index 4b754dacf..f31a2526e 100644 --- a/tests/comparators-tests.cpp +++ b/tests/comparators-tests.cpp @@ -129,7 +129,7 @@ class FilterDriver : public CppUnit::TestFixture CPPUNIT_TEST_SUITE_END(); private: - // The tests creates an RG with 1 column of the cscDt type + // The tests creates an RG with 1 column of the cscDt type // then initialize RGData. After that it adds two numeric values (v1 < v2)and two NULL. // Then creates comparator structures and run a number of tests. v1 < v2 void testComparatorWithDT(execplan::CalpontSystemCatalog::ColDataType cscDt, @@ -381,31 +381,32 @@ private: idbCompare.initialize(inRG); ordering::OrderByData odbData = ordering::OrderByData(specVect, inRG); bool result = odbData(r1.getPointer(), r2.getPointer()); - std::cout << r1.toString() << " < " << r2.toString() << " is " + std::cout << r1.toString() << " < " << r2.toString() << " is " << ((result) ? "true" : "false") << std::endl; CPPUNIT_ASSERT(result == true); result = odbData(r2.getPointer(), r1.getPointer()); - std::cout << r2.toString() << " < " << r1.toString() << " is " + std::cout << r2.toString() << " < " << r1.toString() << " is " << ((result) ? "true" : "false") << std::endl; CPPUNIT_ASSERT(result == false); result = odbData(r2.getPointer(), r2.getPointer()); - std::cout << r2.toString() << " < " << r2.toString() << " is " + std::cout << r2.toString() << " < " << r2.toString() << " is " << ((result) ? "true" : "false") << std::endl; CPPUNIT_ASSERT(result == false); - // Compare value with NULL. if spec.fNf then NULLs goes first + // Compare value with NULL. if spec.fNf then NULLs goes first result = odbData(r3.getPointer(), r1.getPointer()); - std::cout << r3.toString() << " < " << r1.toString() << " is " + std::cout << r3.toString() << " < " << r1.toString() << " is " << ((result) ? "true" : "false") << std::endl; CPPUNIT_ASSERT(result == true); // Compare NULL with NULL result = odbData(r3.getPointer(), r1.getPointer()); - std::cout << r3.toString() << " < " << r3.toString() << " is " + std::cout << r3.toString() << " < " << r3.toString() << " is " << ((result) ? "true" : "false") << std::endl; CPPUNIT_ASSERT(result == true); } void INT_TEST() { +#ifdef __x86_64__ //bool generateValues = true; bool fixedValues = false; testComparatorWithDT(execplan::CalpontSystemCatalog::UTINYINT, 1, fixedValues, 20); @@ -424,6 +425,10 @@ private: testComparatorWithDT(execplan::CalpontSystemCatalog::FLOAT, 4, fixedValues, 20); testComparatorWithDT(execplan::CalpontSystemCatalog::DOUBLE, 8, fixedValues, 20); testComparatorWithDT(execplan::CalpontSystemCatalog::LONGDOUBLE, 8, fixedValues, 20); +#elif __arm__ + // TODO: add arm tests +#endif + } void FLOAT_TEST() diff --git a/tests/rowgroup-tests.cpp b/tests/rowgroup-tests.cpp index d386bfb31..38eebc1b7 100644 --- a/tests/rowgroup-tests.cpp +++ b/tests/rowgroup-tests.cpp @@ -163,7 +163,7 @@ protected: std::vector s16ValueVector; std::vector s32ValueVector; std::vector s64ValueVector; - std::vector offsets; + std::vector offsets; }; TEST_F(RowDecimalTest, NonNullValueCheck) @@ -219,11 +219,11 @@ TEST_F(RowDecimalTest, ToStringCheck) { std::vector exemplarVector; - exemplarVector.push_back(std::string("0: NULL NULL NULL NULL NULL NULL ")); - exemplarVector.push_back(std::string("0: -42 42 -121 -121 -121 -121 ")); - exemplarVector.push_back(std::string("0: -79228162495817593515539431425 -79228162495817593515539431425 0 0 0 0 ")); - exemplarVector.push_back(std::string("0: 0 0 129 129 129 -127 ")); - exemplarVector.push_back(std::string("0: 170141183460469231731687303715884105727 170141183460469231731687303715884105727 9223372036854775807 2147483647 32767 127 ")); + exemplarVector.push_back(std::string("[ 0]: 0: NULL NULL NULL NULL NULL NULL ")); + exemplarVector.push_back(std::string("[ 0]: 0: -42 42 -121 -121 -121 -121 ")); + exemplarVector.push_back(std::string("[ 0]: 0: -79228162495817593515539431425 -79228162495817593515539431425 0 0 0 0 ")); + exemplarVector.push_back(std::string("[ 0]: 0: 0 0 129 129 129 -127 ")); + exemplarVector.push_back(std::string("[ 0]: 0: 170141183460469231731687303715884105727 170141183460469231731687303715884105727 9223372036854775807 2147483647 32767 127 ")); rg.getRow(0, &r); r.initToNull(); diff --git a/utils/rowgroup/rowgroup-tests.cpp b/utils/rowgroup/rowgroup-tests.cpp deleted file mode 100644 index 3ebfb6c0b..000000000 --- a/utils/rowgroup/rowgroup-tests.cpp +++ /dev/null @@ -1,241 +0,0 @@ -/* Copyright (C) 2020 MariaDB Corporation - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; version 2 of - the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - MA 02110-1301, USA. */ - -#include // googletest header file -#include - -#include "rowgroup.h" -#include "columnwidth.h" -#include "joblisttypes.h" -#include "dataconvert.h" - -#define WIDE_DEC_PRECISION 38U -#define INITIAL_ROW_OFFSET 2 - -using CSCDataType = execplan::CalpontSystemCatalog::ColDataType; - -class RowDecimalTest : public ::testing::Test { - protected: - void SetUp() override { - uint32_t precision = WIDE_DEC_PRECISION; - uint32_t oid =3001; - - std::vectortypes; - std::vectorprecisionVec; - std::vector roids, tkeys, cscale; - types.push_back(execplan::CalpontSystemCatalog::DECIMAL); - types.push_back(execplan::CalpontSystemCatalog::UDECIMAL); - for (size_t i=0; i <= 3; i++) { - types.push_back(execplan::CalpontSystemCatalog::DECIMAL); - } - precisionVec.push_back(precision); - precisionVec.push_back(precision); - precisionVec.push_back(18); - precisionVec.push_back(9); - precisionVec.push_back(4); - precisionVec.push_back(2); - std::vectorwidthVec; - uint32_t offset = INITIAL_ROW_OFFSET; - offsets.push_back(offset); - for (size_t i=0; i < types.size(); i++) { - uint8_t width = utils::widthByPrecision(precisionVec[i]); - widthVec.push_back(width); - offset += width; - offsets.push_back(offset); - roids.push_back(oid+i); - tkeys.push_back(i+1); cscale.push_back(0); - } - /*offsets.push_back(INITIAL_ROW_OFFSET); - offsets.push_back(16+INITIAL_ROW_OFFSET); - offsets.push_back(16*2+INITIAL_ROW_OFFSET); - roids.push_back(oid); roids.push_back(oid+1); - tkeys.push_back(1); tkeys.push_back(1); - cscale.push_back(0); cscale.push_back(0);*/ - - rowgroup::RowGroup inRG(roids.size(), //column count - offsets, //oldOffset - roids, // column oids - tkeys, //keys - types, // types - cscale, //scale - precisionVec, // precision - 20, // sTableThreshold - false //useStringTable - ); - - rg = inRG; - rgD.reinit(rg); - rg.setData(&rgD); - - rg.initRow(&r); - rg.initRow(&rOutMappingCheck); - rowSize = r.getSize(); - rg.getRow(0, &r); - - int128_t nullValue = 0; - int128_t bigValue = 0; - uint64_t* uint128_pod = reinterpret_cast(&nullValue); - uint128_pod[0] = joblist::UBIGINTNULL; - uint128_pod[1] = joblist::UBIGINTEMPTYROW; - bigValue = -static_cast(0xFFFFFFFF)*0xFFFFFFFFFFFFFFFF; - sValueVector.push_back(nullValue); - sValueVector.push_back(-42); - sValueVector.push_back(bigValue); - sValueVector.push_back(0); - sValueVector.push_back(nullValue-1); - - uValueVector.push_back(nullValue); - uValueVector.push_back(42); - uValueVector.push_back(bigValue); - uValueVector.push_back(0); - uValueVector.push_back(nullValue-1); - - s8ValueVector.push_back(joblist::TINYINTNULL); - s8ValueVector.push_back(-0x79); - s8ValueVector.push_back(0); - s8ValueVector.push_back(0x81); - s8ValueVector.push_back(joblist::TINYINTNULL-1); - - s16ValueVector.push_back(joblist::SMALLINTNULL); - s16ValueVector.push_back(-0x79); - s16ValueVector.push_back(0); - s16ValueVector.push_back(0x81); - s16ValueVector.push_back(joblist::SMALLINTNULL-1); - - s32ValueVector.push_back(joblist::INTNULL); - s32ValueVector.push_back(-0x79); - s32ValueVector.push_back(0); - s32ValueVector.push_back(0x81); - s32ValueVector.push_back(joblist::INTNULL-1); - - s64ValueVector.push_back(joblist::BIGINTNULL); - s64ValueVector.push_back(-0x79); - s64ValueVector.push_back(0); - s64ValueVector.push_back(0x81); - s64ValueVector.push_back(joblist::BIGINTNULL-1); - - for(size_t i = 0; i < sValueVector.size(); i++) { - r.setBinaryField_offset(&sValueVector[i], - sizeof(sValueVector[0]), offsets[0]); - r.setBinaryField_offset(&uValueVector[i], - sizeof(uValueVector[0]), offsets[1]); - r.setIntField(s64ValueVector[i], 2); - r.setIntField(s32ValueVector[i], 3); - r.setIntField(s16ValueVector[i], 4); - r.setIntField(s8ValueVector[i], 5); - r.nextRow(rowSize); - } - rowCount = sValueVector.size(); - } - // void TearDown() override {} - - rowgroup::Row r; - rowgroup::Row rOutMappingCheck; - rowgroup::RowGroup rg; - rowgroup::RGData rgD; - uint32_t rowSize; - size_t rowCount; - std::vector sValueVector; - std::vector uValueVector; - std::vector s8ValueVector; - std::vector s16ValueVector; - std::vector s32ValueVector; - std::vector s64ValueVector; - std::vector offsets; -}; - -TEST_F(RowDecimalTest, NonNULLValuesCheck) { - rg.getRow(1, &r); - for (size_t i = 1; i <= sValueVector.size(); i++) { - EXPECT_FALSE(r.isNullValue(0)); - EXPECT_FALSE(r.isNullValue(1)); - EXPECT_FALSE(r.isNullValue(2)); - EXPECT_FALSE(r.isNullValue(3)); - EXPECT_FALSE(r.isNullValue(4)); - EXPECT_FALSE(r.isNullValue(5)); - r.nextRow(rowSize); - } -} - -TEST_F(RowDecimalTest, initToNullANDisNullValueValueCheck) { - rg.getRow(0, &r); - r.initToNull(); - EXPECT_TRUE(r.isNullValue(0)); - EXPECT_TRUE(r.isNullValue(1)); - EXPECT_TRUE(r.isNullValue(2)); - EXPECT_TRUE(r.isNullValue(3)); - EXPECT_TRUE(r.isNullValue(4)); - EXPECT_TRUE(r.isNullValue(5)); -} - -TEST_F(RowDecimalTest, getBinaryFieldCheck) { - rg.getRow(0, &r); - uint128_t* u128Value; - int128_t* s128Value; -// std::remove_reference::type uType; -// std::remove_reference::type sType; - - for (size_t i = 0; i < sValueVector.size(); i++) { - s128Value = r.getBinaryField(0); - EXPECT_EQ(sValueVector[i], *s128Value); - u128Value = r.getBinaryField(1); - EXPECT_EQ(uValueVector[i], *u128Value); - //EXPECT_EQ(s64ValueVector[i], r.getIntField(2)); - //EXPECT_EQ(s32ValueVector[i],r.getIntField(3)); - //EXPECT_EQ(r.getIntField(4),s16ValueVector[i]); - //EXPECT_EQ(r.getIntField(5),s8ValueVector[i]); - r.nextRow(rowSize); - } -} - -TEST_F(RowDecimalTest, toStringCheck) { - std::vector exemplarVector; - exemplarVector.push_back(std::string("0: NULL NULL NULL NULL NULL NULL ")); - exemplarVector.push_back(std::string("0: -42 42 -121 -121 -121 -121 ")); - exemplarVector.push_back(std::string("0: -79228162495817593515539431425 -79228162495817593515539431425 0 0 0 0 ")); - exemplarVector.push_back(std::string("0: 0 0 129 129 129 -127 ")); - exemplarVector.push_back(std::string("0: -3 -3 9223372036854775807 2147483647 32767 127 ")); - - rg.getRow(0, &r); - r.initToNull(); - for (auto &el: exemplarVector) { - EXPECT_EQ(el, r.toString()); - r.nextRow(rowSize); - } -} - -TEST_F(RowDecimalTest, toCSVCheck) { -} - -TEST_F(RowDecimalTest, applyMappingCheck) { - int mapping[] = {0, 1, -1, -1, -1, -1}; - rg.getRow(1, &r); - rg.getRow(2, &rOutMappingCheck); - int128_t* s128Value = rOutMappingCheck.getBinaryField(0); - uint128_t* u128Value = rOutMappingCheck.getBinaryField(1); - EXPECT_NE(sValueVector[1], *s128Value); - EXPECT_NE(uValueVector[1], *u128Value); - applyMapping(mapping, r, &rOutMappingCheck); - s128Value = rOutMappingCheck.getBinaryField(0); - EXPECT_EQ(sValueVector[1], *s128Value); - u128Value = rOutMappingCheck.getBinaryField(1); - EXPECT_EQ(uValueVector[1], *u128Value); -} - -// WIP -TEST_F(RowDecimalTest, RowEqualsCheck) { -}