|
| 1 | +#include <scratchcpp/input.h> |
| 2 | +#include <scratchcpp/inputvalue.h> |
| 3 | +#include <scratchcpp/block.h> |
| 4 | + |
| 5 | +#include "../common.h" |
| 6 | + |
| 7 | +using namespace libscratchcpp; |
| 8 | + |
| 9 | +TEST(InputTest, Constructors) |
| 10 | +{ |
| 11 | + Input input1("VALUE", Input::Type::Shadow); |
| 12 | + ASSERT_EQ(input1.name(), "VALUE"); |
| 13 | + ASSERT_EQ(input1.type(), Input::Type::Shadow); |
| 14 | + |
| 15 | + Input input2("custom_block", Input::Type::NoShadow); |
| 16 | + ASSERT_EQ(input2.name(), "custom_block"); |
| 17 | + ASSERT_EQ(input2.type(), Input::Type::NoShadow); |
| 18 | +} |
| 19 | + |
| 20 | +TEST(InputTest, InputId) |
| 21 | +{ |
| 22 | + Input input("", Input::Type::Shadow); |
| 23 | + ASSERT_EQ(input.inputId(), -1); |
| 24 | + |
| 25 | + input.setInputId(3); |
| 26 | + ASSERT_EQ(input.inputId(), 3); |
| 27 | +} |
| 28 | + |
| 29 | +TEST(InputTest, PrimaryValue) |
| 30 | +{ |
| 31 | + Input input("", Input::Type::Shadow); |
| 32 | + ASSERT_TRUE(input.primaryValue()); |
| 33 | + |
| 34 | + input.setPrimaryValue("test"); |
| 35 | + ASSERT_EQ(input.primaryValue()->value().toString(), "test"); |
| 36 | +} |
| 37 | + |
| 38 | +TEST(InputTest, SecondaryValue) |
| 39 | +{ |
| 40 | + Input input("", Input::Type::Shadow); |
| 41 | + ASSERT_TRUE(input.secondaryValue()); |
| 42 | + |
| 43 | + input.setSecondaryValue("test"); |
| 44 | + ASSERT_EQ(input.secondaryValue()->value().toString(), "test"); |
| 45 | +} |
| 46 | + |
| 47 | +TEST(InputTest, ValueBlock) |
| 48 | +{ |
| 49 | + Input input("", Input::Type::Shadow); |
| 50 | + ASSERT_EQ(input.valueBlock(), nullptr); |
| 51 | + ASSERT_EQ(input.valueBlockId(), ""); |
| 52 | + |
| 53 | + auto block = std::make_shared<Block>("abc", ""); |
| 54 | + input.setValueBlock(block); |
| 55 | + ASSERT_EQ(input.valueBlock(), block); |
| 56 | + ASSERT_EQ(input.valueBlockId(), "abc"); |
| 57 | + |
| 58 | + input.setValueBlockId("hello"); |
| 59 | + ASSERT_EQ(input.valueBlockId(), "hello"); |
| 60 | + ASSERT_EQ(input.valueBlock(), nullptr); |
| 61 | +} |
0 commit comments