Permalink
Browse files

More tests

  • Loading branch information...
chchwy committed Jan 13, 2018
1 parent a49cb02 commit 2b98f323b8ef79ac7182b16a2ac7ffa0c91c9ce5
Showing with 50 additions and 50 deletions.
  1. +50 −50 tests/test_object.cpp
View
@@ -11,9 +11,10 @@
#include "layersound.h"
TEST_CASE("Object")
TEST_CASE("Object::addXXXLayer()")
{
Object* obj = new Object;
SECTION("Init an Object")
{
obj->init();
@@ -29,66 +30,65 @@ TEST_CASE("Object")
REQUIRE(obj->getLayer(0)->type() == Layer::BITMAP);
}
delete obj;
}
/*
SECTION("Add a vector layer")
{
REQUIRE(obj->getLayerCount() == 0);
obj->addNewVectorLayer();
REQUIRE(obj->getLayerCount() == 1);
void TestObject::testAddVectorLayer()
{
std::unique_ptr< Object > obj( new Object );
QCOMPARE( obj->getLayerCount(), 0 );
obj->addNewVectorLayer();
QCOMPARE( obj->getLayerCount(), 1 );
Layer* layer = obj->getLayer( 0 );
QCOMPARE( layer->type(), Layer::VECTOR );
}
REQUIRE(obj->getLayer(0)->type() == Layer::VECTOR);
}
void TestObject::testAddCameraLayer()
{
std::unique_ptr< Object > obj( new Object );
QCOMPARE( obj->getLayerCount(), 0 );
obj->addNewCameraLayer();
QCOMPARE( obj->getLayerCount(), 1 );
Layer* layer = obj->getLayer( 0 );
QCOMPARE( layer->type(), Layer::CAMERA );
}
SECTION("Add a camera layer")
{
REQUIRE(obj->getLayerCount() == 0);
obj->addNewCameraLayer();
REQUIRE(obj->getLayerCount() == 1);
void TestObject::testAddSoundLayer()
{
std::unique_ptr< Object > obj( new Object );
QCOMPARE( obj->getLayerCount(), 0 );
obj->addNewSoundLayer();
QCOMPARE( obj->getLayerCount(), 1 );
Layer* layer = obj->getLayer( 0 );
QCOMPARE( layer->type(), Layer::SOUND );
}
REQUIRE(obj->getLayer(0)->type() == Layer::CAMERA);
}
SECTION("Add a sound layer")
{
REQUIRE(obj->getLayerCount() == 0);
obj->addNewSoundLayer();
REQUIRE(obj->getLayerCount() == 1);
REQUIRE(obj->getLayer(0)->type() == Layer::SOUND);
}
void TestObject::testAddMoreLayers()
{
std::unique_ptr< Object > obj( new Object );
QCOMPARE( obj->getLayerCount(), 0 );
SECTION("Add 3 layers")
{
REQUIRE(obj->getLayerCount() == 0);
obj->addNewSoundLayer();
QCOMPARE( obj->getLayerCount(), 1 );
QCOMPARE( obj->getLayer( 0 )->type(), Layer::SOUND );
obj->addNewSoundLayer();
REQUIRE(obj->getLayerCount() == 1);
REQUIRE(obj->getLayer(0)->type() == Layer::SOUND);
obj->addNewCameraLayer();
QCOMPARE( obj->getLayerCount(), 2 );
QCOMPARE( obj->getLayer( 1 )->type(), Layer::CAMERA );
obj->addNewCameraLayer();
REQUIRE(obj->getLayerCount() == 2);
REQUIRE(obj->getLayer(1)->type() == Layer::CAMERA);
obj->addNewBitmapLayer();
QCOMPARE( obj->getLayerCount(), 3 );
QCOMPARE( obj->getLayer( 2 )->type(), Layer::BITMAP );
obj->addNewBitmapLayer();
REQUIRE(obj->getLayerCount() == 3);
REQUIRE(obj->getLayer(2)->type() == Layer::BITMAP);
}
SECTION("Add 500 layers")
{
REQUIRE(obj->getLayerCount() == 0);
for (int i = 0; i < 500; ++i)
{
obj->addNewBitmapLayer();
}
REQUIRE(obj->getLayerCount() == 500);
}
delete obj;
}
/*
void TestObject::testLayerID()
{
std::unique_ptr< Object > obj( new Object );

0 comments on commit 2b98f32

Please sign in to comment.