summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2014-03-14 13:27:22 +0100
committerEike Rathke <erack@redhat.com>2014-03-14 13:30:19 +0100
commitaf88ab2ee9167279cb70a577fb399d23f2ce136f (patch)
tree10249e023702b0bd59286f4b0430ffb2b5875701 /sc
parentc52f3ea0eb327343b1945290c43d3b66f546dfe9 (diff)
unit test for string conversion feature, related fdo#37132 fdo#74622
Change-Id: If7d9c032d6025a6c6bf850e338923296ba2590dd
Diffstat (limited to 'sc')
-rw-r--r--sc/qa/unit/ucalc.cxx77
1 files changed, 74 insertions, 3 deletions
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index c903f4fcb19e..68713dfbdb4a 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -1661,12 +1661,14 @@ void Test::testFuncParam()
m_pDoc->SetString(0, 0, 0, OUString("=\"\"+3")); // empty string
m_pDoc->SetString(0, 1, 0, OUString("=\" \"+3")); // only blank
m_pDoc->SetString(0, 2, 0, OUString("=\" 4 \"+3")); // number in blanks
- m_pDoc->SetString(0, 3, 0, OUString("=\" x \"+3")); // non-numeric => #VALUE! error
+ m_pDoc->SetString(0, 3, 0, OUString("=\" x \"+3")); // non-numeric
+ m_pDoc->SetString(0, 4, 0, OUString("=\"4.4\"+3")); // locale dependent
OUString aVal;
ScCalcConfig aConfig;
- // With "Empty string as zero" option.
+ // With "Convert also locale dependent" and "Empty string as zero"=True option.
+ aConfig.meStringConversion = ScCalcConfig::STRING_CONVERSION_LOCALE_DEPENDENT;
aConfig.mbEmptyStringAsZero = true;
ScInterpreter::SetGlobalConfig(aConfig);
m_pDoc->CalcAll();
@@ -1678,8 +1680,11 @@ void Test::testFuncParam()
CPPUNIT_ASSERT_MESSAGE("incorrect result", val == 7);
aVal = m_pDoc->GetString( 0, 3, 0);
CPPUNIT_ASSERT_MESSAGE("incorrect result", aVal == "#VALUE!");
+ m_pDoc->GetValue(0, 4, 0, val);
+ CPPUNIT_ASSERT_MESSAGE("incorrect result", val == 7.4);
- // Without "Empty string as zero" option.
+ // With "Convert also locale dependent" and "Empty string as zero"=False option.
+ aConfig.meStringConversion = ScCalcConfig::STRING_CONVERSION_LOCALE_DEPENDENT;
aConfig.mbEmptyStringAsZero = false;
ScInterpreter::SetGlobalConfig(aConfig);
m_pDoc->CalcAll();
@@ -1691,6 +1696,72 @@ void Test::testFuncParam()
CPPUNIT_ASSERT_MESSAGE("incorrect result", val == 7);
aVal = m_pDoc->GetString( 0, 3, 0);
CPPUNIT_ASSERT_MESSAGE("incorrect result", aVal == "#VALUE!");
+ m_pDoc->GetValue(0, 4, 0, val);
+ CPPUNIT_ASSERT_MESSAGE("incorrect result", val == 7.4);
+
+ // With "Convert only unambiguous" and "Empty string as zero"=True option.
+ aConfig.meStringConversion = ScCalcConfig::STRING_CONVERSION_UNAMBIGUOUS;
+ aConfig.mbEmptyStringAsZero = true;
+ ScInterpreter::SetGlobalConfig(aConfig);
+ m_pDoc->CalcAll();
+ m_pDoc->GetValue(0, 0, 0, val);
+ CPPUNIT_ASSERT_MESSAGE("incorrect result", val == 3);
+ m_pDoc->GetValue(0, 1, 0, val);
+ CPPUNIT_ASSERT_MESSAGE("incorrect result", val == 3);
+ m_pDoc->GetValue(0, 2, 0, val);
+ CPPUNIT_ASSERT_MESSAGE("incorrect result", val == 7);
+ aVal = m_pDoc->GetString( 0, 3, 0);
+ CPPUNIT_ASSERT_MESSAGE("incorrect result", aVal == "#VALUE!");
+ aVal = m_pDoc->GetString( 0, 4, 0);
+ CPPUNIT_ASSERT_MESSAGE("incorrect result", aVal == "#VALUE!");
+
+ // With "Convert only unambiguous" and "Empty string as zero"=False option.
+ aConfig.meStringConversion = ScCalcConfig::STRING_CONVERSION_UNAMBIGUOUS;
+ aConfig.mbEmptyStringAsZero = false;
+ ScInterpreter::SetGlobalConfig(aConfig);
+ m_pDoc->CalcAll();
+ aVal = m_pDoc->GetString( 0, 0, 0);
+ CPPUNIT_ASSERT_MESSAGE("incorrect result", aVal == "#VALUE!");
+ aVal = m_pDoc->GetString( 0, 1, 0);
+ CPPUNIT_ASSERT_MESSAGE("incorrect result", aVal == "#VALUE!");
+ m_pDoc->GetValue(0, 2, 0, val);
+ CPPUNIT_ASSERT_MESSAGE("incorrect result", val == 7);
+ aVal = m_pDoc->GetString( 0, 3, 0);
+ CPPUNIT_ASSERT_MESSAGE("incorrect result", aVal == "#VALUE!");
+ aVal = m_pDoc->GetString( 0, 4, 0);
+ CPPUNIT_ASSERT_MESSAGE("incorrect result", aVal == "#VALUE!");
+
+ // With "Treat as zero" ("Empty string as zero" is ignored).
+ aConfig.meStringConversion = ScCalcConfig::STRING_CONVERSION_AS_ZERO;
+ aConfig.mbEmptyStringAsZero = true;
+ ScInterpreter::SetGlobalConfig(aConfig);
+ m_pDoc->CalcAll();
+ m_pDoc->GetValue(0, 0, 0, val);
+ CPPUNIT_ASSERT_MESSAGE("incorrect result", val == 3);
+ m_pDoc->GetValue(0, 1, 0, val);
+ CPPUNIT_ASSERT_MESSAGE("incorrect result", val == 3);
+ m_pDoc->GetValue(0, 2, 0, val);
+ CPPUNIT_ASSERT_MESSAGE("incorrect result", val == 3);
+ m_pDoc->GetValue(0, 3, 0, val);
+ CPPUNIT_ASSERT_MESSAGE("incorrect result", val == 3);
+ m_pDoc->GetValue(0, 4, 0, val);
+ CPPUNIT_ASSERT_MESSAGE("incorrect result", val == 3);
+
+ // With "Generate #VALUE! error" ("Empty string as zero" is ignored).
+ aConfig.meStringConversion = ScCalcConfig::STRING_CONVERSION_AS_ERROR;
+ aConfig.mbEmptyStringAsZero = false;
+ ScInterpreter::SetGlobalConfig(aConfig);
+ m_pDoc->CalcAll();
+ aVal = m_pDoc->GetString( 0, 0, 0);
+ CPPUNIT_ASSERT_MESSAGE("incorrect result", aVal == "#VALUE!");
+ aVal = m_pDoc->GetString( 0, 1, 0);
+ CPPUNIT_ASSERT_MESSAGE("incorrect result", aVal == "#VALUE!");
+ aVal = m_pDoc->GetString( 0, 2, 0);
+ CPPUNIT_ASSERT_MESSAGE("incorrect result", aVal == "#VALUE!");
+ aVal = m_pDoc->GetString( 0, 3, 0);
+ CPPUNIT_ASSERT_MESSAGE("incorrect result", aVal == "#VALUE!");
+ aVal = m_pDoc->GetString( 0, 4, 0);
+ CPPUNIT_ASSERT_MESSAGE("incorrect result", aVal == "#VALUE!");
m_pDoc->DeleteTab(0);
}