DrawTest.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #include "../testTools.h"
  2. START_TEST(Draw)
  3. ImageU8 imageA = image_create_U8(16, 16);
  4. uint8_t black = 0;
  5. uint8_t gray = 127;
  6. uint8_t white = 255;
  7. ImageU8 expected1 = image_fromAscii(
  8. "< .x>"
  9. "<xxxxxxxxxxxxxxxx>"
  10. "<x......xx x>"
  11. "<x......xx x>"
  12. "<x..xx..xx xx x>"
  13. "<x..xx..xx xx x>"
  14. "<x......xx x>"
  15. "<x......xx x>"
  16. "<xxxxxxxxxxxxxxxx>"
  17. "<xxxxxxxxxxxxxxxx>"
  18. "<x xx......x>"
  19. "<x xx......x>"
  20. "<x xx xx..xx..x>"
  21. "<x xx xx..xx..x>"
  22. "<x xx......x>"
  23. "<x xx......x>"
  24. "<xxxxxxxxxxxxxxxx>"
  25. );
  26. // TODO: Try drawing outside without crashing. Only drawing to a broken target image should allow crashing.
  27. // Fill the image
  28. image_fill(imageA, white);
  29. draw_rectangle(imageA, IRect(1, 1, 6, 6), gray);
  30. draw_rectangle(imageA, IRect(9, 9, 6, 6), gray);
  31. draw_rectangle(imageA, IRect(9, 1, 6, 6), black);
  32. draw_rectangle(imageA, IRect(1, 9, 6, 6), black);
  33. draw_rectangle(imageA, IRect(3, 3, 2, 2), white);
  34. draw_rectangle(imageA, IRect(3, 11, 2, 2), white);
  35. draw_rectangle(imageA, IRect(11, 3, 2, 2), white);
  36. draw_rectangle(imageA, IRect(11, 11, 2, 2), white);
  37. // TODO: Make a reusable macro for comparing images and showing them when a test fails.
  38. ASSERT_EQUAL(image_maxDifference(imageA, expected1), 0);
  39. //printText("imageA:\n", image_toAscii(imageA, " .x"), "\n");
  40. END_TEST