Open Source Tomb Raider Engine
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

tga.cpp 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*!
  2. * \file test/tga.cpp
  3. * \brief The TGA reader Unit Test
  4. *
  5. * \author xythobuz
  6. */
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. #include <tga.h>
  10. #include "greatest.h"
  11. //! \todo generate list?
  12. const char *testFiles[] = {
  13. "data/particle.tga",
  14. "data/snow.tga",
  15. "data/snow2.tga",
  16. "data/splash.tga",
  17. "data/white.tga"
  18. };
  19. TEST checkFile(FILE *f) {
  20. ASSERTm("File wasn't opened.", f != NULL);
  21. ASSERT_FALSEm("File is invalid?!", mtk_image__tga_check(f));
  22. PASS();
  23. }
  24. TEST loadFile(FILE *f) {
  25. unsigned char *image;
  26. unsigned int width, height;
  27. char type;
  28. ASSERTm("File wasn't opened.", f != NULL);
  29. ASSERT_FALSEm("File couldn't be loaded!", mtk_image__tga_load(f, &image, &width, &height, &type));
  30. printf("\nWidth: %u\nHeight: %u\nType: %d\n", width, height, type);
  31. PASS();
  32. }
  33. SUITE(tgaSuite) {
  34. for (unsigned int i = 0; i < (sizeof(testFiles) / sizeof(testFiles[0])); i++) {
  35. FILE *f = fopen(testFiles[i], "r");
  36. RUN_TESTp(checkFile, f);
  37. RUN_TESTp(loadFile, f);
  38. fclose(f);
  39. }
  40. }
  41. GREATEST_MAIN_DEFS();
  42. int main(int argc, char *argv[]) {
  43. GREATEST_MAIN_BEGIN();
  44. RUN_SUITE(tgaSuite);
  45. GREATEST_MAIN_END();
  46. }