Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

51 righe
1.2 KiB

  1. //
  2. // Lol Engine
  3. //
  4. // Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
  5. // This program is free software; you can redistribute it and/or
  6. // modify it under the terms of the Do What The Fuck You Want To
  7. // Public License, Version 2, as published by Sam Hocevar. See
  8. // http://sam.zoy.org/projects/COPYING.WTFPL for more details.
  9. //
  10. #if defined HAVE_CONFIG_H
  11. # include "config.h"
  12. #endif
  13. #include <cmath>
  14. #include "core.h"
  15. #include "lol/unit.h"
  16. namespace lol
  17. {
  18. LOLUNIT_FIXTURE(ImageTest)
  19. {
  20. LOLUNIT_TEST(OpenImage)
  21. {
  22. Image *image = new Image("data/gradient.png");
  23. LOLUNIT_ASSERT(image);
  24. ivec2 size = image->GetSize();
  25. LOLUNIT_ASSERT_EQUAL(size.x, 256);
  26. LOLUNIT_ASSERT_EQUAL(size.y, 16);
  27. uint8_t *data = (uint8_t *)image->GetData();
  28. LOLUNIT_ASSERT(data);
  29. LOLUNIT_ASSERT_EQUAL((int)data[0], 0x00);
  30. LOLUNIT_ASSERT_EQUAL((int)data[1], 0x00);
  31. LOLUNIT_ASSERT_EQUAL((int)data[2], 0x00);
  32. LOLUNIT_ASSERT_EQUAL((int)data[255 * 4 + 0], 0xff);
  33. LOLUNIT_ASSERT_EQUAL((int)data[255 * 4 + 1], 0xff);
  34. LOLUNIT_ASSERT_EQUAL((int)data[255 * 4 + 2], 0xff);
  35. delete image;
  36. }
  37. };
  38. } /* namespace lol */