From 2e290b12e3c7b09dc7eb6439f8f689b2af98d862 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Fri, 8 Jan 2021 17:13:55 +0800 Subject: [PATCH] [TD-225]udpate the test cases. --- src/query/tests/tsBufTest.cpp | 42 +++++++++++----------- src/query/tests/unitTest.cpp | 68 +++++++++++++++++------------------ 2 files changed, 55 insertions(+), 55 deletions(-) diff --git a/src/query/tests/tsBufTest.cpp b/src/query/tests/tsBufTest.cpp index bada3194bd..8ca636b834 100644 --- a/src/query/tests/tsBufTest.cpp +++ b/src/query/tests/tsBufTest.cpp @@ -34,7 +34,7 @@ void simpleTest() { int32_t num = 10; tVariant t = {0}; t.nType = TSDB_DATA_TYPE_BIGINT; - t.i64Key = 1; + t.i64 = 1; int64_t* list = createTsList(10, 10000000, 30); tsBufAppend(pTSBuf, 0, &t, (const char*)list, num * sizeof(int64_t)); @@ -61,7 +61,7 @@ void largeTSTest() { int32_t num = 1000000; tVariant t = {0}; t.nType = TSDB_DATA_TYPE_BIGINT; - t.i64Key = 1; + t.i64 = 1; int64_t* list = createTsList(num, 10000000, 30); tsBufAppend(pTSBuf, 0, &t, (const char*)list, num * sizeof(int64_t)); @@ -93,7 +93,7 @@ void multiTagsTest() { for (int32_t i = 0; i < numOfTags; ++i) { int64_t* list = createTsList(num, start, step); - t.i64Key = i; + t.i64 = i; tsBufAppend(pTSBuf, 0, &t, (const char*)list, num * sizeof(int64_t)); free(list); @@ -104,7 +104,7 @@ void multiTagsTest() { EXPECT_EQ(pTSBuf->tsOrder, TSDB_ORDER_ASC); EXPECT_EQ(pTSBuf->tsData.len, num * sizeof(int64_t)); - EXPECT_EQ(pTSBuf->block.tag.i64Key, numOfTags - 1); + EXPECT_EQ(pTSBuf->block.tag.i64, numOfTags - 1); EXPECT_EQ(pTSBuf->numOfGroups, 1); tsBufFlush(pTSBuf); @@ -131,7 +131,7 @@ void multiVnodeTagsTest() { for (int32_t i = 0; i < numOfTags; ++i) { int64_t* list = createTsList(num, start, step); - t.i64Key = i; + t.i64 = i; tsBufAppend(pTSBuf, j, &t, (const char*)list, num * sizeof(int64_t)); free(list); @@ -144,11 +144,11 @@ void multiVnodeTagsTest() { EXPECT_EQ(pTSBuf->tsOrder, TSDB_ORDER_ASC); EXPECT_EQ(pTSBuf->tsData.len, num * sizeof(int64_t)); - EXPECT_EQ(pTSBuf->block.tag.i64Key, numOfTags - 1); + EXPECT_EQ(pTSBuf->block.tag.i64, numOfTags - 1); EXPECT_EQ(pTSBuf->tsData.len, num * sizeof(int64_t)); - EXPECT_EQ(pTSBuf->block.tag.i64Key, numOfTags - 1); + EXPECT_EQ(pTSBuf->block.tag.i64, numOfTags - 1); tsBufFlush(pTSBuf); EXPECT_EQ(pTSBuf->tsData.len, 0); @@ -175,7 +175,7 @@ void loadDataTest() { for (int32_t i = 0; i < numOfTags; ++i) { int64_t* list = createTsList(num, start, step); - t.i64Key = i; + t.i64 = i; tsBufAppend(pTSBuf, j, &t, (const char*)list, num * sizeof(int64_t)); printf("%d - %" PRIu64 "\n", i, list[0]); @@ -190,11 +190,11 @@ void loadDataTest() { EXPECT_EQ(pTSBuf->tsOrder, TSDB_ORDER_ASC); EXPECT_EQ(pTSBuf->tsData.len, num * sizeof(int64_t)); - EXPECT_EQ(pTSBuf->block.tag.i64Key, numOfTags - 1); + EXPECT_EQ(pTSBuf->block.tag.i64, numOfTags - 1); EXPECT_EQ(pTSBuf->tsData.len, num * sizeof(int64_t)); - EXPECT_EQ(pTSBuf->block.tag.i64Key, numOfTags - 1); + EXPECT_EQ(pTSBuf->block.tag.i64, numOfTags - 1); tsBufFlush(pTSBuf); EXPECT_EQ(pTSBuf->tsData.len, 0); @@ -253,7 +253,7 @@ void TSTraverse() { for (int32_t i = 0; i < numOfTags; ++i) { int64_t* list = createTsList(num, start, step); - t.i64Key = i; + t.i64 = i; tsBufAppend(pTSBuf, j, &t, (const char*)list, num * sizeof(int64_t)); printf("%d - %d - %" PRIu64 ", %" PRIu64 "\n", j, i, list[0], list[num - 1]); @@ -297,14 +297,14 @@ void TSTraverse() { tVariant t = {0}; t.nType = TSDB_DATA_TYPE_BIGINT; - t.i64Key = startTag; + t.i64 = startTag; tsBufGetElemStartPos(pTSBuf, startVnode, &t); int32_t totalOutput = 10; while (1) { STSElem elem = tsBufGetElem(pTSBuf); - printf("%d-%" PRIu64 "-%" PRIu64 "\n", elem.id, elem.tag->i64Key, elem.ts); + printf("%d-%" PRIu64 "-%" PRIu64 "\n", elem.id, elem.tag->i64, elem.ts); if (!tsBufNextPos(pTSBuf)) { break; @@ -314,7 +314,7 @@ void TSTraverse() { totalOutput = 10; startTag -= 1; - t.i64Key = startTag; + t.i64 = startTag; tsBufGetElemStartPos(pTSBuf, startVnode, &t); if (startTag == 0) { @@ -345,14 +345,14 @@ void TSTraverse() { startVnode = 1; startTag = 2; - t.i64Key = startTag; + t.i64 = startTag; tsBufGetElemStartPos(pTSBuf, startVnode, &t); totalOutput = 10; while (1) { STSElem elem = tsBufGetElem(pTSBuf); - printf("%d-%" PRIu64 "-%" PRIu64 "\n", elem.id, elem.tag->i64Key, elem.ts); + printf("%d-%" PRIu64 "-%" PRIu64 "\n", elem.id, elem.tag->i64, elem.ts); if (!tsBufNextPos(pTSBuf)) { break; @@ -362,7 +362,7 @@ void TSTraverse() { totalOutput = 10; startTag -= 1; - t.i64Key = startTag; + t.i64 = startTag; tsBufGetElemStartPos(pTSBuf, startVnode, &t); if (startTag < 0) { @@ -414,7 +414,7 @@ void mergeDiffVnodeBufferTest() { int64_t start = 10000000; for (int32_t i = 0; i < numOfTags; ++i) { int64_t* list = createTsList(num, start, step); - t.i64Key = i; + t.i64 = i; tsBufAppend(pTSBuf1, 1, &t, (const char*)list, num * sizeof(int64_t)); tsBufAppend(pTSBuf2, 9, &t, (const char*)list, num * sizeof(int64_t)); @@ -451,7 +451,7 @@ void mergeIdenticalVnodeBufferTest() { int64_t start = 10000000; for (int32_t i = 0; i < numOfTags; ++i) { int64_t* list = createTsList(num, start, step); - t.i64Key = i; + t.i64 = i; tsBufAppend(pTSBuf1, 12, &t, (const char*)list, num * sizeof(int64_t)); free(list); @@ -462,7 +462,7 @@ void mergeIdenticalVnodeBufferTest() { for (int32_t i = numOfTags; i < numOfTags * 2; ++i) { int64_t* list = createTsList(num, start, step); - t.i64Key = i; + t.i64 = i; tsBufAppend(pTSBuf2, 77, &t, (const char*)list, num * sizeof(int64_t)); free(list); @@ -487,7 +487,7 @@ void mergeIdenticalVnodeBufferTest() { EXPECT_EQ(elem.id, 77); } - printf("%d-%" PRIu64 "-%" PRIu64 "\n", elem.id, elem.tag->i64Key, elem.ts); + printf("%d-%" PRIu64 "-%" PRIu64 "\n", elem.id, elem.tag->i64, elem.ts); } tsBufDestroy(pTSBuf1); diff --git a/src/query/tests/unitTest.cpp b/src/query/tests/unitTest.cpp index b6e1170d0e..a8500364dc 100644 --- a/src/query/tests/unitTest.cpp +++ b/src/query/tests/unitTest.cpp @@ -27,22 +27,22 @@ int32_t testValidateName(char* name) { } static void _init_tvariant_bool(tVariant* t) { - t->i64Key = TSDB_FALSE; + t->i64 = TSDB_FALSE; t->nType = TSDB_DATA_TYPE_BOOL; } static void _init_tvariant_tinyint(tVariant* t) { - t->i64Key = -27; + t->i64 = -27; t->nType = TSDB_DATA_TYPE_TINYINT; } static void _init_tvariant_int(tVariant* t) { - t->i64Key = -23997659; + t->i64 = -23997659; t->nType = TSDB_DATA_TYPE_INT; } static void _init_tvariant_bigint(tVariant* t) { - t->i64Key = -3333333333333; + t->i64 = -3333333333333; t->nType = TSDB_DATA_TYPE_BIGINT; } @@ -446,19 +446,19 @@ TEST(testCase, tvariant_convert) { _init_tvariant_bool(&t); EXPECT_EQ(tVariantTypeSetType(&t, TSDB_DATA_TYPE_BOOL), 0); - EXPECT_EQ(t.i64Key, 0); + EXPECT_EQ(t.i64, 0); _init_tvariant_bool(&t); EXPECT_EQ(tVariantTypeSetType(&t, TSDB_DATA_TYPE_TINYINT), 0); - EXPECT_EQ(t.i64Key, 0); + EXPECT_EQ(t.i64, 0); _init_tvariant_bool(&t); EXPECT_EQ(tVariantTypeSetType(&t, TSDB_DATA_TYPE_SMALLINT), 0); - EXPECT_EQ(t.i64Key, 0); + EXPECT_EQ(t.i64, 0); _init_tvariant_bool(&t); EXPECT_EQ(tVariantTypeSetType(&t, TSDB_DATA_TYPE_BIGINT), 0); - EXPECT_EQ(t.i64Key, 0); + EXPECT_EQ(t.i64, 0); _init_tvariant_bool(&t); EXPECT_EQ(tVariantTypeSetType(&t, TSDB_DATA_TYPE_FLOAT), 0); @@ -481,23 +481,23 @@ TEST(testCase, tvariant_convert) { // 2. tinyint to other data types _init_tvariant_tinyint(&t); EXPECT_EQ(tVariantTypeSetType(&t, TSDB_DATA_TYPE_BOOL), 0); - EXPECT_EQ(t.i64Key, 1); + EXPECT_EQ(t.i64, 1); _init_tvariant_tinyint(&t); EXPECT_EQ(tVariantTypeSetType(&t, TSDB_DATA_TYPE_TINYINT), 0); - EXPECT_EQ(t.i64Key, -27); + EXPECT_EQ(t.i64, -27); _init_tvariant_tinyint(&t); EXPECT_EQ(tVariantTypeSetType(&t, TSDB_DATA_TYPE_SMALLINT), 0); - EXPECT_EQ(t.i64Key, -27); + EXPECT_EQ(t.i64, -27); _init_tvariant_tinyint(&t); EXPECT_EQ(tVariantTypeSetType(&t, TSDB_DATA_TYPE_INT), 0); - EXPECT_EQ(t.i64Key, -27); + EXPECT_EQ(t.i64, -27); _init_tvariant_tinyint(&t); EXPECT_EQ(tVariantTypeSetType(&t, TSDB_DATA_TYPE_BIGINT), 0); - EXPECT_EQ(t.i64Key, -27); + EXPECT_EQ(t.i64, -27); _init_tvariant_tinyint(&t); EXPECT_EQ(tVariantTypeSetType(&t, TSDB_DATA_TYPE_FLOAT), 0); @@ -521,7 +521,7 @@ TEST(testCase, tvariant_convert) { // types////////////////////////////////////////////////////////////////// _init_tvariant_int(&t); EXPECT_EQ(tVariantTypeSetType(&t, TSDB_DATA_TYPE_BOOL), 0); - EXPECT_EQ(t.i64Key, 1); + EXPECT_EQ(t.i64, 1); _init_tvariant_int(&t); EXPECT_EQ(tVariantTypeSetType(&t, TSDB_DATA_TYPE_TINYINT), 0); @@ -531,11 +531,11 @@ TEST(testCase, tvariant_convert) { _init_tvariant_int(&t); EXPECT_EQ(tVariantTypeSetType(&t, TSDB_DATA_TYPE_INT), 0); - EXPECT_EQ(t.i64Key, -23997659); + EXPECT_EQ(t.i64, -23997659); _init_tvariant_int(&t); EXPECT_EQ(tVariantTypeSetType(&t, TSDB_DATA_TYPE_BIGINT), 0); - EXPECT_EQ(t.i64Key, -23997659); + EXPECT_EQ(t.i64, -23997659); _init_tvariant_int(&t); EXPECT_EQ(tVariantTypeSetType(&t, TSDB_DATA_TYPE_FLOAT), 0); @@ -559,7 +559,7 @@ TEST(testCase, tvariant_convert) { // type////////////////////////////////////////////////////////////////////////////// _init_tvariant_bigint(&t); EXPECT_EQ(tVariantTypeSetType(&t, TSDB_DATA_TYPE_BOOL), 0); - EXPECT_EQ(t.i64Key, 1); + EXPECT_EQ(t.i64, 1); _init_tvariant_bigint(&t); EXPECT_EQ(tVariantTypeSetType(&t, TSDB_DATA_TYPE_TINYINT), 0); @@ -572,7 +572,7 @@ TEST(testCase, tvariant_convert) { _init_tvariant_bigint(&t); EXPECT_EQ(tVariantTypeSetType(&t, TSDB_DATA_TYPE_BIGINT), 0); - EXPECT_EQ(t.i64Key, -3333333333333); + EXPECT_EQ(t.i64, -3333333333333); _init_tvariant_bigint(&t); EXPECT_EQ(tVariantTypeSetType(&t, TSDB_DATA_TYPE_FLOAT), 0); @@ -596,11 +596,11 @@ TEST(testCase, tvariant_convert) { // types//////////////////////////////////////////////////////////////////////// _init_tvariant_float(&t); EXPECT_EQ(tVariantTypeSetType(&t, TSDB_DATA_TYPE_BOOL), 0); - EXPECT_EQ(t.i64Key, 1); + EXPECT_EQ(t.i64, 1); _init_tvariant_float(&t); EXPECT_EQ(tVariantTypeSetType(&t, TSDB_DATA_TYPE_BIGINT), 0); - EXPECT_EQ(t.i64Key, -8991212199); + EXPECT_EQ(t.i64, -8991212199); _init_tvariant_float(&t); EXPECT_EQ(tVariantTypeSetType(&t, TSDB_DATA_TYPE_FLOAT), 0); @@ -626,14 +626,14 @@ TEST(testCase, tvariant_convert) { t.nLen = strlen(t.pz); t.nType = TSDB_DATA_TYPE_BINARY; EXPECT_EQ(tVariantTypeSetType(&t, TSDB_DATA_TYPE_BOOL), 0); - EXPECT_EQ(t.i64Key, 1); + EXPECT_EQ(t.i64, 1); _init_tvariant_binary(&t); EXPECT_EQ(tVariantTypeSetType(&t, TSDB_DATA_TYPE_BOOL), -1); _init_tvariant_binary(&t); EXPECT_EQ(tVariantTypeSetType(&t, TSDB_DATA_TYPE_BIGINT), 0); - EXPECT_EQ(t.i64Key, 200000); + EXPECT_EQ(t.i64, 200000); _init_tvariant_binary(&t); EXPECT_EQ(tVariantTypeSetType(&t, TSDB_DATA_TYPE_FLOAT), 0); @@ -659,14 +659,14 @@ TEST(testCase, tvariant_convert) { t.nLen = wcslen(t.wpz); t.nType = TSDB_DATA_TYPE_NCHAR; EXPECT_EQ(tVariantTypeSetType(&t, TSDB_DATA_TYPE_BOOL), 0); - EXPECT_EQ(t.i64Key, 0); + EXPECT_EQ(t.i64, 0); _init_tvariant_nchar(&t); EXPECT_LE(tVariantTypeSetType(&t, TSDB_DATA_TYPE_BOOL), 0); _init_tvariant_nchar(&t); EXPECT_EQ(tVariantTypeSetType(&t, TSDB_DATA_TYPE_BIGINT), 0); - EXPECT_EQ(t.i64Key, -2000000); + EXPECT_EQ(t.i64, -2000000); _init_tvariant_nchar(&t); EXPECT_EQ(tVariantTypeSetType(&t, TSDB_DATA_TYPE_FLOAT), 0); @@ -732,34 +732,34 @@ static SStrToken createStrToken(char* s) { TEST(testCase, isValidNumber_test) { SStrToken t1 = createStrToken("123abc"); - EXPECT_EQ(isValidNumber(&t1), TK_ILLEGAL); + EXPECT_EQ(tGetNumericStringType(&t1), TK_ILLEGAL); t1 = createStrToken("0xabc"); - EXPECT_EQ(isValidNumber(&t1), TK_HEX); + EXPECT_EQ(tGetNumericStringType(&t1), TK_HEX); t1 = createStrToken("0b11101"); - EXPECT_EQ(isValidNumber(&t1), TK_BIN); + EXPECT_EQ(tGetNumericStringType(&t1), TK_BIN); t1 = createStrToken(".134abc"); - EXPECT_EQ(isValidNumber(&t1), TK_ILLEGAL); + EXPECT_EQ(tGetNumericStringType(&t1), TK_ILLEGAL); t1 = createStrToken("1e1 "); - EXPECT_EQ(isValidNumber(&t1), TK_ILLEGAL); + EXPECT_EQ(tGetNumericStringType(&t1), TK_ILLEGAL); t1 = createStrToken("1+2"); - EXPECT_EQ(isValidNumber(&t1), TK_ILLEGAL); + EXPECT_EQ(tGetNumericStringType(&t1), TK_ILLEGAL); t1 = createStrToken("-0x123"); - EXPECT_EQ(isValidNumber(&t1), TK_HEX); + EXPECT_EQ(tGetNumericStringType(&t1), TK_HEX); t1 = createStrToken("-1"); - EXPECT_EQ(isValidNumber(&t1), TK_INTEGER); + EXPECT_EQ(tGetNumericStringType(&t1), TK_INTEGER); t1 = createStrToken("-0b1110"); - EXPECT_EQ(isValidNumber(&t1), TK_BIN); + EXPECT_EQ(tGetNumericStringType(&t1), TK_BIN); t1 = createStrToken("-.234"); - EXPECT_EQ(isValidNumber(&t1), TK_FLOAT); + EXPECT_EQ(tGetNumericStringType(&t1), TK_FLOAT); } TEST(testCase, getTempFilePath_test) { -- GitLab