Convert AreaTest to cppunit.
This commit is contained in:
@@ -1,8 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2014 Haiku, Inc.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "AreaTest.h"
|
||||||
|
|
||||||
#include <OS.h>
|
#include <OS.h>
|
||||||
#include <stdio.h>
|
|
||||||
|
#include <cppunit/TestCaller.h>
|
||||||
|
#include <cppunit/TestSuite.h>
|
||||||
|
|
||||||
|
|
||||||
int main()
|
AreaTest::AreaTest()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
AreaTest::~AreaTest()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
AreaTest::TestAreas()
|
||||||
{
|
{
|
||||||
int * ptr = new int[1];
|
int * ptr = new int[1];
|
||||||
char *adr;
|
char *adr;
|
||||||
@@ -31,22 +52,34 @@ int main()
|
|||||||
ptrclone1 = (int *)(adrclone1 + offset);
|
ptrclone1 = (int *)(adrclone1 + offset);
|
||||||
ptrclone2 = (int *)(adrclone2 + offset);
|
ptrclone2 = (int *)(adrclone2 + offset);
|
||||||
|
|
||||||
printf("offset = 0x%08x\n", (int)offset);
|
// Check that he pointer is inside the area returned by area_for...
|
||||||
printf("id = 0x%08x\n", (int)id);
|
CPPUNIT_ASSERT(offset >= 0);
|
||||||
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);
|
|
||||||
|
|
||||||
|
// 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;
|
ptr[0] = 0x12345678;
|
||||||
|
CPPUNIT_ASSERT(ptr[0] == ptrclone1[0]);
|
||||||
printf("ptr[0] = 0x%08x\n", (int)ptr[0]);
|
CPPUNIT_ASSERT(ptrclone2[0] == ptrclone1[0]);
|
||||||
printf("ptr clone 1[0] = 0x%08x\n", (int)ptrclone1[0]);
|
CPPUNIT_ASSERT_EQUAL(0x12345678, ptrclone2[0]);
|
||||||
printf("ptr clone 2[0] = 0x%08x\n", (int)ptrclone2[0]);
|
}
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
/*static*/ void
|
||||||
|
AreaTest::AddTests(BTestSuite& parent)
|
||||||
|
{
|
||||||
|
CppUnit::TestSuite& suite = *new CppUnit::TestSuite("AreaTest");
|
||||||
|
|
||||||
|
suite.addTest(new CppUnit::TestCaller<AreaTest>(
|
||||||
|
"AreaTest::TestAreas", &AreaTest::TestAreas));
|
||||||
|
|
||||||
|
parent.addTest("AreaTest", &suite);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 <TestCase.h>
|
||||||
|
#include <TestSuite.h>
|
||||||
|
|
||||||
|
|
||||||
|
class AreaTest: public BTestCase {
|
||||||
|
public:
|
||||||
|
AreaTest();
|
||||||
|
virtual ~AreaTest();
|
||||||
|
|
||||||
|
void TestAreas();
|
||||||
|
|
||||||
|
static void AddTests(BTestSuite& suite);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
SubDir HAIKU_TOP src tests kits media ;
|
SubDir HAIKU_TOP src tests kits media ;
|
||||||
|
|
||||||
SimpleTest AreaTest : AreaTest.cpp : be [ TargetLibsupc++ ] ;
|
|
||||||
|
|
||||||
SimpleTest BufferTest : BufferTest.cpp : libmedia.so be [ TargetLibsupc++ ] ;
|
SimpleTest BufferTest : BufferTest.cpp : libmedia.so be [ TargetLibsupc++ ] ;
|
||||||
|
|
||||||
SimpleTest SizeofTest : SizeofTest.cpp : be ;
|
SimpleTest SizeofTest : SizeofTest.cpp : be ;
|
||||||
@@ -17,6 +15,14 @@ SimpleTest mediaDescriptions :
|
|||||||
mediaDescriptions.cpp
|
mediaDescriptions.cpp
|
||||||
: media ;
|
: 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 media_decoder ;
|
||||||
SubInclude HAIKU_TOP src tests kits media mpeg2_decoder_test ;
|
SubInclude HAIKU_TOP src tests kits media mpeg2_decoder_test ;
|
||||||
SubInclude HAIKU_TOP src tests kits media mp3_decoder_test ;
|
SubInclude HAIKU_TOP src tests kits media mp3_decoder_test ;
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2014 Haiku, Inc.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <TestSuite.h>
|
||||||
|
#include <TestSuiteAddon.h>
|
||||||
|
|
||||||
|
#include "AreaTest.h"
|
||||||
|
|
||||||
|
|
||||||
|
BTestSuite*
|
||||||
|
getTestSuite()
|
||||||
|
{
|
||||||
|
BTestSuite* suite = new BTestSuite("MediaKit");
|
||||||
|
|
||||||
|
AreaTest::AddTests(*suite);
|
||||||
|
|
||||||
|
return suite;
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user