Skip to content

Commit 69f27f0

Browse files
committed
Add motion blocks test
1 parent 1ef8d42 commit 69f27f0

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

test/blocks/CMakeLists.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,19 @@ target_link_libraries(
109109
)
110110

111111
gtest_discover_tests(sensing_blocks_test)
112+
113+
# motion_blocks_test
114+
add_executable(
115+
motion_blocks_test
116+
motion_blocks_test.cpp
117+
)
118+
119+
target_link_libraries(
120+
motion_blocks_test
121+
GTest::gtest_main
122+
GTest::gmock_main
123+
scratchcpp
124+
scratchcpp_mocks
125+
)
126+
127+
gtest_discover_tests(motion_blocks_test)

test/blocks/motion_blocks_test.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#include <scratchcpp/compiler.h>
2+
#include <scratchcpp/block.h>
3+
#include <enginemock.h>
4+
5+
#include "../common.h"
6+
#include "blocks/motionblocks.h"
7+
#include "engine/internal/engine.h"
8+
9+
using namespace libscratchcpp;
10+
11+
using ::testing::Return;
12+
13+
class MotionBlocksTest : public testing::Test
14+
{
15+
public:
16+
void SetUp() override
17+
{
18+
m_section = std::make_unique<MotionBlocks>();
19+
m_section->registerBlocks(&m_engine);
20+
}
21+
22+
std::unique_ptr<IBlockSection> m_section;
23+
EngineMock m_engineMock;
24+
Engine m_engine;
25+
};
26+
27+
TEST_F(MotionBlocksTest, Name)
28+
{
29+
ASSERT_EQ(m_section->name(), "Motion");
30+
}
31+
32+
TEST_F(MotionBlocksTest, CategoryVisible)
33+
{
34+
ASSERT_TRUE(m_section->categoryVisible());
35+
}
36+
37+
TEST_F(MotionBlocksTest, RegisterBlocks)
38+
{
39+
m_section->registerBlocks(&m_engineMock);
40+
}

0 commit comments

Comments
 (0)