Skip to content

Commit 5fb2c75

Browse files
authored
Merge pull request #161 from scratchcpp/sound_test
Add Sound test
2 parents 3a2ded5 + a356eef commit 5fb2c75

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

test/assets/CMakeLists.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,17 @@ target_link_libraries(
2525
)
2626

2727
gtest_discover_tests(costume_test)
28+
29+
# sound_test
30+
add_executable(
31+
sound_test
32+
sound_test.cpp
33+
)
34+
35+
target_link_libraries(
36+
sound_test
37+
GTest::gtest_main
38+
scratchcpp
39+
)
40+
41+
gtest_discover_tests(sound_test)

test/assets/sound_test.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#include <scratchcpp/sound.h>
2+
3+
#include "../common.h"
4+
5+
using namespace libscratchcpp;
6+
7+
TEST(SoundTest, Constructors)
8+
{
9+
Sound sound("sound1", "a", "svg");
10+
ASSERT_EQ(sound.assetId(), "a");
11+
ASSERT_EQ(sound.name(), "sound1");
12+
ASSERT_EQ(sound.dataFormat(), "svg");
13+
ASSERT_EQ(sound.md5ext(), "a.svg");
14+
ASSERT_EQ(sound.rate(), 0);
15+
ASSERT_EQ(sound.sampleCount(), 0);
16+
}
17+
18+
TEST(SoundTest, Rate)
19+
{
20+
Sound sound("sound1", "a", "svg");
21+
22+
sound.setRate(2);
23+
ASSERT_EQ(sound.rate(), 2);
24+
}
25+
26+
TEST(SoundTest, SampleCount)
27+
{
28+
Sound sound("sound1", "a", "svg");
29+
30+
sound.setSampleCount(10);
31+
ASSERT_EQ(sound.sampleCount(), 10);
32+
}

0 commit comments

Comments
 (0)