diff --git a/source/libs/decimal/test/decimalTest.cpp b/source/libs/decimal/test/decimalTest.cpp index 4babb489a0..b760c0bfb8 100644 --- a/source/libs/decimal/test/decimalTest.cpp +++ b/source/libs/decimal/test/decimalTest.cpp @@ -717,12 +717,9 @@ TEST(decimal, toStr) { } SDataType getDecimalType(uint8_t prec, uint8_t scale) { - if (prec <= 18) { - return {.type = TSDB_DATA_TYPE_DECIMAL64, .precision = prec, .scale = scale, .bytes = 8}; - } else if (prec <= 38) { - return {.type = TSDB_DATA_TYPE_DECIMAL, .precision = prec, .scale = scale, .bytes = 16}; - } - return {}; + if (prec > TSDB_DECIMAL_MAX_PRECISION) throw std::string("invalid prec: ") + std::to_string(prec); + uint8_t type = decimalTypeFromPrecision(prec); + return {.type = type, .precision = prec, .scale = scale, .bytes = tDataTypes[type].bytes}; } bool operator==(const SDataType& lt, const SDataType& rt) { diff --git a/source/util/test/CMakeLists.txt b/source/util/test/CMakeLists.txt index 768e465fea..9158e07e72 100644 --- a/source/util/test/CMakeLists.txt +++ b/source/util/test/CMakeLists.txt @@ -30,7 +30,7 @@ ENDIF() # ADD_EXECUTABLE(trefTest ./trefTest.c) # TARGET_LINK_LIBRARIES(trefTest util common) # ENDIF () -INCLUDE_DIRECTORIES(${TD_SOURCE_DIR}/src/util/inc) +INCLUDE_DIRECTORIES(${TD_SOURCE_DIR}/source/util/inc) INCLUDE_DIRECTORIES(${TD_SOURCE_DIR}/include/common) add_executable(heapTest "heapTest.cpp")