diff options
author | Roger Leigh <rleigh@codelibre.net> | 2016-09-08 20:28:17 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-09-09 15:42:35 (GMT) |
commit | 069cac584f3fccfad54b4fcce8d7e8584a009c51 (patch) | |
tree | 2db7d8e3c5058df2afac8c6fc2367d55a8c21bff /Tests/FindBZip2 | |
parent | e9ce050342c34b92e0eaa281a4e454c9b78a41d9 (diff) | |
download | CMake-069cac584f3fccfad54b4fcce8d7e8584a009c51.zip CMake-069cac584f3fccfad54b4fcce8d7e8584a009c51.tar.gz CMake-069cac584f3fccfad54b4fcce8d7e8584a009c51.tar.bz2 |
Tests: Add FindBZip2 unit tests
Diffstat (limited to 'Tests/FindBZip2')
-rw-r--r-- | Tests/FindBZip2/CMakeLists.txt | 10 | ||||
-rw-r--r-- | Tests/FindBZip2/Test/CMakeLists.txt | 16 | ||||
-rw-r--r-- | Tests/FindBZip2/Test/main.c | 23 |
3 files changed, 49 insertions, 0 deletions
diff --git a/Tests/FindBZip2/CMakeLists.txt b/Tests/FindBZip2/CMakeLists.txt new file mode 100644 index 0000000..0eb3b99 --- /dev/null +++ b/Tests/FindBZip2/CMakeLists.txt @@ -0,0 +1,10 @@ +add_test(NAME FindBZip2.Test COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindBZip2/Test" + "${CMake_BINARY_DIR}/Tests/FindBZip2/Test" + ${build_generator_args} + --build-project TestFindBZip2 + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) diff --git a/Tests/FindBZip2/Test/CMakeLists.txt b/Tests/FindBZip2/Test/CMakeLists.txt new file mode 100644 index 0000000..e9cb618 --- /dev/null +++ b/Tests/FindBZip2/Test/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.4) +project(TestFindBZip2 C) +include(CTest) + +find_package(BZip2 REQUIRED) + +add_definitions(-DCMAKE_EXPECTED_BZip2_VERSION="${BZip2_VERSION_STRING}") + +add_executable(test_tgt main.c) +target_link_libraries(test_tgt BZip2::BZip2) +add_test(NAME test_tgt COMMAND test_tgt) + +add_executable(test_var main.c) +target_include_directories(test_var PRIVATE ${BZIP2_INCLUDE_DIRS}) +target_link_libraries(test_var PRIVATE ${BZIP2_LIBRARIES}) +add_test(NAME test_var COMMAND test_var) diff --git a/Tests/FindBZip2/Test/main.c b/Tests/FindBZip2/Test/main.c new file mode 100644 index 0000000..8e24c94 --- /dev/null +++ b/Tests/FindBZip2/Test/main.c @@ -0,0 +1,23 @@ +#include <bzlib.h> +#include <stdio.h> +#include <stdlib.h> + +int main() +{ + int chunksize = 1024; + FILE* file = fopen("test.bzip2", "wb"); + char* buf = malloc(sizeof(char) * chunksize); + int error, rsize; + unsigned int in, out; + BZFILE* bzfile = BZ2_bzWriteOpen(&error, file, 64, 1, 10); + + /* Don't actually write anything for the purposes of the test */ + + BZ2_bzWriteClose(&error, bzfile, 1, &in, &out); + free(buf); + fclose(file); + + remove("test.bzip2"); + + return 0; +} |