1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- /*!
- * \file test/TGA.cpp
- * \brief The TGA reader Unit Test
- *
- * \author xythobuz
- */
- #include <stdio.h>
- #include <stdlib.h>
- #include <utils/tga.h>
- #include "greatest.h"
-
- //! \todo generate list?
- const char *testFiles[] = {
- "../../data/particle.tga",
- "../../data/snow.tga",
- "../../data/snow2.tga",
- "../../data/splash.tga",
- "../../data/white.tga"
- };
-
- TEST checkFile(FILE *f) {
- ASSERTm("File wasn't opened.", f != NULL);
- ASSERT_FALSEm("File is invalid?!", tga_check(f));
- PASS();
- }
-
- TEST loadFile(FILE *f) {
- unsigned char *image;
- unsigned int width, height;
- char type;
- ASSERTm("File wasn't opened.", f != NULL);
- ASSERT_FALSEm("File couldn't be loaded!", tga_load(f, &image, &width, &height, &type));
- printf("\nWidth: %u\nHeight: %u\nType: %d\n", width, height, type);
- PASS();
- }
-
- SUITE(tgaSuite) {
- for (unsigned int i = 0; i < (sizeof(testFiles) / sizeof(testFiles[0])); i++) {
- FILE *f = fopen(testFiles[i], "r");
- RUN_TESTp(checkFile, f);
- RUN_TESTp(loadFile, f);
- fclose(f);
- }
- }
-
- GREATEST_MAIN_DEFS();
-
- int main(int argc, char *argv[]) {
- GREATEST_MAIN_BEGIN();
- RUN_SUITE(tgaSuite);
- GREATEST_MAIN_END();
- }
|