Skip to content

Commit a2e256c

Browse files
add new test for the new sanity checks
1 parent 9702d8c commit a2e256c

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

code/tests/cases/test_sanity.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,34 @@ FOSSIL_TEST(c_sanity_sys_file_exists) {
8787
remove(filename);
8888
} // end case
8989

90+
FOSSIL_TEST(c_sanity_sys_create_dir) {
91+
const char *dirname = "test_dir";
92+
int result = FOSSIL_SANITY_SYS_CREATE_DIR(dirname);
9093

94+
// Test cases
95+
ASSUME_ITS_EQUAL_I32(result, 0); // Directory creation should succeed
96+
ASSUME_ITS_EQUAL_I32(FOSSIL_SANITY_SYS_DIR_EXISTS(dirname), 1); // Directory should exist
97+
98+
// Cleanup
99+
rmdir(dirname);
100+
} // end case
101+
102+
FOSSIL_TEST(c_sanity_sys_dir_exists) {
103+
const char *dirname = "test_dir_exists";
104+
105+
// Ensure directory does not exist initially
106+
ASSUME_ITS_EQUAL_I32(FOSSIL_SANITY_SYS_DIR_EXISTS(dirname), 0);
107+
108+
// Create the directory
109+
int result = FOSSIL_SANITY_SYS_CREATE_DIR(dirname);
110+
ASSUME_ITS_EQUAL_I32(result, 0);
111+
112+
// Test cases
113+
ASSUME_ITS_EQUAL_I32(FOSSIL_SANITY_SYS_DIR_EXISTS(dirname), 1);
114+
115+
// Cleanup
116+
rmdir(dirname);
117+
} // end case
91118

92119
// * * * * * * * * * * * * * * * * * * * * * * * *
93120
// * Fossil Logic Test Pool
@@ -97,6 +124,8 @@ FOSSIL_TEST_GROUP(c_sanity_test_cases) {
97124
FOSSIL_TEST_ADD(c_sanity_suite, c_sanity_sys_getpid);
98125
FOSSIL_TEST_ADD(c_sanity_suite, c_sanity_sys_create_file);
99126
FOSSIL_TEST_ADD(c_sanity_suite, c_sanity_sys_file_exists);
127+
FOSSIL_TEST_ADD(c_sanity_suite, c_sanity_sys_create_dir);
128+
FOSSIL_TEST_ADD(c_sanity_suite, c_sanity_sys_dir_exists);
100129

101130
FOSSIL_TEST_REGISTER(c_sanity_suite);
102131
} // end of group

code/tests/cases/test_sanity.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,34 @@ FOSSIL_TEST(cpp_sanity_sys_file_exists) {
8787
remove(filename);
8888
} // end case
8989

90+
FOSSIL_TEST(cpp_sanity_sys_create_dir) {
91+
const char *dirname = "test_dir";
92+
int result = FOSSIL_SANITY_SYS_CREATE_DIR(dirname);
9093

94+
// Test cases
95+
ASSUME_ITS_EQUAL_I32(result, 0); // Directory creation should succeed
96+
ASSUME_ITS_EQUAL_I32(FOSSIL_SANITY_SYS_DIR_EXISTS(dirname), 1); // Directory should exist
97+
98+
// Cleanup
99+
rmdir(dirname);
100+
} // end case
101+
102+
FOSSIL_TEST(cpp_sanity_sys_dir_exists) {
103+
const char *dirname = "test_dir_exists";
104+
105+
// Ensure directory does not exist initially
106+
ASSUME_ITS_EQUAL_I32(FOSSIL_SANITY_SYS_DIR_EXISTS(dirname), 0);
107+
108+
// Create the directory
109+
int result = FOSSIL_SANITY_SYS_CREATE_DIR(dirname);
110+
ASSUME_ITS_EQUAL_I32(result, 0);
111+
112+
// Test cases
113+
ASSUME_ITS_EQUAL_I32(FOSSIL_SANITY_SYS_DIR_EXISTS(dirname), 1);
114+
115+
// Cleanup
116+
rmdir(dirname);
117+
} // end case
91118

92119
// * * * * * * * * * * * * * * * * * * * * * * * *
93120
// * Fossil Logic Test Pool
@@ -97,6 +124,8 @@ FOSSIL_TEST_GROUP(cpp_sanity_test_cases) {
97124
FOSSIL_TEST_ADD(cpp_sanity_suite, cpp_sanity_sys_getpid);
98125
FOSSIL_TEST_ADD(cpp_sanity_suite, cpp_sanity_sys_create_file);
99126
FOSSIL_TEST_ADD(cpp_sanity_suite, cpp_sanity_sys_file_exists);
127+
FOSSIL_TEST_ADD(cpp_sanity_suite, cpp_sanity_sys_create_dir);
128+
FOSSIL_TEST_ADD(cpp_sanity_suite, cpp_sanity_sys_dir_exists);
100129

101130
FOSSIL_TEST_REGISTER(cpp_sanity_suite);
102131
} // end of group

0 commit comments

Comments
 (0)