diff options
author | Philipp Hofer <philipp.hofer@protonmail.com> | 2020-11-12 12:48:50 +0100 |
---|---|---|
committer | Christian Lohmaier <lohmaier+LibreOffice@googlemail.com> | 2020-11-13 14:31:50 +0100 |
commit | 16389aae367ebfa8ce19f8ee1c26232fec7ff729 (patch) | |
tree | 7aaadc9979fba948691e66ee3ea92cea3b69d0bd /basic/qa | |
parent | 0eaf2092940dc604926d31ef11b6ffb07abedc5a (diff) |
tdf#123936 Formatting files in module basic with clang-format
Change-Id: I87736d6f1a1d069c990b4e7b9ca291634ab4fb44
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105646
Tested-by: Jenkins
Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
Diffstat (limited to 'basic/qa')
-rw-r--r-- | basic/qa/cppunit/basictest.hxx | 10 | ||||
-rw-r--r-- | basic/qa/cppunit/test_scanner.cxx | 143 |
2 files changed, 78 insertions, 75 deletions
diff --git a/basic/qa/cppunit/basictest.hxx b/basic/qa/cppunit/basictest.hxx index f5fb79f557ba..c0afeb5bd18c 100644 --- a/basic/qa/cppunit/basictest.hxx +++ b/basic/qa/cppunit/basictest.hxx @@ -29,21 +29,21 @@ private: StarBASICRef mpBasic; void InitSnippet(); - void MakeModule( const OUString& sSource ); + void MakeModule(const OUString& sSource); public: - explicit MacroSnippet( const OUString& sSource ); + explicit MacroSnippet(const OUString& sSource); MacroSnippet(); - void LoadSourceFromFile( const OUString& sMacroFileURL ); + void LoadSourceFromFile(const OUString& sMacroFileURL); - SbxVariableRef Run( const css::uno::Sequence< css::uno::Any >& rArgs ); + SbxVariableRef Run(const css::uno::Sequence<css::uno::Any>& rArgs); SbxVariableRef Run(); bool Compile(); - DECL_LINK( BasicErrorHdl, StarBASIC *, bool ); + DECL_LINK(BasicErrorHdl, StarBASIC*, bool); bool HasError() const; const ErrCode& getError() const; diff --git a/basic/qa/cppunit/test_scanner.cxx b/basic/qa/cppunit/test_scanner.cxx index 7515b0d07862..ed340755deba 100644 --- a/basic/qa/cppunit/test_scanner.cxx +++ b/basic/qa/cppunit/test_scanner.cxx @@ -19,22 +19,22 @@ namespace { - struct Symbol - { +struct Symbol +{ sal_uInt16 line; sal_uInt16 col1; OUString text; double number; SbxDataType type; bool ws; - }; +}; - /** +/** * Perform tests on Scanner. */ - class ScannerTest : public CppUnit::TestFixture - { - private: +class ScannerTest : public CppUnit::TestFixture +{ +private: void testBlankLines(); void testOperators(); void testAlphanum(); @@ -67,44 +67,44 @@ namespace // End of test suite definition CPPUNIT_TEST_SUITE_END(); - }; +}; - const OUString cr = "\n"; - const OUString rem = "REM"; - const OUString asdf = "asdf"; - const OUString dot = "."; - const OUString goto_ = "goto"; - const OUString excl = "!"; +const OUString cr = "\n"; +const OUString rem = "REM"; +const OUString asdf = "asdf"; +const OUString dot = "."; +const OUString goto_ = "goto"; +const OUString excl = "!"; - std::vector<Symbol> getSymbols(const OUString& source, sal_Int32& errors, bool bCompatible = false) - { +std::vector<Symbol> getSymbols(const OUString& source, sal_Int32& errors, bool bCompatible = false) +{ std::vector<Symbol> symbols; SbiScanner scanner(source); scanner.EnableErrors(); scanner.SetCompatible(bCompatible); - while(scanner.NextSym()) + while (scanner.NextSym()) { - Symbol symbol; - symbol.line = scanner.GetLine(); - symbol.col1 = scanner.GetCol1(); - symbol.text = scanner.GetSym(); - symbol.number = scanner.GetDbl(); - symbol.type = scanner.GetType(); - symbol.ws = scanner.WhiteSpace(); - symbols.push_back(symbol); + Symbol symbol; + symbol.line = scanner.GetLine(); + symbol.col1 = scanner.GetCol1(); + symbol.text = scanner.GetSym(); + symbol.number = scanner.GetDbl(); + symbol.type = scanner.GetType(); + symbol.ws = scanner.WhiteSpace(); + symbols.push_back(symbol); } errors = scanner.GetErrors(); return symbols; - } +} - std::vector<Symbol> getSymbols(const OUString& source, bool bCompatible = false) - { +std::vector<Symbol> getSymbols(const OUString& source, bool bCompatible = false) +{ sal_Int32 i; return getSymbols(source, i, bCompatible); - } +} - void ScannerTest::testBlankLines() - { +void ScannerTest::testBlankLines() +{ std::vector<Symbol> symbols; symbols = getSymbols(""); CPPUNIT_ASSERT(symbols.empty()); @@ -156,10 +156,10 @@ namespace CPPUNIT_ASSERT_EQUAL(size_t(1), symbols.size()); CPPUNIT_ASSERT_EQUAL(cr, symbols[0].text); CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[0].type); - } +} - void ScannerTest::testOperators() - { +void ScannerTest::testOperators() +{ const OUString sourceE("="); const OUString sourceLT("<"); const OUString sourceGT(">"); @@ -235,10 +235,10 @@ namespace CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[0].type); CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text); CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[1].type); - } +} - void ScannerTest::testAlphanum() - { +void ScannerTest::testAlphanum() +{ const OUString source1("asdfghefg"); const OUString source3("AdfsaAUdsl10987"); const OUString source4("asdfa_mnvcnm"); @@ -359,10 +359,10 @@ namespace CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[1].type); CPPUNIT_ASSERT_EQUAL(cr, symbols[2].text); CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[2].type); - } +} - void ScannerTest::testComments() - { +void ScannerTest::testComments() +{ std::vector<Symbol> symbols; symbols = getSymbols("REM asdf"); @@ -417,10 +417,10 @@ namespace CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[2].type); CPPUNIT_ASSERT_EQUAL(rem, symbols[3].text); CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[3].type); - } +} - void ScannerTest::testGoto() - { +void ScannerTest::testGoto() +{ std::vector<Symbol> symbols; symbols = getSymbols("goto"); @@ -449,10 +449,10 @@ namespace CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[2].type); CPPUNIT_ASSERT_EQUAL(cr, symbols[3].text); CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[3].type); - } +} - void ScannerTest::testGotoCompatible() - { +void ScannerTest::testGotoCompatible() +{ std::vector<Symbol> symbols; symbols = getSymbols("goto", true); @@ -471,10 +471,10 @@ namespace CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text); CPPUNIT_ASSERT_EQUAL(OUString("to"), symbols[2].text); CPPUNIT_ASSERT_EQUAL(cr, symbols[3].text); - } +} - void ScannerTest::testExclamation() - { +void ScannerTest::testExclamation() +{ std::vector<Symbol> symbols; symbols = getSymbols("asdf!asdf"); @@ -513,10 +513,10 @@ namespace CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size()); CPPUNIT_ASSERT_EQUAL(excl, symbols[0].text); CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text); - } +} - void ScannerTest::testNumbers() - { +void ScannerTest::testNumbers() +{ std::vector<Symbol> symbols; sal_Int32 errors; @@ -642,7 +642,10 @@ namespace CPPUNIT_ASSERT_EQUAL(cr, symbols[5].text); CPPUNIT_ASSERT_EQUAL(0u, static_cast<unsigned int>(errors)); - symbols = getSymbols("1.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", errors); + symbols = getSymbols("1." + "0000000000000000000000000000000000000000000000000000000000000000000000000" + "000000000000000000000000000000000000000000000000000", + errors); CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size()); CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, symbols[0].number, 1E-12); CPPUNIT_ASSERT_EQUAL(SbxDOUBLE, symbols[0].type); @@ -652,13 +655,13 @@ namespace CPPUNIT_ASSERT_EQUAL(1u, static_cast<unsigned int>(errors)); // HACK double fInf = 0.0; - rtl::math::setInf( &fInf, false); + rtl::math::setInf(&fInf, false); symbols = getSymbols("10e308", errors); CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size()); CPPUNIT_ASSERT_EQUAL(fInf, symbols[0].number); CPPUNIT_ASSERT_EQUAL(SbxDOUBLE, symbols[0].type); CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text); - CPPUNIT_ASSERT_EQUAL(1u, static_cast<unsigned int>(errors)); // math error, overflow + CPPUNIT_ASSERT_EQUAL(1u, static_cast<unsigned int>(errors)); // math error, overflow // trailing data type character % = SbxINTEGER symbols = getSymbols("1.23%"); @@ -709,10 +712,10 @@ namespace CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text); // ERRCODE_BASIC_SYNTAX CPPUNIT_ASSERT_EQUAL(1u, static_cast<unsigned int>(errors)); - } +} - void ScannerTest::testDataType() - { +void ScannerTest::testDataType() +{ std::vector<Symbol> symbols; symbols = getSymbols("asdf%"); @@ -749,10 +752,10 @@ namespace CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size()); CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[0].type); CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text); - } +} - void ScannerTest::testHexOctal() - { +void ScannerTest::testHexOctal() +{ sal_Int32 errors; std::vector<Symbol> symbols; @@ -1031,10 +1034,10 @@ namespace CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text); // ERRCODE_BASIC_MATH_OVERFLOW CPPUNIT_ASSERT_EQUAL(1u, static_cast<unsigned int>(errors)); - } +} - void ScannerTest::testTdf103104() - { +void ScannerTest::testTdf103104() +{ std::vector<Symbol> symbols; symbols = getSymbols("asdf _\n asdf"); @@ -1061,10 +1064,10 @@ namespace CPPUNIT_ASSERT_EQUAL(asdf, symbols[2].text); CPPUNIT_ASSERT(!symbols[2].ws); CPPUNIT_ASSERT_EQUAL(cr, symbols[3].text); - } +} - void ScannerTest::testTdf136032() - { +void ScannerTest::testTdf136032() +{ std::vector<Symbol> symbols; sal_Int32 errors; @@ -1076,10 +1079,10 @@ namespace symbols = getSymbols("Print #i, \"A#B\"", errors); CPPUNIT_ASSERT_EQUAL(size_t(5), symbols.size()); CPPUNIT_ASSERT_EQUAL(0u, static_cast<unsigned int>(errors)); - } +} - // Put the test suite in the registry - CPPUNIT_TEST_SUITE_REGISTRATION(ScannerTest); +// Put the test suite in the registry +CPPUNIT_TEST_SUITE_REGISTRATION(ScannerTest); } // namespace CPPUNIT_PLUGIN_IMPLEMENT(); |