init
This commit is contained in:
7
tests/CMakeLists.txt
Normal file
7
tests/CMakeLists.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
project(test)
|
||||
|
||||
|
||||
|
||||
add_subdirectory(container)
|
||||
add_subdirectory(io)
|
||||
|
||||
10
tests/container/CMakeLists.txt
Normal file
10
tests/container/CMakeLists.txt
Normal file
@@ -0,0 +1,10 @@
|
||||
project(test-container)
|
||||
|
||||
|
||||
add_executable(${PROJECT_NAME}-string test-lt-string.c)
|
||||
target_link_libraries(${PROJECT_NAME}-string latch)
|
||||
if(UNIX)
|
||||
add_test(${PROJECT_NAME}-string ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-string)
|
||||
elseif(WIN32)
|
||||
add_test(${PROJECT_NAME}-string ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-string.exe)
|
||||
endif()
|
||||
31
tests/container/test-lt-string.c
Normal file
31
tests/container/test-lt-string.c
Normal file
@@ -0,0 +1,31 @@
|
||||
#include "latch/container/lt-string.h"
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
printf("LT_String 创建测试\n");
|
||||
LT_String *str = lt_string_new("Hello, world!");
|
||||
printf("字符串内容: %s\n", str->data);
|
||||
printf("字符串长度: %ld\n", str->length);
|
||||
|
||||
printf("LT_String cut测试 start=0,end=11,step=1\n");
|
||||
LT_String *str2 = lt_string_cut(str, 0, 11, 1);
|
||||
printf("字符串内容: %s\n", str2->data);
|
||||
printf("字符串长度: %ld\n", str2->length);
|
||||
str2->close(str2);
|
||||
|
||||
printf("LT_String cut测试-反转cut start=0,end=11,step=-1\n");
|
||||
LT_String *str3 = lt_string_cut(str, 0, 11, -1);
|
||||
printf("字符串内容: %s\n", str3->data);
|
||||
printf("字符串长度: %ld\n", str3->length);
|
||||
str3->close(str3);
|
||||
|
||||
printf("LT_String 测试反转\n");
|
||||
LT_String *str4 = lt_string_reverse(str);
|
||||
printf("字符串内容: %s\n", str4->data);
|
||||
printf("字符串长度: %ld\n", str4->length);
|
||||
str4->close(str4);
|
||||
|
||||
str->close(str);
|
||||
return 0;
|
||||
}
|
||||
11
tests/io/CMakeLists.txt
Normal file
11
tests/io/CMakeLists.txt
Normal file
@@ -0,0 +1,11 @@
|
||||
project(test-io)
|
||||
|
||||
|
||||
add_executable(${PROJECT_NAME}-file test-lt-file.c)
|
||||
target_link_libraries(${PROJECT_NAME}-file latch)
|
||||
|
||||
if(UNIX)
|
||||
add_test(${PROJECT_NAME}-file ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-file)
|
||||
elseif(WIN32)
|
||||
add_test(${PROJECT_NAME}-file ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-file.exe)
|
||||
endif()
|
||||
16
tests/io/test-lt-file.c
Normal file
16
tests/io/test-lt-file.c
Normal file
@@ -0,0 +1,16 @@
|
||||
#include "latch/io/lt-file.h"
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
LT_File* f = lt_file_open("test.txt", "w");
|
||||
printf("LT_File size: %ld\n", sizeof(LT_File));
|
||||
printf("File: %p\n", f);
|
||||
printf("File name: %s\n", f->name->data);
|
||||
printf("File path: %s\n", f->path->data);
|
||||
printf("File size: %ld\n", f->size);
|
||||
printf("file create time %ld\n", f->create_time);
|
||||
printf("file modify time %ld\n", f->modify_time);
|
||||
|
||||
f->close(f);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user