|
| 1 | +#include "scratch/sprite.h" |
| 2 | +#include "testspriteinterface.h" |
| 3 | +#include "../common.h" |
| 4 | + |
| 5 | +#define INIT_SPRITE() sprite.setInterface(&spriteInterface); |
| 6 | + |
| 7 | +using namespace libscratchcpp; |
| 8 | + |
| 9 | +Sprite sprite; |
| 10 | +TestSpriteInterface spriteInterface; |
| 11 | + |
| 12 | +TEST(IScratchSpriteTest, Visible) |
| 13 | +{ |
| 14 | + INIT_SPRITE(); |
| 15 | + sprite.setVisible(false); |
| 16 | + ASSERT_EQ(spriteInterface.visible, false); |
| 17 | + sprite.setVisible(true); |
| 18 | + ASSERT_EQ(spriteInterface.visible, true); |
| 19 | +} |
| 20 | + |
| 21 | +TEST(IScratchSpriteTest, X) |
| 22 | +{ |
| 23 | + INIT_SPRITE(); |
| 24 | + sprite.setX(300); |
| 25 | + ASSERT_EQ(spriteInterface.x, 300); |
| 26 | + sprite.setX(5.25); |
| 27 | + ASSERT_EQ(spriteInterface.x, 5.25); |
| 28 | +} |
| 29 | + |
| 30 | +TEST(IScratchSpriteTest, Y) |
| 31 | +{ |
| 32 | + INIT_SPRITE(); |
| 33 | + sprite.setY(300); |
| 34 | + ASSERT_EQ(spriteInterface.y, 300); |
| 35 | + sprite.setY(5.25); |
| 36 | + ASSERT_EQ(spriteInterface.y, 5.25); |
| 37 | +} |
| 38 | + |
| 39 | +TEST(IScratchSpriteTest, Size) |
| 40 | +{ |
| 41 | + INIT_SPRITE(); |
| 42 | + sprite.setSize(50); |
| 43 | + ASSERT_EQ(spriteInterface.size, 50); |
| 44 | + sprite.setSize(75.5); |
| 45 | + ASSERT_EQ(spriteInterface.size, 75.5); |
| 46 | +} |
| 47 | + |
| 48 | +TEST(IScratchSpriteTest, Direction) |
| 49 | +{ |
| 50 | + INIT_SPRITE(); |
| 51 | + sprite.setDirection(85); |
| 52 | + ASSERT_EQ(spriteInterface.direction, 85); |
| 53 | + sprite.setDirection(179.715); |
| 54 | + ASSERT_EQ(spriteInterface.direction, 179.715); |
| 55 | +} |
| 56 | + |
| 57 | +TEST(IScratchSpriteTest, RotationStyle) |
| 58 | +{ |
| 59 | + INIT_SPRITE(); |
| 60 | + sprite.setRotationStyle(Sprite::RotationStyle::DoNotRotate); |
| 61 | + ASSERT_EQ(spriteInterface.rotationStyle, Sprite::RotationStyle::DoNotRotate); |
| 62 | + sprite.setRotationStyle(Sprite::RotationStyle::LeftRight); |
| 63 | + ASSERT_EQ(spriteInterface.rotationStyle, Sprite::RotationStyle::LeftRight); |
| 64 | +} |
| 65 | + |
| 66 | +TEST(IScratchSpriteTest, CostumeData) |
| 67 | +{ |
| 68 | + INIT_SPRITE(); |
| 69 | + // TODO: Add tests for costume data |
| 70 | +} |
0 commit comments