tests: Add test boilerplate for our homegrown demanglers.

There's only one test each, for now, but adding tests is now of course
a one-line addition per test.
This commit is contained in:
Augustin Cavalier 2018-09-16 23:06:32 -04:00
parent 48a6df083d
commit 8339f2eb89
4 changed files with 112 additions and 4 deletions

View File

@ -0,0 +1,57 @@
/*
* Copyright 2018, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#include "DemangleTest.h"
#include <cppunit/TestCaller.h>
#include <cppunit/TestSuite.h>
#include "Demangler.h"
DemangleTest::DemangleTest()
{
}
DemangleTest::~DemangleTest()
{
}
#define TEST(expect, input) \
NextSubTest(); \
CPPUNIT_ASSERT_EQUAL(BString(expect), Demangler::Demangle(input))
void
DemangleTest::RunGCC2Tests()
{
TEST("", "()");
TEST("BPrivate::IconCache::SyncDraw(BPrivate::Model*, BView*, BPoint, BPrivate::IconDrawMode, icon_size, void*, void*)",
"SyncDraw__Q28BPrivate9IconCachePQ28BPrivate5ModelP5BViewG6BPointQ28BPrivate12IconDrawMode9icon_sizePFP5BViewG6BPointP7BBitmapPv_vPv");
}
void
DemangleTest::RunGCC3PTests()
{
TEST("BPrivate::IconCache::SyncDraw(BPrivate::Model*, BView*, BPoint, BPrivate::IconDrawMode, icon_size, void (*)(BView*, BPoint, BBitmap*, void*), void*)",
"_ZN8BPrivate9IconCache8SyncDrawEPNS_5ModelEP5BView6BPointNS_12IconDrawModeE9icon_sizePFvS4_S5_P7BBitmapPvESA_");
}
#undef TEST
/* static */ void
DemangleTest::AddTests(BTestSuite& parent)
{
CppUnit::TestSuite& suite = *new CppUnit::TestSuite("DemangleTest");
suite.addTest(new CppUnit::TestCaller<DemangleTest>(
"DemangleTest::RunGCC2Tests", &DemangleTest::RunGCC2Tests));
suite.addTest(new CppUnit::TestCaller<DemangleTest>(
"DemangleTest::RunGCC3+Tests", &DemangleTest::RunGCC3PTests));
parent.addTest("DemangleTest", &suite);
}

View File

@ -0,0 +1,25 @@
/*
* Copyright 2018, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef DEMANGLE_TEST
#define DEMANGLE_TEST
#include <TestCase.h>
#include <TestSuite.h>
class DemangleTest : public BTestCase {
public:
DemangleTest();
virtual ~DemangleTest();
void RunGCC2Tests();
void RunGCC3PTests();
static void AddTests(BTestSuite& suite);
};
#endif // DEMANGLE_TEST

View File

@ -1,9 +1,13 @@
SubDir HAIKU_TOP src tests add-ons kernel debugger ;
UsePrivateKernelHeaders ;
UsePrivateHeaders shared ;
SubDirHdrs $(HAIKU_TOP) src kits debugger demangler ;
SubDirHdrs $(HAIKU_TOP) src add-ons kernel debugger demangle ;
UnitTestLib libkerneldebuggertest.so :
KernelDebuggerTest.cpp
SimpleTest gcc2_demangle_test : gcc2_demangle_test.cpp ;
DemangleTest.cpp
: <nogrist>Debugger_demangler.o
be [ TargetLibstdc++ ] [ TargetLibsupc++ ]
;

View File

@ -0,0 +1,22 @@
/*
* Copyright 2018, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#include <TestSuite.h>
#include <TestSuiteAddon.h>
#include "DemangleTest.h"
BTestSuite*
getTestSuite()
{
BTestSuite* suite = new BTestSuite("KernelDebuggerTest");
DemangleTest::AddTests(*suite);
return suite;
}