diff options
author | August Sodora <augsod@gmail.com> | 2011-11-20 00:44:53 -0500 |
---|---|---|
committer | August Sodora <augsod@gmail.com> | 2011-11-20 00:48:17 -0500 |
commit | b97774aefa122aebf20de4208a820953c39172b1 (patch) | |
tree | f9ed171d7630a7330b090b7d243e437b955b63a2 /basic/qa | |
parent | hopefully gb_Executable_EXT_for_build does it (diff) | |
download | core-b97774aefa122aebf20de4208a820953c39172b1.tar.gz core-b97774aefa122aebf20de4208a820953c39172b1.zip |
Added regression test for scanner
Diffstat (limited to 'basic/qa')
-rw-r--r-- | basic/qa/cppunit/test_scanner.cxx | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/basic/qa/cppunit/test_scanner.cxx b/basic/qa/cppunit/test_scanner.cxx index dd46b7a48e34..95bbb479bcd8 100644 --- a/basic/qa/cppunit/test_scanner.cxx +++ b/basic/qa/cppunit/test_scanner.cxx @@ -34,6 +34,7 @@ namespace void testAlphanum(); void testComments(); void testGoto(); + void testGotoCompatible(); void testExclamation(); void testNumbers(); void testDataType(); @@ -47,6 +48,7 @@ namespace CPPUNIT_TEST(testAlphanum); CPPUNIT_TEST(testComments); CPPUNIT_TEST(testGoto); + CPPUNIT_TEST(testGotoCompatible); CPPUNIT_TEST(testExclamation); CPPUNIT_TEST(testNumbers); CPPUNIT_TEST(testDataType); @@ -62,10 +64,11 @@ namespace const static rtl::OUString goto_(RTL_CONSTASCII_USTRINGPARAM("goto")); const static rtl::OUString excl(RTL_CONSTASCII_USTRINGPARAM("!")); - std::vector<Symbol> getSymbols(const rtl::OUString& source) + std::vector<Symbol> getSymbols(const rtl::OUString& source, bool bCompatible = false) { std::vector<Symbol> symbols; SbiScanner scanner(source); + scanner.SetCompatible(bCompatible); while(scanner.NextSym()) { Symbol symbol; @@ -449,6 +452,32 @@ namespace CPPUNIT_ASSERT(symbols[3].type == SbxVARIANT); } + void ScannerTest::testGotoCompatible() + { + const rtl::OUString source1(RTL_CONSTASCII_USTRINGPARAM("goto")); + const rtl::OUString source2(RTL_CONSTASCII_USTRINGPARAM("go to")); + const rtl::OUString source3(RTL_CONSTASCII_USTRINGPARAM("go\nto")); + + std::vector<Symbol> symbols; + + symbols = getSymbols(source1, true); + CPPUNIT_ASSERT(symbols.size() == 2); + CPPUNIT_ASSERT(symbols[0].text == goto_); + CPPUNIT_ASSERT(symbols[1].text == cr); + + symbols = getSymbols(source2, true); + CPPUNIT_ASSERT(symbols.size() == 2); + CPPUNIT_ASSERT(symbols[0].text == rtl::OUString(goto_)); + CPPUNIT_ASSERT(symbols[1].text == cr); + + symbols = getSymbols(source3, true); + CPPUNIT_ASSERT(symbols.size() == 4); + CPPUNIT_ASSERT(symbols[0].text == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("go"))); + CPPUNIT_ASSERT(symbols[1].text == cr); + CPPUNIT_ASSERT(symbols[2].text == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("to"))); + CPPUNIT_ASSERT(symbols[3].text == cr); + } + void ScannerTest::testExclamation() { const rtl::OUString source1(RTL_CONSTASCII_USTRINGPARAM("asdf!asdf")); |