move symbol database tests to testsymboldatabase.cpp

This commit is contained in:
Robert Reif 2011-04-28 21:03:57 -04:00
parent e8eb20c6ef
commit bd03768415
2 changed files with 233 additions and 234 deletions

View File

@ -191,24 +191,6 @@ private:
TEST_CASE(constIfCfg); // ticket #1881 - fp when there are #if
TEST_CASE(constFriend); // ticket #1921 - fp for friend function
TEST_CASE(constUnion); // ticket #2111 - fp when there are union
TEST_CASE(symboldatabase1);
TEST_CASE(symboldatabase2);
TEST_CASE(symboldatabase3); // ticket #2000
TEST_CASE(symboldatabase4);
TEST_CASE(symboldatabase5); // ticket #2178
TEST_CASE(symboldatabase6); // ticket #2221
TEST_CASE(symboldatabase7); // ticket #2230
TEST_CASE(symboldatabase8); // ticket #2252
TEST_CASE(symboldatabase9); // ticket #2525
TEST_CASE(symboldatabase10); // ticket #2537
TEST_CASE(symboldatabase11); // ticket #2539
TEST_CASE(symboldatabase12); // ticket #2547
TEST_CASE(symboldatabase13); // ticket #2577
TEST_CASE(symboldatabase14); // ticket #2589
TEST_CASE(symboldatabase15); // ticket #2591
TEST_CASE(symboldatabase16); // ticket #2637
TEST_CASE(symboldatabase17); // ticket #2657
}
// Check the operator Equal
@ -6171,221 +6153,6 @@ private:
ASSERT_EQUALS("", errout.str());
}
void symboldatabase1()
{
checkConst("namespace foo {\n"
" class bar;\n"
"};");
ASSERT_EQUALS("", errout.str());
checkConst("class foo : public bar < int, int> {\n"
"};");
ASSERT_EQUALS("", errout.str());
}
void symboldatabase2()
{
checkConst("class foo {\n"
"public slots :\n"
"foo() { }\n"
"};");
ASSERT_EQUALS("", errout.str());
checkConst("class foo {\n"
"class bar;\n"
"foo() { }\n"
"};");
ASSERT_EQUALS("", errout.str());
}
void symboldatabase3()
{
checkConst("typedef void (func_type)();\n"
"struct A {\n"
" friend func_type f : 2;\n"
"};\n");
ASSERT_EQUALS("", errout.str());
}
void symboldatabase4()
{
checkConst("static void function_declaration_before(void) __attribute__((__used__));\n"
"static void function_declaration_before(void) {}\n"
"static void function_declaration_after(void) {}\n"
"static void function_declaration_after(void) __attribute__((__used__));\n");
ASSERT_EQUALS("", errout.str());
checkConst("main(int argc, char *argv[]) { }\n");
ASSERT_EQUALS("", errout.str());
checkConst("namespace boost {\n"
" std::locale generate_locale()\n"
" {\n"
" return std::locale();\n"
" }\n"
"}\n");
ASSERT_EQUALS("", errout.str());
checkConst("namespace X {\n"
" static void function_declaration_before(void) __attribute__((__used__));\n"
" static void function_declaration_before(void) {}\n"
" static void function_declaration_after(void) {}\n"
" static void function_declaration_after(void) __attribute__((__used__));\n"
"}\n");
ASSERT_EQUALS("", errout.str());
checkConst("testing::testing()\n"
"{\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
void symboldatabase5()
{
// ticket #2178 - segmentation fault
checkConst("int CL_INLINE_DECL(integer_decode_float) (int x) {\n"
" return (sign ? cl_I() : 0);\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
void symboldatabase6()
{
// ticket #2221 - segmentation fault
checkConst("template<int i> class X { };\n"
"X< 1>2 > x1;\n"
"X<(1>2)> x2;\n"
"template<class T> class Y { };\n"
"Y<X<1>> x3;\n"
"Y<X<6>>1>> x4;\n"
"Y<X<(6>>1)>> x5;\n");
ASSERT_EQUALS("", errout.str());
}
void symboldatabase7()
{
// ticket #2230 - segmentation fault
checkConst("template<template<class> class E,class D> class C : E<D>\n"
"{\n"
"public:\n"
" int f();\n"
"};\n"
"class E : C<D,int>\n"
"{\n"
"public:\n"
" int f() { return C< ::D,int>::f(); }\n"
"};\n");
ASSERT_EQUALS("", errout.str());
}
void symboldatabase8()
{
// ticket #2252 - segmentation fault
checkConst("struct PaletteColorSpaceHolder: public rtl::StaticWithInit<uno::Reference<rendering::XColorSpace>,\n"
" PaletteColorSpaceHolder>\n"
"{\n"
" uno::Reference<rendering::XColorSpace> operator()()\n"
" {\n"
" return vcl::unotools::createStandardColorSpace();\n"
" }\n"
"};\n");
ASSERT_EQUALS("", errout.str());
}
void symboldatabase9()
{
// ticket #2425 - segmentation fault
checkConst("class CHyperlink : public CString\n"
"{\n"
"public:\n"
" const CHyperlink& operator=(LPCTSTR lpsz) {\n"
" CString::operator=(lpsz);\n"
" return *this;\n"
" }\n"
"};\n");
ASSERT_EQUALS("", errout.str());
}
void symboldatabase10()
{
// ticket #2537 - segmentation fault
checkConst("class A {\n"
"private:\n"
" void f();\n"
"};\n"
"class B {\n"
" friend void A::f();\n"
"};\n");
ASSERT_EQUALS("", errout.str());
}
void symboldatabase11()
{
// ticket #2539 - segmentation fault
checkConst("int g ();\n"
"struct S {\n"
" int i : (false ? g () : 1);\n"
"};\n");
ASSERT_EQUALS("", errout.str());
}
void symboldatabase12()
{
// ticket #2547 - segmentation fault
checkConst("class foo {\n"
" void bar2 () = __null;\n"
"};\n");
ASSERT_EQUALS("", errout.str());
}
void symboldatabase13()
{
// ticket #2577 - segmentation fault
checkConst("class foo {\n"
" void bar2 () = A::f;\n"
"};\n");
ASSERT_EQUALS("", errout.str());
}
void symboldatabase14()
{
// ticket #2589 - segmentation fault
checkConst("struct B : A\n");
ASSERT_EQUALS("", errout.str());
}
void symboldatabase15()
{
// ticket #2591 - segmentation fault
checkConst("struct A :\n");
ASSERT_EQUALS("", errout.str());
}
void symboldatabase16()
{
// ticket #2637 - segmentation fault
checkConst("{} const const\n");
ASSERT_EQUALS("", errout.str());
}
void symboldatabase17()
{
// ticket #2657 - segmentation fault
checkConst("return f(){}\n");
ASSERT_EQUALS("", errout.str());
}
};
REGISTER_TEST(TestClass)

View File

@ -102,6 +102,24 @@ private:
TEST_CASE(hasGlobalVariables3);
TEST_CASE(functionArgs1);
TEST_CASE(symboldatabase1);
TEST_CASE(symboldatabase2);
TEST_CASE(symboldatabase3); // ticket #2000
TEST_CASE(symboldatabase4);
TEST_CASE(symboldatabase5); // ticket #2178
TEST_CASE(symboldatabase6); // ticket #2221
TEST_CASE(symboldatabase7); // ticket #2230
TEST_CASE(symboldatabase8); // ticket #2252
TEST_CASE(symboldatabase9); // ticket #2525
TEST_CASE(symboldatabase10); // ticket #2537
TEST_CASE(symboldatabase11); // ticket #2539
TEST_CASE(symboldatabase12); // ticket #2547
TEST_CASE(symboldatabase13); // ticket #2577
TEST_CASE(symboldatabase14); // ticket #2589
TEST_CASE(symboldatabase15); // ticket #2591
TEST_CASE(symboldatabase16); // ticket #2637
TEST_CASE(symboldatabase17); // ticket #2657
}
void test_isVariableDeclarationCanHandleNull()
@ -637,6 +655,220 @@ private:
ASSERT_EQUALS("", errout.str());
}
void symboldatabase1()
{
check("namespace foo {\n"
" class bar;\n"
"};");
ASSERT_EQUALS("", errout.str());
check("class foo : public bar < int, int> {\n"
"};");
ASSERT_EQUALS("", errout.str());
}
void symboldatabase2()
{
check("class foo {\n"
"public slots :\n"
"foo() { }\n"
"};");
ASSERT_EQUALS("", errout.str());
check("class foo {\n"
"class bar;\n"
"foo() { }\n"
"};");
ASSERT_EQUALS("", errout.str());
}
void symboldatabase3()
{
check("typedef void (func_type)();\n"
"struct A {\n"
" friend func_type f : 2;\n"
"};\n");
ASSERT_EQUALS("", errout.str());
}
void symboldatabase4()
{
check("static void function_declaration_before(void) __attribute__((__used__));\n"
"static void function_declaration_before(void) {}\n"
"static void function_declaration_after(void) {}\n"
"static void function_declaration_after(void) __attribute__((__used__));\n");
ASSERT_EQUALS("", errout.str());
check("main(int argc, char *argv[]) { }\n");
ASSERT_EQUALS("", errout.str());
check("namespace boost {\n"
" std::locale generate_locale()\n"
" {\n"
" return std::locale();\n"
" }\n"
"}\n");
ASSERT_EQUALS("", errout.str());
check("namespace X {\n"
" static void function_declaration_before(void) __attribute__((__used__));\n"
" static void function_declaration_before(void) {}\n"
" static void function_declaration_after(void) {}\n"
" static void function_declaration_after(void) __attribute__((__used__));\n"
"}\n");
ASSERT_EQUALS("", errout.str());
check("testing::testing()\n"
"{\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
void symboldatabase5()
{
// ticket #2178 - segmentation fault
check("int CL_INLINE_DECL(integer_decode_float) (int x) {\n"
" return (sign ? cl_I() : 0);\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
void symboldatabase6()
{
// ticket #2221 - segmentation fault
check("template<int i> class X { };\n"
"X< 1>2 > x1;\n"
"X<(1>2)> x2;\n"
"template<class T> class Y { };\n"
"Y<X<1>> x3;\n"
"Y<X<6>>1>> x4;\n"
"Y<X<(6>>1)>> x5;\n");
ASSERT_EQUALS("", errout.str());
}
void symboldatabase7()
{
// ticket #2230 - segmentation fault
check("template<template<class> class E,class D> class C : E<D>\n"
"{\n"
"public:\n"
" int f();\n"
"};\n"
"class E : C<D,int>\n"
"{\n"
"public:\n"
" int f() { return C< ::D,int>::f(); }\n"
"};\n");
ASSERT_EQUALS("", errout.str());
}
void symboldatabase8()
{
// ticket #2252 - segmentation fault
check("struct PaletteColorSpaceHolder: public rtl::StaticWithInit<uno::Reference<rendering::XColorSpace>,\n"
" PaletteColorSpaceHolder>\n"
"{\n"
" uno::Reference<rendering::XColorSpace> operator()()\n"
" {\n"
" return vcl::unotools::createStandardColorSpace();\n"
" }\n"
"};\n");
ASSERT_EQUALS("", errout.str());
}
void symboldatabase9()
{
// ticket #2425 - segmentation fault
check("class CHyperlink : public CString\n"
"{\n"
"public:\n"
" const CHyperlink& operator=(LPCTSTR lpsz) {\n"
" CString::operator=(lpsz);\n"
" return *this;\n"
" }\n"
"};\n");
ASSERT_EQUALS("", errout.str());
}
void symboldatabase10()
{
// ticket #2537 - segmentation fault
check("class A {\n"
"private:\n"
" void f();\n"
"};\n"
"class B {\n"
" friend void A::f();\n"
"};\n");
ASSERT_EQUALS("", errout.str());
}
void symboldatabase11()
{
// ticket #2539 - segmentation fault
check("int g ();\n"
"struct S {\n"
" int i : (false ? g () : 1);\n"
"};\n");
ASSERT_EQUALS("", errout.str());
}
void symboldatabase12()
{
// ticket #2547 - segmentation fault
check("class foo {\n"
" void bar2 () = __null;\n"
"};\n");
ASSERT_EQUALS("", errout.str());
}
void symboldatabase13()
{
// ticket #2577 - segmentation fault
check("class foo {\n"
" void bar2 () = A::f;\n"
"};\n");
ASSERT_EQUALS("", errout.str());
}
void symboldatabase14()
{
// ticket #2589 - segmentation fault
check("struct B : A\n");
ASSERT_EQUALS("", errout.str());
}
void symboldatabase15()
{
// ticket #2591 - segmentation fault
check("struct A :\n");
ASSERT_EQUALS("", errout.str());
}
void symboldatabase16()
{
// ticket #2637 - segmentation fault
check("{} const const\n");
ASSERT_EQUALS("", errout.str());
}
void symboldatabase17()
{
// ticket #2657 - segmentation fault
check("return f(){}\n");
ASSERT_EQUALS("", errout.str());
}
};
REGISTER_TEST(TestSymbolDatabase)