|
| 1 | +#include "scratch/blockprototype.h" |
| 2 | +#include "../common.h" |
| 3 | + |
| 4 | +using namespace libscratchcpp; |
| 5 | + |
| 6 | +TEST(BlockPrototypeTest, ProcCode) |
| 7 | +{ |
| 8 | + BlockPrototype prototype("test block"); |
| 9 | + ASSERT_EQ(prototype.procCode(), "test block"); |
| 10 | + ASSERT_TRUE(prototype.argumentTypes().empty()); |
| 11 | + ASSERT_TRUE(prototype.argumentDefaults().empty()); |
| 12 | + |
| 13 | + prototype.setProcCode("test %s block %s %b"); |
| 14 | + ASSERT_EQ(prototype.procCode(), "test %s block %s %b"); |
| 15 | + ASSERT_EQ( |
| 16 | + prototype.argumentTypes(), |
| 17 | + std::vector<BlockPrototype::ArgType>({ |
| 18 | + BlockPrototype::ArgType::StringNum, |
| 19 | + BlockPrototype::ArgType::StringNum, |
| 20 | + BlockPrototype::ArgType::Bool, |
| 21 | + })); |
| 22 | + ASSERT_EQ(prototype.argumentDefaults(), std::vector<Value>({ "", "", false })); |
| 23 | + |
| 24 | + prototype.setProcCode("%b %s test %b block %b"); |
| 25 | + ASSERT_EQ(prototype.procCode(), "%b %s test %b block %b"); |
| 26 | + ASSERT_EQ( |
| 27 | + prototype.argumentTypes(), |
| 28 | + std::vector<BlockPrototype::ArgType>({ BlockPrototype::ArgType::Bool, BlockPrototype::ArgType::StringNum, BlockPrototype::ArgType::Bool, BlockPrototype::ArgType::Bool })); |
| 29 | + ASSERT_EQ(prototype.argumentDefaults(), std::vector<Value>({ false, "", false, false })); |
| 30 | +} |
0 commit comments