diff --git a/src/tests/kits/media/AreaTest.cpp b/src/tests/kits/media/AreaTest.cpp index 7421453a38..3cb1d9d654 100644 --- a/src/tests/kits/media/AreaTest.cpp +++ b/src/tests/kits/media/AreaTest.cpp @@ -1,8 +1,29 @@ +/* + * Copyright 2014 Haiku, Inc. + * Distributed under the terms of the MIT License. + */ + + +#include "AreaTest.h" + #include -#include + +#include +#include -int main() +AreaTest::AreaTest() +{ +} + + +AreaTest::~AreaTest() +{ +} + + +void +AreaTest::TestAreas() { int * ptr = new int[1]; char *adr; @@ -31,22 +52,34 @@ int main() ptrclone1 = (int *)(adrclone1 + offset); ptrclone2 = (int *)(adrclone2 + offset); - printf("offset = 0x%08x\n", (int)offset); - printf("id = 0x%08x\n", (int)id); - printf("id clone 1 = 0x%08x\n", (int)idclone1); - printf("id clone 2 = 0x%08x\n", (int)idclone2); - printf("adr = 0x%08x\n", (int)adr); - printf("adr clone 1 = 0x%08x\n", (int)adrclone1); - printf("adr clone 2 = 0x%08x\n", (int)adrclone2); - printf("ptr = 0x%08x\n", (int)ptr); - printf("ptr clone 1 = 0x%08x\n", (int)ptrclone1); - printf("ptr clone 2 = 0x%08x\n", (int)ptrclone2); + // Check that he pointer is inside the area returned by area_for... + CPPUNIT_ASSERT(offset >= 0); + // Chech that the clones have different IDs + CPPUNIT_ASSERT(id != idclone1); + CPPUNIT_ASSERT(id != idclone2); + CPPUNIT_ASSERT(idclone1 != idclone2); + + // Check that the clones have different addresses + CPPUNIT_ASSERT(adr != adrclone1); + CPPUNIT_ASSERT(adr != adrclone2); + CPPUNIT_ASSERT(adrclone1 != adrclone2); + + // Check that changes on one view of the area are visible in others. ptr[0] = 0x12345678; - - printf("ptr[0] = 0x%08x\n", (int)ptr[0]); - printf("ptr clone 1[0] = 0x%08x\n", (int)ptrclone1[0]); - printf("ptr clone 2[0] = 0x%08x\n", (int)ptrclone2[0]); - - return 0; + CPPUNIT_ASSERT(ptr[0] == ptrclone1[0]); + CPPUNIT_ASSERT(ptrclone2[0] == ptrclone1[0]); + CPPUNIT_ASSERT_EQUAL(0x12345678, ptrclone2[0]); +} + + +/*static*/ void +AreaTest::AddTests(BTestSuite& parent) +{ + CppUnit::TestSuite& suite = *new CppUnit::TestSuite("AreaTest"); + + suite.addTest(new CppUnit::TestCaller( + "AreaTest::TestAreas", &AreaTest::TestAreas)); + + parent.addTest("AreaTest", &suite); } diff --git a/src/tests/kits/media/AreaTest.h b/src/tests/kits/media/AreaTest.h new file mode 100644 index 0000000000..a6b5e60e0d --- /dev/null +++ b/src/tests/kits/media/AreaTest.h @@ -0,0 +1,25 @@ +/* + * Copyright 2014 Haiku, Inc. + * Distributed under the terms of the MIT License. + */ +#ifndef AREA_TEST_H +#define AREA_TEST_H + + +#include +#include + + +class AreaTest: public BTestCase { +public: + AreaTest(); + virtual ~AreaTest(); + + void TestAreas(); + + static void AddTests(BTestSuite& suite); +}; + + +#endif + diff --git a/src/tests/kits/media/Jamfile b/src/tests/kits/media/Jamfile index 0439e574ee..802c58e559 100644 --- a/src/tests/kits/media/Jamfile +++ b/src/tests/kits/media/Jamfile @@ -1,7 +1,5 @@ SubDir HAIKU_TOP src tests kits media ; -SimpleTest AreaTest : AreaTest.cpp : be [ TargetLibsupc++ ] ; - SimpleTest BufferTest : BufferTest.cpp : libmedia.so be [ TargetLibsupc++ ] ; SimpleTest SizeofTest : SizeofTest.cpp : be ; @@ -17,6 +15,14 @@ SimpleTest mediaDescriptions : mediaDescriptions.cpp : media ; +UnitTestLib libmediatest.so : + MediaKitTestAddon.cpp + + AreaTest.cpp + + : be [ TargetLibstdc++ ] [ TargetLibsupc++ ] +; + SubInclude HAIKU_TOP src tests kits media media_decoder ; SubInclude HAIKU_TOP src tests kits media mpeg2_decoder_test ; SubInclude HAIKU_TOP src tests kits media mp3_decoder_test ; diff --git a/src/tests/kits/media/MediaKitTestAddon.cpp b/src/tests/kits/media/MediaKitTestAddon.cpp new file mode 100644 index 0000000000..7d12bdc190 --- /dev/null +++ b/src/tests/kits/media/MediaKitTestAddon.cpp @@ -0,0 +1,22 @@ +/* + * Copyright 2014 Haiku, Inc. + * Distributed under the terms of the MIT License. + */ + + +#include +#include + +#include "AreaTest.h" + + +BTestSuite* +getTestSuite() +{ + BTestSuite* suite = new BTestSuite("MediaKit"); + + AreaTest::AddTests(*suite); + + return suite; +} +