Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/scratchcpp/costume.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class CostumePrivate;
class LIBSCRATCHCPP_EXPORT Costume : public Asset
{
public:
Costume(std::string name, std::string id, std::string format);
Costume(const std::string &name, const std::string &id, const std::string &format);

double bitmapResolution() const;
void setBitmapResolution(double newBitmapResolution);
Expand Down
2 changes: 1 addition & 1 deletion src/scratch/costume.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using namespace libscratchcpp;

/*! Constructs Costume. */
Costume::Costume(std::string name, std::string id, std::string format) :
Costume::Costume(const std::string &name, const std::string &id, const std::string &format) :
Asset(name, id, format),
impl(spimpl::make_impl<CostumePrivate>())
{
Expand Down
15 changes: 15 additions & 0 deletions test/assets/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# asset_test
add_executable(
asset_test
asset_test.cpp
Expand All @@ -10,3 +11,17 @@ target_link_libraries(
)

gtest_discover_tests(asset_test)

# costume_test
add_executable(
costume_test
costume_test.cpp
)

target_link_libraries(
costume_test
GTest::gtest_main
scratchcpp
)

gtest_discover_tests(costume_test)
41 changes: 41 additions & 0 deletions test/assets/costume_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#include <scratchcpp/costume.h>

#include "../common.h"

using namespace libscratchcpp;

TEST(CostumeTest, Constructors)
{
Costume costume("costume1", "a", "svg");
ASSERT_EQ(costume.assetId(), "a");
ASSERT_EQ(costume.name(), "costume1");
ASSERT_EQ(costume.dataFormat(), "svg");
ASSERT_EQ(costume.md5ext(), "a.svg");
ASSERT_EQ(costume.bitmapResolution(), 1);
ASSERT_EQ(costume.rotationCenterX(), 0);
ASSERT_EQ(costume.rotationCenterY(), 0);
}

TEST(CostumeTest, BitmapResolution)
{
Costume costume("costume1", "a", "svg");

costume.setBitmapResolution(5.52);
ASSERT_EQ(costume.bitmapResolution(), 5.52);
}

TEST(CostumeTest, RotationCenterX)
{
Costume costume("costume1", "a", "svg");

costume.setRotationCenterX(240);
ASSERT_EQ(costume.rotationCenterX(), 240);
}

TEST(CostumeTest, RotationCenterY)
{
Costume costume("costume1", "a", "svg");

costume.setRotationCenterY(180);
ASSERT_EQ(costume.rotationCenterY(), 180);
}