Open Source Tomb Raider Engine
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

mtk_tga.cpp 1.2KB

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