test_sprite.c 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /**
  2. * This is a test for sprite in $package$
  3. */
  4. #include "si_test.h"
  5. #include "eruta.h"
  6. #include "sprite.h"
  7. TEST_FUNC(sprite) {
  8. #ifdef COMMENT
  9. SpriteList * list;
  10. Sprite * sprite;
  11. SpriteAction * act;
  12. SpriteFrame * frame;
  13. SpriteLayer * layer;
  14. Point offset = bevec(1.0, 2.0);
  15. sprite = sprite_new(1);
  16. list = spritelist_new();
  17. TEST_NOTNULL(list);
  18. TEST_NOTNULL(spritelist_getornew(list, 123));
  19. TEST_NOTNULL(sprite);
  20. TEST_NULL(sprite_action(sprite, 0));
  21. TEST_NULL(sprite_action(sprite, 1));
  22. TEST_NULL(sprite_frame(sprite, 1, 2));
  23. TEST_NULL(sprite_layer(sprite, 1, 2, 3));
  24. act = sprite_newaction(sprite, 0, SPRITE_NORTH, SPRITE_ACTIVE);
  25. TEST_NOTNULL(act);
  26. TEST_PTREQ(act, sprite_action(sprite, 0));
  27. act = sprite_newaction(sprite, 0, SPRITE_NORTH,SPRITE_ACTIVE);
  28. TEST_NOTNULL(act);
  29. TEST_PTREQ(act, sprite_action(sprite, 0));
  30. frame = sprite_newframe(sprite, 0, 1, SPRITE_ACTIVE, 0.25);
  31. TEST_NOTNULL(frame);
  32. TEST_PTREQ(frame, sprite_frame(sprite, 0, 1));
  33. layer = sprite_newlayer(sprite, 0, 1, 2, NULL, offset);
  34. TEST_NOTNULL(layer);
  35. TEST_PTREQ(layer, sprite_layer(sprite, 0, 1, 2));
  36. /* Check if out of bounds new works and doesn't leak. */
  37. act = sprite_newaction(sprite, 100, SPRITE_NORTH, SPRITE_ACTIVE);
  38. TEST_NULL(act);
  39. layer = sprite_newlayer(sprite, 0, 1, 22, NULL, offset);
  40. TEST_NULL(layer);
  41. TEST_PTREQ(layer, sprite_layer(sprite, 0, 1, 22));
  42. frame = sprite_newframe(sprite, 0, 111, SPRITE_ACTIVE, 0.25);
  43. TEST_NULL(frame);
  44. layer = sprite_newlayer(sprite, 0, 1, 222, NULL, offset);
  45. TEST_NULL(layer);
  46. TEST_NOTNULL(sprite_maxactions_(sprite, 77));
  47. TEST_INTEQ(77, sprite_maxactions(sprite));
  48. act = sprite_newaction(sprite, 60, SPRITE_NORTH, SPRITE_ACTIVE);
  49. TEST_NOTNULL(sprite_action(sprite, 60));
  50. TEST_NOTNULL(sprite_maxactions_(sprite, 1));
  51. TEST_NULL(sprite_action(sprite, 60));
  52. TEST_INTEQ(1, sprite_maxactions(sprite));
  53. TEST_NOTNULL(sprite_action(sprite, 0));
  54. act = sprite_action(sprite, 0);
  55. if (act) {
  56. TEST_NOTNULL(spriteaction_maxframes_(act, 3));
  57. }
  58. spritelist_free(list);
  59. sprite_free(sprite);
  60. #endif
  61. TEST_DONE();
  62. }
  63. int main(void) {
  64. TEST_INIT();
  65. TEST_RUN(sprite);
  66. TEST_REPORT();
  67. }