提交 4eedfc40 编写于 作者: H hzcheng

add more code

上级 a04663b7
......@@ -6,4 +6,4 @@ add_subdirectory(tsdb)
enable_testing()
add_subdirectory(tests)
\ No newline at end of file
# add_subdirectory(tests)
\ No newline at end of file
add_subdirectory(common)
add_subdirectory(tsdb)
\ No newline at end of file
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} SOURCE_LIST)
message(STATUS "COMMON: ${SOURCE_LIST}")
add_executable(commonTests ${SOURCE_LIST})
target_link_libraries(commonTests gtest gtest_main pthread common)
add_test(
NAME
unit
COMMAND
${CMAKE_CURRENT_BINARY_DIR}/commonTests
)
\ No newline at end of file
#include <gtest/gtest.h>
#include "dataformat.h"
TEST(commonDataTests, createDataRow) {
EXPECT_EQ(1, 2/2);
}
\ No newline at end of file
#include <gtest/gtest.h>
#include <stdlib.h>
#include <stdio.h>
#include "schema.h"
TEST(commonSchemaTests, createSchema) {
EXPECT_EQ(1, 2/2);
}
\ No newline at end of file
......@@ -9,3 +9,5 @@ target_include_directories(tsdb
PUBLIC "${CMAKE_SOURCE_DIR}/src/util/inc"
PUBLIC "${CMAKE_SOURCE_DIR}/src/os/linux/inc"
)
add_subdirectory(tests)
\ No newline at end of file
......@@ -116,6 +116,7 @@ int32_t tsdbCreateTableImpl(STsdbMeta *pMeta, STableCfg *pCfg);
int32_t tsdbDropTableImpl(STsdbMeta *pMeta, STableId tableId);
STable *tsdbIsValidTableToInsert(STsdbMeta *pMeta, STableId tableId);
int32_t tsdbInsertRowToTableImpl(SSkipListNode *pNode, STable *pTable);
STable *tsdbGetTableByUid(STsdbMeta *pMeta, int64_t uid);
#ifdef __cplusplus
}
......
......@@ -12,7 +12,6 @@
static int tsdbFreeTable(STable *pTable);
static int32_t tsdbCheckTableCfg(STableCfg *pCfg);
static STable *tsdbGetTableByUid(STsdbMeta *pMeta, int64_t uid);
static int tsdbAddTableToMeta(STsdbMeta *pMeta, STable *pTable);
static int tsdbAddTableIntoMap(STsdbMeta *pMeta, STable *pTable);
static int tsdbAddTableIntoIndex(STsdbMeta *pMeta, STable *pTable);
......@@ -206,7 +205,7 @@ static int32_t tsdbCheckTableCfg(STableCfg *pCfg) {
return 0;
}
static STable *tsdbGetTableByUid(STsdbMeta *pMeta, int64_t uid) {
STable *tsdbGetTableByUid(STsdbMeta *pMeta, int64_t uid) {
return (STable *)taosGetDataFromHashTable(pMeta->tableMap, (char *)(&uid), sizeof(uid));
}
......
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} SOURCE_LIST)
message(STATUS "TSDB: ${SOURCE_LIST}")
add_executable(tsdbTests ${SOURCE_LIST})
target_link_libraries(tsdbTests gtest gtest_main pthread tsdb)
......
#include <gtest/gtest.h>
#include <stdlib.h>
#include "tsdb.h"
#include "tsdbMeta.h"
TEST(TsdbTest, createTsdbRepo) {
TEST(TsdbTest, createTable) {
STsdbMeta *pMeta = tsdbCreateMeta(100);
ASSERT_NE(pMeta, nullptr);
STableCfg config;
config.tableId.tid = 0;
config.tableId.uid = 98868728187539L;
config.numOfCols = 2;
config.schema = (SSchema *)malloc(sizeof(SSchema) + sizeof(SColumn) * config.numOfCols);
config.schema->version = 0;
config.schema->numOfCols = 2;
config.schema->numOfTags = 0;
config.schema->colIdCounter = 1;
for (int i = 0; i < config.numOfCols; i++) {
SColumn *pCol = config.schema->columns + i;
pCol->type = TD_DATATYPE_BIGINT;
pCol->colId = config.schema->colIdCounter++;
pCol->offset = 10;
pCol->colName = strdup("col1");
}
config.tagValues = nullptr;
tsdbCreateTableImpl(pMeta, &config), 0;
STable *pTable = tsdbGetTableByUid(pMeta, config.tableId.uid);
ASSERT_NE(pTable, nullptr);
}
TEST(TsdbTest, DISABLED_createTsdbRepo) {
STsdbCfg *pCfg = tsdbCreateDefaultCfg();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册