From 7adad817c90e3945962c2ffde7df2df04d74f89e Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Fri, 8 Dec 2023 18:27:38 +0800 Subject: [PATCH] case: add arrayTest unit case --- source/util/test/CMakeLists.txt | 8 ++++++++ source/util/test/arrayTest.cpp | 18 ++++++++++++++++++ tests/army/test.py | 12 ++++++------ 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/source/util/test/CMakeLists.txt b/source/util/test/CMakeLists.txt index 94f8deee44..f4f3880388 100644 --- a/source/util/test/CMakeLists.txt +++ b/source/util/test/CMakeLists.txt @@ -33,6 +33,14 @@ ENDIF() INCLUDE_DIRECTORIES(${TD_SOURCE_DIR}/src/util/inc) +# arrayTest +add_executable(arrayTest "arrayTest.cpp") +target_link_libraries(arrayTest os util gtest_main) +add_test( + NAME arrayTest + COMMAND arrayTest +) + # # freelistTest # add_executable(freelistTest "") # target_sources(freelistTest diff --git a/source/util/test/arrayTest.cpp b/source/util/test/arrayTest.cpp index a579837791..4c21017436 100644 --- a/source/util/test/arrayTest.cpp +++ b/source/util/test/arrayTest.cpp @@ -82,3 +82,21 @@ TEST(arrayTest, array_search_test) { taosArrayDestroy(pa); } + +TEST(arrayTest, array_data_correct) { + SArray* pa = (SArray*)taosArrayInit(1, sizeof(int32_t)); + size_t cnt = 1000; + + for (int32_t i = 0; i < cnt; ++i) { + taosArrayPush(pa, &i); + } + ASSERT_EQ(taosArrayGetSize(pa), cnt); + + int32_t* pv = NULL; + for (int32_t i = 0; i < cnt; i++) { + pv = (int32_t*)taosArrayGet(pa, i); + ASSERT_EQ(*pv, i); + } + + taosArrayDestroy(pa); +} diff --git a/tests/army/test.py b/tests/army/test.py index 795132b14e..cc114e0d16 100644 --- a/tests/army/test.py +++ b/tests/army/test.py @@ -26,12 +26,12 @@ import threading import importlib import toml -sys.path.append("../pytest") -from util.log import * -from util.dnodes import * -from util.cases import * -from util.cluster import * -from util.taosadapter import * + +from frame.log import * +from frame.dnodes import * +from frame.cases import * +from frame.cluster import * +from frame.taosadapter import * import taos import taosrest