From 878d14052fb4f13af555b1bdff078954c4c9034a Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Thu, 12 Oct 2023 17:56:02 +0800 Subject: [PATCH] fix(test): fix syntax error on windows. --- source/client/test/clientTests.cpp | 46 ++++++++++++++++++------------ 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/source/client/test/clientTests.cpp b/source/client/test/clientTests.cpp index d73a72f96a..addf0aa629 100644 --- a/source/client/test/clientTests.cpp +++ b/source/client/test/clientTests.cpp @@ -47,7 +47,8 @@ void printSubResults(void* pRes, int32_t* totalRows) { int32_t precision = taos_result_precision(pRes); taos_print_row(buf, row, fields, numOfFields); *totalRows += 1; - printf("vgId: %d, offset: %"PRId64", precision: %d, row content: %s\n", vgId, offset, precision, buf); + std::cout << "vgId:" << vgId << ", offset:" << offset << ", precision:" << precision << ", row content:" << buf + << std::endl; } // taos_free_result(pRes); @@ -1167,16 +1168,19 @@ TEST(clientCase, tmq_commit) { } for(int i = 0; i < numOfAssign; i++){ - printf("assign i:%d, vgId:%d, offset:%"PRId64", start:%"PRId64", end:%"PRId64"\n", i, pAssign[i].vgId, pAssign[i].currentOffset, pAssign[i].begin, pAssign[i].end); + tmq_topic_assignment* pa = &pAssign[i]; + std::cout << "assign i:" << i << ", vgId:" << pa->vgId << ", offset:" << pa->currentOffset << ", start:%" + << pa->begin << ", end:%" << pa->end << std::endl; - int64_t committed = tmq_committed(tmq, topicName, pAssign[i].vgId); - printf("committed vgId:%d, committed:%"PRId64"\n", pAssign[i].vgId, committed); + int64_t committed = tmq_committed(tmq, topicName, pa->vgId); + std::cout << "committed vgId:" << pa->vgId << " committed:" << committed << std::endl; - int64_t position = tmq_position(tmq, topicName, pAssign[i].vgId); - printf("position vgId:%d, position:%"PRId64"\n", pAssign[i].vgId, position); - tmq_offset_seek(tmq, topicName, pAssign[i].vgId, 1); - position = tmq_position(tmq, topicName, pAssign[i].vgId); - printf("after seek 1, position vgId:%d, position:%"PRId64"\n", pAssign[i].vgId, position); + int64_t position = tmq_position(tmq, topicName, pa->vgId); + std::cout << "position vgId:" << pa->vgId << ", position:" << position << std::endl; + + tmq_offset_seek(tmq, topicName, pa->vgId, 1); + position = tmq_position(tmq, topicName, pa->vgId); + std::cout << "after seek 1, position vgId:" << pa->vgId << " position:" << position << std::endl; } while (1) { @@ -1191,12 +1195,14 @@ TEST(clientCase, tmq_commit) { tmq_commit_sync(tmq, pRes); for(int i = 0; i < numOfAssign; i++) { int64_t committed = tmq_committed(tmq, topicName, pAssign[i].vgId); - printf("committed vgId:%d, committed:%"PRId64"\n", pAssign[i].vgId, committed); + std::cout << "committed vgId:" << pAssign[i].vgId << " , committed:" << committed << std::endl; if(committed > 0){ int32_t code = tmq_commit_offset_sync(tmq, topicName, pAssign[i].vgId, 4); printf("tmq_commit_offset_sync vgId:%d, offset:4, code:%d\n", pAssign[i].vgId, code); int64_t committed = tmq_committed(tmq, topicName, pAssign[i].vgId); - printf("after tmq_commit_offset_sync, committed vgId:%d, committed:%"PRId64"\n", pAssign[i].vgId, committed); + + std::cout << "after tmq_commit_offset_sync, committed vgId:" << pAssign[i].vgId << ", committed:" << committed + << std::endl; } } if (pRes != NULL) { @@ -1212,7 +1218,12 @@ TEST(clientCase, tmq_commit) { taos_close(pConn); fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows); } - +namespace { +void doPrintInfo(tmq_topic_assignment* pa, int32_t index) { + std::cout << "assign i:" << index << ", vgId:" << pa->vgId << ", offset:%" << pa->currentOffset << ", start:%" + << pa->begin << ", end:%" << pa->end << std::endl; +} +} TEST(clientCase, td_25129) { // taos_options(TSDB_OPTION_CONFIGDIR, "~/first/cfg"); @@ -1264,7 +1275,7 @@ TEST(clientCase, td_25129) { } for(int i = 0; i < numOfAssign; i++){ - printf("assign i:%d, vgId:%d, offset:%"PRId64", start:%"PRId64", end:%"PRId64"\n", i, pAssign[i].vgId, pAssign[i].currentOffset, pAssign[i].begin, pAssign[i].end); + doPrintInfo(&pAssign[i], i); } // tmq_offset_seek(tmq, "tp", pAssign[0].vgId, 4); @@ -1281,7 +1292,7 @@ TEST(clientCase, td_25129) { } for(int i = 0; i < numOfAssign; i++){ - printf("assign i:%d, vgId:%d, offset:%"PRId64", start:%"PRId64", end:%"PRId64"\n", i, pAssign[i].vgId, pAssign[i].currentOffset, pAssign[i].begin, pAssign[i].end); + doPrintInfo(&pAssign[i], i); } tmq_free_assignment(pAssign); @@ -1298,7 +1309,7 @@ TEST(clientCase, td_25129) { for(int i = 0; i < numOfAssign; i++){ int64_t committed = tmq_committed(tmq, topicName, pAssign[i].vgId); - printf("assign i:%d, vgId:%d, committed:%"PRId64", offset:%"PRId64", start:%"PRId64", end:%"PRId64"\n", i, pAssign[i].vgId, committed, pAssign[i].currentOffset, pAssign[i].begin, pAssign[i].end); + doPrintInfo(&pAssign[i], i); } while (1) { @@ -1328,7 +1339,7 @@ TEST(clientCase, td_25129) { } for(int i = 0; i < numOfAssign; i++){ - printf("assign i:%d, vgId:%d, offset:%"PRId64", start:%"PRId64", end:%"PRId64"\n", i, pAssign[i].vgId, pAssign[i].currentOffset, pAssign[i].begin, pAssign[i].end); + doPrintInfo(&pAssign[i], i); } } else { for(int i = 0; i < numOfAssign; i++) { @@ -1364,8 +1375,7 @@ TEST(clientCase, td_25129) { } for(int i = 0; i < numOfAssign; i++){ - printf("assign i:%d, vgId:%d, offset:%"PRId64", start:%"PRId64", end:%"PRId64"\n", i, pAssign[i].vgId, pAssign[i].currentOffset, - pAssign[i].begin, pAssign[i].end); + doPrintInfo(&pAssign[i], i); } tmq_free_assignment(pAssign);