diff options
Diffstat (limited to 'test')
| -rwxr-xr-x | test/CMakeLists.txt | 13 | ||||
| -rw-r--r-- | test/src/testalgo.c | 2 | ||||
| -rw-r--r-- | test/src/testfile.c | 8 | ||||
| -rw-r--r-- | test/src/testhashmap.c | 2 |
4 files changed, 16 insertions, 9 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index a95e1bc..19d1cae 100755 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -2,9 +2,6 @@ set(CMAKE_C_STANDARD 90) set(CMAKE_C_STANDARD_REQUIRED ON) set(CMAKE_C_EXTENSIONS OFF) -# Enable warnings and pedantics -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -pedantic") - # Enable testing include(CTest) enable_testing() @@ -13,10 +10,20 @@ enable_testing() file(GLOB TEST_FILES "src/*.c") foreach(TEST_FILENAME ${TEST_FILES}) + # Add test get_filename_component(TEST_NAME ${TEST_FILENAME} NAME_WE) add_executable("${TEST_NAME}" ${TEST_FILENAME}) target_link_libraries("${TEST_NAME}" bhlib bhunit) add_test(NAME "${TEST_NAME}" COMMAND "${TEST_NAME}") + + # Enable all compiler warnings + if(MSVC) + target_compile_options("${TEST_NAME}" PRIVATE /W4 /WX) + else() + target_compile_options("${TEST_NAME}" PRIVATE -Wall -Wextra -Wpedantic -Werror -fstrict-aliasing) + endif() + + # Enable coverage if(COVERAGE) target_compile_options("${TEST_NAME}" PRIVATE -coverage) target_link_options("${TEST_NAME}" PRIVATE -coverage) diff --git a/test/src/testalgo.c b/test/src/testalgo.c index be762f4..1eb8460 100644 --- a/test/src/testalgo.c +++ b/test/src/testalgo.c @@ -480,4 +480,4 @@ int main(int argc, char **argv) bh_unit_add("heap_replace", check_heap_replace); return bh_unit_run(); -}
\ No newline at end of file +} diff --git a/test/src/testfile.c b/test/src/testfile.c index 0f006a4..3cf0581 100644 --- a/test/src/testfile.c +++ b/test/src/testfile.c @@ -121,7 +121,7 @@ static int check_normal(void) BH_VERIFY(bh_io_read(io, buffer, 5, &actual) == BH_OK); BH_VERIFY(actual == 5); BH_VERIFY(memcmp(buffer, "67890", 5) == 0); - bh_io_close(io); + bh_io_free(io); /* Check operations for read and write access */ BH_VERIFY((io = bh_file_new(FILENAME1)) != NULL); @@ -226,7 +226,7 @@ static int check_truncate(void) BH_VERIFY(bh_io_seek(io, 0, BH_IO_SEEK_SET) == BH_OK); BH_VERIFY(bh_io_read(io, buffer, sizeof(buffer), &actual) == BH_OK); BH_VERIFY(actual == 0); - bh_io_close(io); + bh_io_free(io); /* Check operations for read and write access */ BH_VERIFY((io = bh_file_new(FILENAME1)) != NULL); @@ -321,7 +321,7 @@ static int check_exist(void) BH_VERIFY(bh_io_read(io, buffer, 5, &actual) == BH_OK); BH_VERIFY(actual == 5); BH_VERIFY(memcmp(buffer, "67890", 5) == 0); - bh_io_close(io); + bh_io_free(io); /* Check operations for read and write access */ BH_VERIFY((io = bh_file_new(FILENAME1)) != NULL); @@ -627,4 +627,4 @@ int main(int argc, bh_unit_add("size", check_size); return bh_unit_run(); -}
\ No newline at end of file +} diff --git a/test/src/testhashmap.c b/test/src/testhashmap.c index 9728977..b166e5a 100644 --- a/test/src/testhashmap.c +++ b/test/src/testhashmap.c @@ -157,7 +157,7 @@ static int lookup(void) BH_VERIFY(bh_hashmap_at(hashmap, BH_INT2PTR(i * 4), NULL) == BH_OK); BH_VERIFY(bh_hashmap_at(hashmap, BH_INT2PTR(i * 4), &value) == BH_OK); - BH_VERIFY(BH_PTR2INT(value) == i); + BH_VERIFY(BH_PTR2INT(value) == (int)i); } /* Lookup non-existing elements */ |
