1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-29 08:21:15 +03:00

MCOL-641 Changed the hint to search for GTest headers.

This commit introduces DataConvert UTs.

DataConvert::decimalToString now can negative values.

Next version for Row::toString(), applyMapping UT checks.

Row:equals() is now wide-DECIMAL aware.
This commit is contained in:
drrtuy
2020-02-24 17:22:52 +03:00
committed by Roman Nozdrin
parent c23ead2703
commit b29d0c9daa
7 changed files with 142 additions and 39 deletions

View File

@ -11,3 +11,9 @@ add_library(dataconvert SHARED ${dataconvert_LIB_SRCS})
add_dependencies(dataconvert loggingcpp)
install(TARGETS dataconvert DESTINATION ${ENGINE_LIBDIR} COMPONENT columnstore-engine)
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-platform)
endif()

View File

@ -1220,7 +1220,7 @@ size_t DataConvert::writeIntPart(T* dec, char* p,
if (buflen <= p-original_p)
{
throw QueryDataExcept("toString() char buffer overflow.", formatErr);
throw QueryDataExcept("writeIntPart() char buffer overflow.", formatErr);
}
return p-original_p;
}
@ -1352,31 +1352,27 @@ void DataConvert::decimalToString(T* valuePtr,
unsigned int buflen,
cscDataType colDataType) // We don't need the last one
{
if (*valuePtr < static_cast<T>(0))
T value = *valuePtr;
char* ptr = &buf[0];
size_t l1 = buflen;
if (value < static_cast<T>(0))
{
*buf++ = '-';
*valuePtr *= -1;
*ptr++ = '-';
value *= -1;
idbassert(l1 >= 2);
l1--;
}
toString<T>(valuePtr, buf, buflen);
//we want to move the last scale chars right by one spot to insert the dp
//we want to move the trailing null as well, so it's really scale+1 chars
toString<T>(&value, ptr, buflen);
// Biggest ColumnStore supports is DECIMAL(38,x), or 38 total digits+dp+sign for column
if (scale == 0)
return;
//we want to move the last scale chars right by one spot to insert the dp
//we want to move the trailing null as well, so it's really scale+1 chars
size_t l1 = strlen(buf);
char* ptr = &buf[0];
if (*valuePtr < 0)
{
ptr++;
idbassert(l1 >= 2);
l1--;
}
//need to make sure we have enough leading zeros for this to work...
//at this point scale is always > 0
size_t l2 = 1;