aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2012-03-26 02:26:40 +0200
committerAlexander Sulfrian <alexander@sulfrian.net>2013-01-13 22:40:52 +0100
commita5e90892da7de8f10dae70b75f1fb51587eaf8db (patch)
tree42f9f092375e65a3b0228aed87865d9bedded2de
parent9bd2b5f28805c9a5d0df28f6323b4c895e3fd9f4 (diff)
downloadusdx-a5e90892da7de8f10dae70b75f1fb51587eaf8db.tar.gz
usdx-a5e90892da7de8f10dae70b75f1fb51587eaf8db.tar.xz
usdx-a5e90892da7de8f10dae70b75f1fb51587eaf8db.zip
tests: changed CPPUNIT_ASSERT to CPPUNIT_ASSERT_EQUAL for better error msgs
-rw-r--r--test/base/ringbuffer.cpp58
-rw-r--r--test/base/songloading.cpp40
-rw-r--r--test/utils/image.cpp16
-rw-r--r--test/utils/point.cpp40
-rw-r--r--test/utils/rectangle.cpp24
5 files changed, 89 insertions, 89 deletions
diff --git a/test/base/ringbuffer.cpp b/test/base/ringbuffer.cpp
index 99631108..73c85d65 100644
--- a/test/base/ringbuffer.cpp
+++ b/test/base/ringbuffer.cpp
@@ -63,7 +63,7 @@ namespace usdx
// negative value when the given buffer is NULL
void testReadNullBuffer()
{
- CPPUNIT_ASSERT( -1 == rbuff->read(NULL,10) );
+ CPPUNIT_ASSERT_EQUAL(-1, rbuff->read(NULL,10));
}
// check if the read function reports an error in form of a
@@ -71,21 +71,21 @@ namespace usdx
void testReadNegativeCount()
{
char buffer[10];
- CPPUNIT_ASSERT( -1 == rbuff->read(buffer,-1) );
+ CPPUNIT_ASSERT_EQUAL(-1, rbuff->read(buffer,-1));
}
// check the returnvalue when reading on a empty ringbuffer
void testReadEmptyRingBuffer()
{
char buffer[10];
- CPPUNIT_ASSERT( 0 == rbuff->read(buffer,10) );
+ CPPUNIT_ASSERT_EQUAL(0, rbuff->read(buffer,10));
}
// check in the read function reports an error in form of a
// negative value when the given buffer is NULL
void testWriteNullBuffer()
{
- CPPUNIT_ASSERT( -1 == rbuff->write(NULL,10) );
+ CPPUNIT_ASSERT_EQUAL(-1, rbuff->write(NULL,10));
}
// check if the read function reports an error in form of a
@@ -93,7 +93,7 @@ namespace usdx
void testWriteNegativeCount()
{
char buffer[10];
- CPPUNIT_ASSERT( -1 == rbuff->write(buffer,-1) );
+ CPPUNIT_ASSERT_EQUAL(-1, rbuff->write(buffer,-1));
}
// checks the retrunvalue when writeing over the limits of a
@@ -101,7 +101,7 @@ namespace usdx
void testWriteOverflow()
{
char buffer[20];
- CPPUNIT_ASSERT( 0 == rbuff->read(buffer,20) );
+ CPPUNIT_ASSERT_EQUAL(0, rbuff->read(buffer,20));
}
// check if the read value is ajusted correctly, when
@@ -111,12 +111,12 @@ namespace usdx
char w1Buffer[4]="AAA";
char w2Buffer[4]="BBB";
char rBuffer[7]="CCCCCC";
- CPPUNIT_ASSERT( 3 == rbuff->write(w1Buffer,3) );
- CPPUNIT_ASSERT( 3 == rbuff->write(w1Buffer,3) );
- CPPUNIT_ASSERT( 3 == rbuff->write(w1Buffer,3) );
- CPPUNIT_ASSERT( 4 == rbuff->write(w2Buffer,4) );
- CPPUNIT_ASSERT( 6 == rbuff->read(rBuffer,6) );
- CPPUNIT_ASSERT( 0 == strcmp("AAAAAA",rBuffer) );
+ CPPUNIT_ASSERT_EQUAL(3, rbuff->write(w1Buffer,3));
+ CPPUNIT_ASSERT_EQUAL(3, rbuff->write(w1Buffer,3));
+ CPPUNIT_ASSERT_EQUAL(3, rbuff->write(w1Buffer,3));
+ CPPUNIT_ASSERT_EQUAL(4, rbuff->write(w2Buffer,4));
+ CPPUNIT_ASSERT_EQUAL(6, rbuff->read(rBuffer,6));
+ CPPUNIT_ASSERT_EQUAL(0, strcmp("AAAAAA",rBuffer));
}
// check if inputdata equals outputdata
@@ -125,10 +125,10 @@ namespace usdx
char w1Buffer[4]="AAA";
char w2Buffer[4]="BBB";
char rBuffer[7]="CCCCCC";
- CPPUNIT_ASSERT( 3 == rbuff->write(w1Buffer,3) );
- CPPUNIT_ASSERT( 4 == rbuff->write(w2Buffer,4) );
- CPPUNIT_ASSERT( 7 == rbuff->read(rBuffer,7) );
- CPPUNIT_ASSERT( 0 == strcmp("AAABBB",rBuffer) );
+ CPPUNIT_ASSERT_EQUAL(3, rbuff->write(w1Buffer,3));
+ CPPUNIT_ASSERT_EQUAL(4, rbuff->write(w2Buffer,4));
+ CPPUNIT_ASSERT_EQUAL(7, rbuff->read(rBuffer,7));
+ CPPUNIT_ASSERT_EQUAL(0, strcmp("AAABBB",rBuffer));
}
// check what happens when read trys to read more data than
@@ -137,9 +137,9 @@ namespace usdx
{
char wBuffer[4]="AAA";
char rBuffer[5]="BBBB";
- CPPUNIT_ASSERT( 4 == rbuff->write(wBuffer,4) );
- CPPUNIT_ASSERT( 4 == rbuff->read(rBuffer,5) );
- CPPUNIT_ASSERT( 0 == strcmp("AAA",rBuffer) );
+ CPPUNIT_ASSERT_EQUAL(4, rbuff->write(wBuffer,4));
+ CPPUNIT_ASSERT_EQUAL(4, rbuff->read(rBuffer,5));
+ CPPUNIT_ASSERT_EQUAL(0, strcmp("AAA",rBuffer));
}
// check if the correct ringbuffer size is reported
@@ -147,9 +147,9 @@ namespace usdx
{
char w1Buffer[4]="AAA";
char w2Buffer[5]="BBBB";
- CPPUNIT_ASSERT( 4 == rbuff->write(w1Buffer,4) );
- CPPUNIT_ASSERT( 5 == rbuff->write(w2Buffer,5) );
- CPPUNIT_ASSERT( 10 == rbuff->get_size() );
+ CPPUNIT_ASSERT_EQUAL(4, rbuff->write(w1Buffer,4));
+ CPPUNIT_ASSERT_EQUAL(5, rbuff->write(w2Buffer,5));
+ CPPUNIT_ASSERT_EQUAL(10, rbuff->get_size());
}
// check if the available space in the ringbuffer
@@ -157,9 +157,9 @@ namespace usdx
{
char w1Buffer[4]="AAA";
char w2Buffer[5]="BBBB";
- CPPUNIT_ASSERT( 4 == rbuff->write(w1Buffer,4) );
- CPPUNIT_ASSERT( 5 == rbuff->write(w2Buffer,5) );
- CPPUNIT_ASSERT( 9 == rbuff->get_available() );
+ CPPUNIT_ASSERT_EQUAL(4, rbuff->write(w1Buffer,4));
+ CPPUNIT_ASSERT_EQUAL(5, rbuff->write(w2Buffer,5));
+ CPPUNIT_ASSERT_EQUAL(9, rbuff->get_available());
}
// check if the flush function clears the buffer correctly
@@ -168,11 +168,11 @@ namespace usdx
char w1Buffer[4]="AAA";
char w2Buffer[4]="BBB";
char rBuffer[4]="CCC";
- CPPUNIT_ASSERT( 4 == rbuff->write(w1Buffer,4) );
+ CPPUNIT_ASSERT_EQUAL(4, rbuff->write(w1Buffer,4));
rbuff->flush();
- CPPUNIT_ASSERT( 4 == rbuff->write(w2Buffer,4) );
- CPPUNIT_ASSERT( 4 == rbuff->read(rBuffer,4) );
- CPPUNIT_ASSERT( 0 == strcmp("BBB",rBuffer) );
+ CPPUNIT_ASSERT_EQUAL(4, rbuff->write(w2Buffer,4));
+ CPPUNIT_ASSERT_EQUAL(4, rbuff->read(rBuffer,4));
+ CPPUNIT_ASSERT_EQUAL(0, strcmp("BBB",rBuffer));
}
};
diff --git a/test/base/songloading.cpp b/test/base/songloading.cpp
index 03824669..614fb22d 100644
--- a/test/base/songloading.cpp
+++ b/test/base/songloading.cpp
@@ -62,28 +62,28 @@ namespace usdx
{
Song *song = Songloader::get_instance()->load_header("testdata/testsong_correct.txt");
- CPPUNIT_ASSERT( "Test Ärtist" == song->get_artist() );
+ CPPUNIT_ASSERT_EQUAL(std::string("Test Ärtist"), song->get_artist());
// FIXIT: unicode length is not counted correctly
- // CPPUNIT_ASSERT( 11 == song->get_artist().length() );
- CPPUNIT_ASSERT( "Test Title" == song->get_title() );
- CPPUNIT_ASSERT( "Test.mp3" == song->get_mp3() );
- CPPUNIT_ASSERT( 42.23f == song->get_bpm(0) );
- CPPUNIT_ASSERT( 42.23f == song->get_bpm(10) );
- CPPUNIT_ASSERT( 10 == song->get_gap() );
- CPPUNIT_ASSERT( "Test[BG].jpg" == song->get_background() );
- CPPUNIT_ASSERT( "Test[CO].jpg" == song->get_cover_file() );
- CPPUNIT_ASSERT( "Test Genre" == song->get_genre() );
- CPPUNIT_ASSERT( false == song->get_relative() );
- CPPUNIT_ASSERT( "Cpp" == song->get_language() );
- CPPUNIT_ASSERT( "Test[VD#12,3].mkv" == song->get_video() );
- CPPUNIT_ASSERT( 12.3f == song->get_video_gap() );
- CPPUNIT_ASSERT( 0 == song->get_start() );
- CPPUNIT_ASSERT( "Test0r" == song->get_creator() );
- CPPUNIT_ASSERT( 7 == song->get_year() );
- CPPUNIT_ASSERT( 666 == song->get_stop() );
- CPPUNIT_ASSERT( 0 == song->get_notes_gap() );
+ // CPPUNIT_ASSERT_EQUAL(11, song->get_artist().length());
+ CPPUNIT_ASSERT_EQUAL(std::string("Test Title"), song->get_title());
+ CPPUNIT_ASSERT_EQUAL(std::string("Test.mp3"), song->get_mp3());
+ CPPUNIT_ASSERT_EQUAL(42.23f, song->get_bpm(0));
+ CPPUNIT_ASSERT_EQUAL(42.23f, song->get_bpm(10));
+ CPPUNIT_ASSERT_EQUAL(10.0f, song->get_gap());
+ CPPUNIT_ASSERT_EQUAL(std::string("Test[BG].jpg"), song->get_background());
+ CPPUNIT_ASSERT_EQUAL(std::string("Test[CO].jpg"), song->get_cover_file());
+ CPPUNIT_ASSERT_EQUAL(std::string("Test Genre"), song->get_genre());
+ CPPUNIT_ASSERT_EQUAL(false, song->get_relative());
+ CPPUNIT_ASSERT_EQUAL(std::string("Cpp"), song->get_language());
+ CPPUNIT_ASSERT_EQUAL(std::string("Test[VD#12,3].mkv"), song->get_video());
+ CPPUNIT_ASSERT_EQUAL(12.3f, song->get_video_gap());
+ CPPUNIT_ASSERT_EQUAL(0.0f, song->get_start());
+ CPPUNIT_ASSERT_EQUAL(std::string("Test0r"), song->get_creator());
+ CPPUNIT_ASSERT_EQUAL(7, song->get_year());
+ CPPUNIT_ASSERT_EQUAL(666, song->get_stop());
+ CPPUNIT_ASSERT_EQUAL(0, song->get_notes_gap());
// TODO
- //CPPUNIT_ASSERT( UTF-8 == song->get_encodeing() );
+ //CPPUNIT_ASSERT_EQUAL(UTF-8, song->get_encodeing());
delete song;
}
diff --git a/test/utils/image.cpp b/test/utils/image.cpp
index c5f3bb48..f94e9afe 100644
--- a/test/utils/image.cpp
+++ b/test/utils/image.cpp
@@ -59,8 +59,8 @@ namespace usdx
const SDL_Surface *surface = img.get_surface();
log << log4cpp::Priority::INFO << "test.bmp: " <<
"w = " << surface->w << "; h = " << surface->h;
- CPPUNIT_ASSERT(40 == surface->w);
- CPPUNIT_ASSERT(30 == surface->h);
+ CPPUNIT_ASSERT_EQUAL(40, surface->w);
+ CPPUNIT_ASSERT_EQUAL(30, surface->h);
}
void testJpg()
@@ -69,8 +69,8 @@ namespace usdx
const SDL_Surface *surface = img.get_surface();
log << log4cpp::Priority::INFO << "test.jpg: " <<
"w = " << surface->w << "; h = " << surface->h;
- CPPUNIT_ASSERT(40 == surface->w);
- CPPUNIT_ASSERT(30 == surface->h);
+ CPPUNIT_ASSERT_EQUAL(40, surface->w);
+ CPPUNIT_ASSERT_EQUAL(30, surface->h);
}
void testPng()
@@ -79,8 +79,8 @@ namespace usdx
const SDL_Surface *surface = img.get_surface();
log << log4cpp::Priority::INFO << "test.png: " <<
"w = " << surface->w << "; h = " << surface->h;
- CPPUNIT_ASSERT(40 == surface->w);
- CPPUNIT_ASSERT(30 == surface->h);
+ CPPUNIT_ASSERT_EQUAL(40, surface->w);
+ CPPUNIT_ASSERT_EQUAL(30, surface->h);
}
void testGif()
@@ -89,8 +89,8 @@ namespace usdx
const SDL_Surface *surface = img.get_surface();
log << log4cpp::Priority::INFO << "test.gif: " <<
"w = " << surface->w << "; h = " << surface->h;
- CPPUNIT_ASSERT(40 == surface->w);
- CPPUNIT_ASSERT(30 == surface->h);
+ CPPUNIT_ASSERT_EQUAL(40, surface->w);
+ CPPUNIT_ASSERT_EQUAL(30, surface->h);
}
void testNotAnImage()
diff --git a/test/utils/point.cpp b/test/utils/point.cpp
index 64fa2216..6284ea2c 100644
--- a/test/utils/point.cpp
+++ b/test/utils/point.cpp
@@ -55,12 +55,12 @@ namespace usdx
Point<int> p1(100, 200), p2(50, 70);
Point<int> p3 = p1 + p2;
- CPPUNIT_ASSERT(p1.get_x() == 100);
- CPPUNIT_ASSERT(p1.get_y() == 200);
- CPPUNIT_ASSERT(p2.get_x() == 50);
- CPPUNIT_ASSERT(p2.get_y() == 70);
- CPPUNIT_ASSERT(p3.get_x() == 150);
- CPPUNIT_ASSERT(p3.get_y() == 270);
+ CPPUNIT_ASSERT_EQUAL(p1.get_x(), 100);
+ CPPUNIT_ASSERT_EQUAL(p1.get_y(), 200);
+ CPPUNIT_ASSERT_EQUAL(p2.get_x(), 50);
+ CPPUNIT_ASSERT_EQUAL(p2.get_y(), 70);
+ CPPUNIT_ASSERT_EQUAL(p3.get_x(), 150);
+ CPPUNIT_ASSERT_EQUAL(p3.get_y(), 270);
}
void testDiff()
@@ -68,12 +68,12 @@ namespace usdx
Point<int> p1(100, 200), p2(50, 70);
Point<int> p3 = p1 - p2;
- CPPUNIT_ASSERT(p1.get_x() == 100);
- CPPUNIT_ASSERT(p1.get_y() == 200);
- CPPUNIT_ASSERT(p2.get_x() == 50);
- CPPUNIT_ASSERT(p2.get_y() == 70);
- CPPUNIT_ASSERT(p3.get_x() == 50);
- CPPUNIT_ASSERT(p3.get_y() == 130);
+ CPPUNIT_ASSERT_EQUAL(p1.get_x(), 100);
+ CPPUNIT_ASSERT_EQUAL(p1.get_y(), 200);
+ CPPUNIT_ASSERT_EQUAL(p2.get_x(), 50);
+ CPPUNIT_ASSERT_EQUAL(p2.get_y(), 70);
+ CPPUNIT_ASSERT_EQUAL(p3.get_x(), 50);
+ CPPUNIT_ASSERT_EQUAL(p3.get_y(), 130);
}
void testCompoundSum()
@@ -81,10 +81,10 @@ namespace usdx
Point<int> p1(100, 200), p2(50, 70);
p1 += p2;
- CPPUNIT_ASSERT(p1.get_x() == 150);
- CPPUNIT_ASSERT(p1.get_y() == 270);
- CPPUNIT_ASSERT(p2.get_x() == 50);
- CPPUNIT_ASSERT(p2.get_y() == 70);
+ CPPUNIT_ASSERT_EQUAL(p1.get_x(), 150);
+ CPPUNIT_ASSERT_EQUAL(p1.get_y(), 270);
+ CPPUNIT_ASSERT_EQUAL(p2.get_x(), 50);
+ CPPUNIT_ASSERT_EQUAL(p2.get_y(), 70);
}
void testCompoundDiff()
@@ -92,10 +92,10 @@ namespace usdx
Point<int> p1(100, 200), p2(50, 70);
p1 -= p2;
- CPPUNIT_ASSERT(p1.get_x() == 50);
- CPPUNIT_ASSERT(p1.get_y() == 130);
- CPPUNIT_ASSERT(p2.get_x() == 50);
- CPPUNIT_ASSERT(p2.get_y() == 70);
+ CPPUNIT_ASSERT_EQUAL(p1.get_x(), 50);
+ CPPUNIT_ASSERT_EQUAL(p1.get_y(), 130);
+ CPPUNIT_ASSERT_EQUAL(p2.get_x(), 50);
+ CPPUNIT_ASSERT_EQUAL(p2.get_y(), 70);
}
};
diff --git a/test/utils/rectangle.cpp b/test/utils/rectangle.cpp
index 343d442f..faee50f9 100644
--- a/test/utils/rectangle.cpp
+++ b/test/utils/rectangle.cpp
@@ -54,10 +54,10 @@ namespace usdx
int coords[] = { 100, 150, 200, 250 };
Rectangle<int> rect(coords);
- CPPUNIT_ASSERT(rect.get_left() == 100);
- CPPUNIT_ASSERT(rect.get_top() == 150);
- CPPUNIT_ASSERT(rect.get_width() == 200);
- CPPUNIT_ASSERT(rect.get_height() == 250);
+ CPPUNIT_ASSERT_EQUAL(rect.get_left(), 100);
+ CPPUNIT_ASSERT_EQUAL(rect.get_top(), 150);
+ CPPUNIT_ASSERT_EQUAL(rect.get_width(), 200);
+ CPPUNIT_ASSERT_EQUAL(rect.get_height(), 250);
}
void testIntersectInner()
@@ -66,10 +66,10 @@ namespace usdx
Rectangle<int> inner(120, 170, 180, 200);
Rectangle<int> intersect = outer.intersect(inner);
- CPPUNIT_ASSERT(intersect.get_point1().get_x() == 120);
- CPPUNIT_ASSERT(intersect.get_point1().get_y() == 170);
- CPPUNIT_ASSERT(intersect.get_point2().get_x() == 180);
- CPPUNIT_ASSERT(intersect.get_point2().get_y() == 200);
+ CPPUNIT_ASSERT_EQUAL(intersect.get_point1().get_x(), 120);
+ CPPUNIT_ASSERT_EQUAL(intersect.get_point1().get_y(), 170);
+ CPPUNIT_ASSERT_EQUAL(intersect.get_point2().get_x(), 180);
+ CPPUNIT_ASSERT_EQUAL(intersect.get_point2().get_y(), 200);
}
void testIntersectOuter()
@@ -78,10 +78,10 @@ namespace usdx
Rectangle<int> inner(100, 150, 200, 250);
Rectangle<int> intersect = outer.intersect(inner);
- CPPUNIT_ASSERT(intersect.get_point1().get_x() == 120);
- CPPUNIT_ASSERT(intersect.get_point1().get_y() == 170);
- CPPUNIT_ASSERT(intersect.get_point2().get_x() == 180);
- CPPUNIT_ASSERT(intersect.get_point2().get_y() == 200);
+ CPPUNIT_ASSERT_EQUAL(intersect.get_point1().get_x(), 120);
+ CPPUNIT_ASSERT_EQUAL(intersect.get_point1().get_y(), 170);
+ CPPUNIT_ASSERT_EQUAL(intersect.get_point2().get_x(), 180);
+ CPPUNIT_ASSERT_EQUAL(intersect.get_point2().get_y(), 200);
}
};