Skip to content

Commit e60e8c1

Browse files
authored
Merge pull request #159 from scratchcpp/asset_test
Add Asset test
2 parents 978a945 + fa84a32 commit e60e8c1

File tree

5 files changed

+29
-2
lines changed

5 files changed

+29
-2
lines changed

include/scratchcpp/asset.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class AssetPrivate;
1616
class LIBSCRATCHCPP_EXPORT Asset
1717
{
1818
public:
19-
Asset(std::string name, std::string id, std::string format);
19+
Asset(const std::string &name, const std::string &id, const std::string &format);
2020

2121
const std::string &assetId() const;
2222

src/scratch/asset.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
using namespace libscratchcpp;
88

99
/*! Constructs Asset. */
10-
Asset::Asset(std::string name, std::string id, std::string format) :
10+
Asset::Asset(const std::string &name, const std::string &id, const std::string &format) :
1111
impl(spimpl::make_impl<AssetPrivate>(name, id, format))
1212
{
1313
}

test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ add_subdirectory(scratch_classes)
2424
add_subdirectory(target_interfaces)
2525
add_subdirectory(blocks)
2626
add_subdirectory(scratchconfiguration)
27+
add_subdirectory(assets)

test/assets/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
add_executable(
2+
asset_test
3+
asset_test.cpp
4+
)
5+
6+
target_link_libraries(
7+
asset_test
8+
GTest::gtest_main
9+
scratchcpp
10+
)
11+
12+
gtest_discover_tests(asset_test)

test/assets/asset_test.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include <scratchcpp/asset.h>
2+
3+
#include "../common.h"
4+
5+
using namespace libscratchcpp;
6+
7+
TEST(AssetTest, Constructors)
8+
{
9+
Asset asset("costume1", "a", "svg");
10+
ASSERT_EQ(asset.assetId(), "a");
11+
ASSERT_EQ(asset.name(), "costume1");
12+
ASSERT_EQ(asset.dataFormat(), "svg");
13+
ASSERT_EQ(asset.md5ext(), "a.svg");
14+
}

0 commit comments

Comments
 (0)