Skip to content
This repository has been archived by the owner on Apr 9, 2021. It is now read-only.

Commit

Permalink
add ICU_VERSION check
Browse files Browse the repository at this point in the history
  • Loading branch information
ovalhub committed Jan 15, 2018
1 parent 012007c commit 5d4b253
Showing 1 changed file with 22 additions and 19 deletions.
41 changes: 22 additions & 19 deletions test/test_NumberFormatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,34 +31,37 @@ class TestNumberFormatter(TestCase):

def testBasic(self):

text = NumberFormatter.withLocale(Locale.getUS()).formatInt(1234)
self.assertEqual(text, u'1,234')
if ICU_VERSION >= '60.0':
text = NumberFormatter.withLocale(Locale.getUS()).formatInt(1234)
self.assertEqual(text, u'1,234')

text = LocalizedNumberFormatter(Locale.getUS()).formatInt(1234)
self.assertEqual(text, u'1,234')
text = LocalizedNumberFormatter(Locale.getUS()).formatInt(1234)
self.assertEqual(text, u'1,234')

def testFancy(self):

text = NumberFormatter.with_() \
.notation(Notation.compactShort()) \
.unit(CurrencyUnit('EUR')) \
.rounding(Rounder.maxDigits(2)) \
.locale(Locale.getFrance()) \
.formatInt(1234)
self.assertEqual(text, u'1,2\xa0k\xa0€')
if ICU_VERSION >= '60.0':
text = NumberFormatter.with_() \
.notation(Notation.compactShort()) \
.unit(CurrencyUnit('EUR')) \
.rounding(Rounder.maxDigits(2)) \
.locale(Locale.getFrance()) \
.formatInt(1234)
self.assertEqual(text, u'1,2\xa0k\xa0€')

def testUnit(self):

formatter = UnlocalizedNumberFormatter() \
.sign(UNumberSignDisplay.ALWAYS) \
.unit(MeasureUnit.createMeter()) \
.unitWidth(UNumberUnitWidth.FULL_NAME)
if ICU_VERSION >= '60.0':
formatter = UnlocalizedNumberFormatter() \
.sign(UNumberSignDisplay.ALWAYS) \
.unit(MeasureUnit.createMeter()) \
.unitWidth(UNumberUnitWidth.FULL_NAME)

text = formatter.locale(Locale.getUS()).formatInt(1234)
self.assertEqual(text, u'+1,234 meters')
text = formatter.locale(Locale.getUS()).formatInt(1234)
self.assertEqual(text, u'+1,234 meters')

text = formatter.locale(Locale.getFrance()).formatInt(1234)
self.assertEqual(text, u'+1\xa0234 mètres')
text = formatter.locale(Locale.getFrance()).formatInt(1234)
self.assertEqual(text, u'+1\xa0234 mètres')


if __name__ == "__main__":
Expand Down

0 comments on commit 5d4b253

Please sign in to comment.