summaryrefslogtreecommitdiff
path: root/svl
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2015-08-06 19:11:20 +0200
committerEike Rathke <erack@redhat.com>2015-08-06 19:11:50 +0200
commitb02f792f23e6d5872de1f2f5abd0151a89751c43 (patch)
treea2ff6e0497e39bfe374b8db91128215ee63f4b5e /svl
parentc7d66949beecab92dc8f1380c54751710aa0b7a2 (diff)
unit test for short name ambiguity, tdf#93080
Change-Id: I97f33c8db59d2fc084b5e4eb389bff3d8254d4f0
Diffstat (limited to 'svl')
-rw-r--r--svl/qa/unit/svl.cxx35
1 files changed, 35 insertions, 0 deletions
diff --git a/svl/qa/unit/svl.cxx b/svl/qa/unit/svl.cxx
index 6f46ba5110ae..f6ee9e245f8e 100644
--- a/svl/qa/unit/svl.cxx
+++ b/svl/qa/unit/svl.cxx
@@ -1048,6 +1048,41 @@ void Test::testIsNumberFormat()
CPPUNIT_ASSERT_EQUAL(aTests[i].bIsNumber, bIsNumber);
}
+
+ // Test Spanish "mar" short name ambiguity, day "martes" or month "marzo".
+ // Day of week names are only parsed away, not evaluated if they actually
+ // correspond to the date given.
+ struct SpanishDate
+ {
+ const char* mpInput;
+ bool mbNumber;
+ const char* mpOutput;
+ } aSpanishTests[] = {
+ { "22/11/1999", true, "22/11/1999" },
+ { "Lun 22/11/1999", true, "22/11/1999" },
+ { "Mar 22/11/1999", true, "22/11/1999" },
+ { "Abr 22/11/1999", false, "" }, // month name AND numeric month don't go along
+ { "Lun Mar 22/11/1999", false, "" }, // month name AND numeric month don't go along
+ { "Mar Mar 22/11/1999", false, "" }, // month name AND numeric month don't go along
+ { "Lun Mar 22 1999", true, "22/03/1999" },
+ { "Mar Mar 22 1999", true, "22/03/1999" },
+ { "Mar Lun 22 1999", false, "" } // day name only at the beginning (could change?)
+ };
+
+ sal_uInt32 nIndex = aFormatter.GetFormatIndex( NF_DATE_SYS_DDMMYYYY, LANGUAGE_SPANISH);
+ for (size_t i = 0; i < SAL_N_ELEMENTS(aSpanishTests); ++i)
+ {
+ double fNumber = 0;
+ OUString aString = OUString::createFromAscii( aSpanishTests[i].mpInput);
+ bool bIsNumber = aFormatter.IsNumberFormat( aString, nIndex, fNumber);
+ CPPUNIT_ASSERT_EQUAL( aSpanishTests[i].mbNumber, bIsNumber);
+ if (aSpanishTests[i].mbNumber)
+ {
+ Color* pColor;
+ aFormatter.GetOutputString( fNumber, nIndex, aString, &pColor);
+ CPPUNIT_ASSERT_EQUAL( OUString::createFromAscii( aSpanishTests[i].mpOutput), aString);
+ }
+ }
}
CPPUNIT_TEST_SUITE_REGISTRATION(Test);