xref: /haiku/src/tests/add-ons/kernel/debugger/DemangleTest.cpp (revision 68ea01249e1e2088933cb12f9c28d4e5c5d1c9ef)
1 /*
2  * Copyright 2018, Haiku, Inc. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 
6 
7 #include "DemangleTest.h"
8 
9 #include <cppunit/TestCaller.h>
10 #include <cppunit/TestSuite.h>
11 
12 #include "Demangler.h"
13 
14 
15 DemangleTest::DemangleTest()
16 {
17 }
18 
19 
20 DemangleTest::~DemangleTest()
21 {
22 }
23 
24 
25 #define TEST(expect, input) \
26 	NextSubTest(); \
27 	CPPUNIT_ASSERT_EQUAL(BString(expect), Demangler::Demangle(input))
28 void
29 DemangleTest::RunGCC2Tests()
30 {
31 	// Long and complex things
32 	TEST("BPrivate::IconCache::SyncDraw(BPrivate::Model*, BView*, BPoint, BPrivate::IconDrawMode, icon_size, void*, void*)",
33 		"SyncDraw__Q28BPrivate9IconCachePQ28BPrivate5ModelP5BViewG6BPointQ28BPrivate12IconDrawMode9icon_sizePFP5BViewG6BPointP7BBitmapPv_vPv");
34 	TEST("BPrivate::BContainerWindow::UpdateMenu(BMenu*, BPrivate::BContainerWindow::UpdateMenuContext)",
35 		"UpdateMenu__Q28BPrivate16BContainerWindowP5BMenuQ38BPrivate16BContainerWindow17UpdateMenuContext");
36 	TEST("icu_57::BreakIterator::registerInstance(icu_57::BreakIterator*, icu_57::Locale&, UBreakIteratorType, UErrorCode&)",
37 		"registerInstance__Q26icu_5713BreakIteratorPQ26icu_5713BreakIteratorRCQ26icu_576Locale18UBreakIteratorTypeR10UErrorCode");
38 
39 	// Previously caused crashes
40 	TEST("SetTo__Q282_GLOBAL_", "_GLOBAL_::SetTo()");
41 }
42 
43 
44 void
45 DemangleTest::RunGCC3PTests()
46 {
47 	// Long and complex things
48 	TEST("BPrivate::IconCache::SyncDraw(BPrivate::Model*, BView*, BPoint, BPrivate::IconDrawMode, icon_size, void (*)(BView*, BPoint, BBitmap*, void*), void*)",
49 		"_ZN8BPrivate9IconCache8SyncDrawEPNS_5ModelEP5BView6BPointNS_12IconDrawModeE9icon_sizePFvS4_S5_P7BBitmapPvESA_");
50 	TEST("BPrivate::BContainerWindow::UpdateMenu(BMenu*, BPrivate::BContainerWindow::UpdateMenuContext)",
51 		"_ZN8BPrivate16BContainerWindow10UpdateMenuEP5BMenuNS0_17UpdateMenuContextE");
52 	TEST("icu_57::BreakIterator::registerInstance(icu_57::BreakIterator*, icu_57::Locale const&, UBreakIteratorType, UErrorCode&)",
53 		"_ZN6icu_5713BreakIterator16registerInstanceEPS0_RKNS_6LocaleE18UBreakIteratorTypeR10UErrorCode");
54 }
55 #undef TEST
56 
57 
58 /* static */ void
59 DemangleTest::AddTests(BTestSuite& parent)
60 {
61 	CppUnit::TestSuite& suite = *new CppUnit::TestSuite("DemangleTest");
62 
63 	suite.addTest(new CppUnit::TestCaller<DemangleTest>(
64 		"DemangleTest::RunGCC2Tests", &DemangleTest::RunGCC2Tests));
65 	suite.addTest(new CppUnit::TestCaller<DemangleTest>(
66 		"DemangleTest::RunGCC3+Tests", &DemangleTest::RunGCC3PTests));
67 
68 	parent.addTest("DemangleTest", &suite);
69 }
70