diff options
author | Maximilian Heinzler <m.heinzler@heinzler.de> | 2018-11-20 20:03:19 (GMT) |
---|---|---|
committer | Maximilian Heinzler <m.heinzler@heinzler.de> | 2018-11-20 20:07:03 (GMT) |
commit | 6962a41e6b83e1ead36ab26b06ebe81aeee0087a (patch) | |
tree | 41b7ae116e6e9b9bf562660628ed7457ffd1ab92 /Tests/FindGIF/Test/main.c | |
parent | 5bc64fe6c25f3c02dda7d22eb65c07bdf2e6eb46 (diff) | |
download | CMake-6962a41e6b83e1ead36ab26b06ebe81aeee0087a.zip CMake-6962a41e6b83e1ead36ab26b06ebe81aeee0087a.tar.gz CMake-6962a41e6b83e1ead36ab26b06ebe81aeee0087a.tar.bz2 |
FindGIF: Add test
This tests whether GIFLIB can be found and the linker works. For newer
versions (>=5) it also tests if the version was parsed correctly.
Diffstat (limited to 'Tests/FindGIF/Test/main.c')
-rw-r--r-- | Tests/FindGIF/Test/main.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/Tests/FindGIF/Test/main.c b/Tests/FindGIF/Test/main.c new file mode 100644 index 0000000..4ed72ec --- /dev/null +++ b/Tests/FindGIF/Test/main.c @@ -0,0 +1,35 @@ +#include <assert.h> +#include <stdio.h> +#include <string.h> + +#include <gif_lib.h> + +// GIFLIB before version 5 didn't know this macro +#ifndef GIFLIB_MAJOR +# define GIFLIB_MAJOR 4 +#endif + +int main() +{ + // because of the API changes we have to test different functions depending + // on the version of GIFLIB +#if GIFLIB_MAJOR >= 5 + // test the linker + GifErrorString(D_GIF_SUCCEEDED); + + // check the version + char gif_version_string[16]; + snprintf(gif_version_string, 16, "%i.%i.%i", GIFLIB_MAJOR, GIFLIB_MINOR, + GIFLIB_RELEASE); + + assert(strcmp(gif_version_string, CMAKE_EXPECTED_GIF_VERSION) == 0); +#else + // test the linker + GifLastError(); + + // unfortunately there is no way to check the version in older version of + // GIFLIB +#endif + + return 0; +} |