[Libreoffice-commits] .: basic/qa
August Sodora
augsod at kemper.freedesktop.org
Sat Nov 19 22:39:19 PST 2011
basic/qa/cppunit/test_scanner.cxx | 31 ++++++++++++++++++++++++++++++-
1 file changed, 30 insertions(+), 1 deletion(-)
New commits:
commit b97774aefa122aebf20de4208a820953c39172b1
Author: August Sodora <augsod at gmail.com>
Date: Sun Nov 20 00:44:53 2011 -0500
Added regression test for scanner
diff --git a/basic/qa/cppunit/test_scanner.cxx b/basic/qa/cppunit/test_scanner.cxx
index dd46b7a..95bbb47 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"));
More information about the Libreoffice-commits
mailing list