[Libreoffice-commits] core.git: basic/qa

shubham656 (via logerrit) logerrit at kemper.freedesktop.org
Wed Feb 17 14:35:06 UTC 2021


 basic/qa/cppunit/test_scanner.cxx |   77 ++++++++++++++++++++++++++++++++++++++
 basic/qa/vba_tests/typename.vb    |   14 ++++++
 basic/qa/vba_tests/vartype.vb     |   38 +++++++++++++++---
 3 files changed, 123 insertions(+), 6 deletions(-)

New commits:
commit 30ca77c43ba1c8f94d6f34eea763a3d3ca7e72f6
Author:     shubham656 <shubham656jain at gmail.com>
AuthorDate: Tue Jan 26 21:33:53 2021 +0530
Commit:     Andreas Heinisch <andreas.heinisch at yahoo.de>
CommitDate: Wed Feb 17 15:34:22 2021 +0100

    tdf#130677 Write new tests for literals
    
    Change-Id: I22607fdcaab840ca1512abf534712d36d4b5ee9b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109964
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
    Reviewed-by: Andreas Heinisch <andreas.heinisch at yahoo.de>
    Tested-by: Jenkins

diff --git a/basic/qa/cppunit/test_scanner.cxx b/basic/qa/cppunit/test_scanner.cxx
index ed340755deba..5663c44d027e 100644
--- a/basic/qa/cppunit/test_scanner.cxx
+++ b/basic/qa/cppunit/test_scanner.cxx
@@ -1034,6 +1034,83 @@ void ScannerTest::testHexOctal()
     CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
     // ERRCODE_BASIC_MATH_OVERFLOW
     CPPUNIT_ASSERT_EQUAL(1u, static_cast<unsigned int>(errors));
+
+    // maximum for Hex & = SbxLONG
+    symbols = getSymbols("&H7FFFFFFF&");
+    CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(2147483647.0, symbols[0].number, 1E-12);
+    CPPUNIT_ASSERT_EQUAL(OUString(), symbols[0].text);
+    CPPUNIT_ASSERT_EQUAL(SbxLONG, symbols[0].type);
+    CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+
+    // minimum for Hex & = SbxLONG
+    symbols = getSymbols("&H80000000&");
+    CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(-2147483648.0, symbols[0].number, 1E-12);
+    CPPUNIT_ASSERT_EQUAL(OUString(), symbols[0].text);
+    CPPUNIT_ASSERT_EQUAL(SbxLONG, symbols[0].type);
+    CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+
+    // overflow for Hex & = SbxLONG
+    symbols = getSymbols("&H100000000&", errors);
+    CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(0, symbols[0].number, 1E-12);
+    CPPUNIT_ASSERT_EQUAL(OUString(), symbols[0].text);
+    CPPUNIT_ASSERT_EQUAL(SbxLONG, symbols[0].type);
+    CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+    // ERRCODE_BASIC_MATH_OVERFLOW
+    CPPUNIT_ASSERT_EQUAL(1u, static_cast<unsigned int>(errors));
+
+    // maximum for Octal & = SbxLONG
+    symbols = getSymbols("&O17777777777&");
+    CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(2147483647.0, symbols[0].number, 1E-12);
+    CPPUNIT_ASSERT_EQUAL(OUString(), symbols[0].text);
+    CPPUNIT_ASSERT_EQUAL(SbxLONG, symbols[0].type);
+    CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+
+    // minimum for Octal & = SbxLONG
+    symbols = getSymbols("&O20000000000&", errors);
+    CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(-2147483648.0, symbols[0].number, 1E-12);
+    CPPUNIT_ASSERT_EQUAL(OUString(), symbols[0].text);
+    CPPUNIT_ASSERT_EQUAL(SbxLONG, symbols[0].type);
+    CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+
+    // overflow for Octal & = SbxLONG
+    symbols = getSymbols("&O40000000000&", errors);
+    CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(0, symbols[0].number, 1E-12);
+    CPPUNIT_ASSERT_EQUAL(OUString(), symbols[0].text);
+    CPPUNIT_ASSERT_EQUAL(SbxLONG, symbols[0].type);
+    CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+    // ERRCODE_BASIC_MATH_OVERFLOW
+    CPPUNIT_ASSERT_EQUAL(1u, static_cast<unsigned int>(errors));
+
+    /* test for leading zeros */
+
+    // &H0000000FFFF = 65535
+    symbols = getSymbols("&H0000000FFFF");
+    CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(-1.0, symbols[0].number, 1E-12);
+    CPPUNIT_ASSERT_EQUAL(OUString(), symbols[0].text);
+    CPPUNIT_ASSERT_EQUAL(SbxINTEGER, symbols[0].type);
+    CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+
+    // &O00000123 = 83
+    symbols = getSymbols("&O00000123");
+    CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(83.0, symbols[0].number, 1E-12);
+    CPPUNIT_ASSERT_EQUAL(OUString(), symbols[0].text);
+    CPPUNIT_ASSERT_EQUAL(SbxINTEGER, symbols[0].type);
+    CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+
+    symbols = getSymbols("&O7777777");
+    CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(2097151.0, symbols[0].number, 1E-12);
+    CPPUNIT_ASSERT_EQUAL(OUString(), symbols[0].text);
+    CPPUNIT_ASSERT_EQUAL(SbxLONG, symbols[0].type);
+    CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
 }
 
 void ScannerTest::testTdf103104()
diff --git a/basic/qa/vba_tests/typename.vb b/basic/qa/vba_tests/typename.vb
index c8fa5330a8e8..4442cba55e98 100644
--- a/basic/qa/vba_tests/typename.vb
+++ b/basic/qa/vba_tests/typename.vb
@@ -25,6 +25,13 @@ Sub verify_testTypeName()
     Dim l1 As Long
     Dim s1 As String
 
+    Dim TestIntSign%
+    Dim TestLongSign&
+    Dim TestSingleSign!
+    Dim TestDoubleSign#
+    Dim TestCurrSign@
+    Dim TestStrSign$
+
     TestUtil.AssertEqual(TypeName(s1), "String",  "TypeName(s1)")
     TestUtil.AssertEqual(TypeName(b1), "Boolean", "TypeName(b1)")
     TestUtil.AssertEqual(TypeName(c1), "Byte",    "TypeName(c1)")
@@ -39,6 +46,13 @@ Sub verify_testTypeName()
     TestUtil.AssertEqual(TypeName(1048575),  "Long",    "TypeName(1048575)")
     TestUtil.AssertEqual(TypeName(-1048575), "Long",    "TypeName(-1048575)")
 
+    TestUtil.AssertEqual(TypeName(TestIntSign),    "Integer",  "TypeName(TestIntSign)")
+    TestUtil.AssertEqual(TypeName(TestLongSign),   "Long",     "TypeName(TestLongSign)")
+    TestUtil.AssertEqual(TypeName(TestSingleSign), "Single",   "TypeName(TestSingleSign)")
+    TestUtil.AssertEqual(TypeName(TestDoubleSign), "Double",   "TypeName(TestDoubleSign)")
+    TestUtil.AssertEqual(TypeName(TestCurrSign),   "Currency", "TypeName(TestCurrSign)")
+    TestUtil.AssertEqual(TypeName(TestStrSign),    "String",   "TypeName(TestStrSign)")
+
     Exit Sub
 errorHandler:
     TestUtil.ReportErrorHandler("verify_testTypeName", Err, Error$, Erl)
diff --git a/basic/qa/vba_tests/vartype.vb b/basic/qa/vba_tests/vartype.vb
index c392772ec27d..2d8345ed1d86 100644
--- a/basic/qa/vba_tests/vartype.vb
+++ b/basic/qa/vba_tests/vartype.vb
@@ -22,14 +22,40 @@ Sub verify_testVarType()
     Dim TestLong As Long
     Dim TestDouble As Double
     Dim TestBoo As Boolean
+    Dim TestSingle As Single
+    Dim TestCurr As Currency
+
+    Dim TestIntSign%
+    Dim TestLongSign&
+    Dim TestSingleSign!
+    Dim TestDoubleSign#
+    Dim TestCurrSign@
+    Dim TestStrSign$
     On Error GoTo errorHandler
 
-    TestUtil.AssertEqual(VarType(TestStr),      8, "VarType(TestStr)")
-    TestUtil.AssertEqual(VarType(TestBoo),     11, "VarType(TestBoo)")
-    TestUtil.AssertEqual(VarType(TestDouble),   5, "VarType(TestDouble)")
-    TestUtil.AssertEqual(VarType(TestLong),     3, "VarType(TestLong)")
-    TestUtil.AssertEqual(VarType(TestInt),      2, "VarType(TestInt)")
-    TestUtil.AssertEqual(VarType(TestDateTime), 7, "VarType(TestDateTime)")
+    TestUtil.AssertEqual(vbInteger,  2,  "vbInteger")
+    TestUtil.AssertEqual(vbLong,     3,  "vbLong")
+    TestUtil.AssertEqual(vbSingle,   4,  "vbSingle")
+    TestUtil.AssertEqual(vbDouble,   5,  "vbDouble")
+    TestUtil.AssertEqual(vbCurrency, 6,  "vbCurrency")
+    TestUtil.AssertEqual(vbDate,     7,  "vbDate")
+    TestUtil.AssertEqual(vbString,   8,  "vbString")
+    TestUtil.AssertEqual(vbBoolean,  11, "vbBoolean")
+
+    TestUtil.AssertEqual(VarType(TestStr),        vbString,   "VarType(TestStr)")
+    TestUtil.AssertEqual(VarType(TestBoo),        vbBoolean,  "VarType(TestBoo)")
+    TestUtil.AssertEqual(VarType(TestDouble),     vbDouble,   "VarType(TestDouble)")
+    TestUtil.AssertEqual(VarType(TestLong),       vbLong,     "VarType(TestLong)")
+    TestUtil.AssertEqual(VarType(TestInt),        vbInteger,  "VarType(TestInt)")
+    TestUtil.AssertEqual(VarType(TestDateTime),   vbDate,     "VarType(TestDateTime)")
+    TestUtil.AssertEqual(VarType(TestSingle),     vbSingle,   "VarType(TestSingle)")
+    TestUtil.AssertEqual(VarType(TestCurr),       vbCurrency, "VarType(TestCurr)")
+
+    TestUtil.AssertEqual(VarType(TestIntSign),    vbInteger,  "VarType(TestIntSign)")
+    TestUtil.AssertEqual(VarType(TestLongSign),   vbLong,     "VarType(TestLongSign)")
+    TestUtil.AssertEqual(VarType(TestSingleSign), vbSingle,   "VarType(TestSingleSign)")
+    TestUtil.AssertEqual(VarType(TestDoubleSign), vbDouble,   "VarType(TestDoubleSign)")
+    TestUtil.AssertEqual(VarType(TestCurrSign),   vbCurrency, "VarType(TestCurrSign)")
 
     Exit Sub
 errorHandler:


More information about the Libreoffice-commits mailing list