123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- goog.provide('goog.i18n.pluralRulesTest');
- goog.setTestOnly('goog.i18n.pluralRulesTest');
- goog.require('goog.i18n.pluralRules');
- goog.require('goog.testing.jsunit');
- var Keyword = goog.i18n.pluralRules.Keyword;
- function testSimpleSelectEn() {
- var funcSelect = goog.i18n.pluralRules.enSelect_;
- assertEquals(Keyword.OTHER, funcSelect(0));
- assertEquals(Keyword.ONE, funcSelect(1));
- assertEquals(Keyword.OTHER, funcSelect(2));
- assertEquals(Keyword.OTHER, funcSelect(0, 2));
- assertEquals(Keyword.OTHER, funcSelect(1, 2));
- assertEquals(Keyword.OTHER, funcSelect(2, 2));
- }
- function testSimpleSelectRo() {
- var funcSelect = goog.i18n.pluralRules.roSelect_;
- assertEquals(Keyword.FEW, funcSelect(0));
- assertEquals(Keyword.ONE, funcSelect(1));
- assertEquals(Keyword.FEW, funcSelect(2));
- assertEquals(Keyword.FEW, funcSelect(12));
- assertEquals(Keyword.OTHER, funcSelect(23));
- assertEquals(Keyword.FEW, funcSelect(1212));
- assertEquals(Keyword.OTHER, funcSelect(1223));
- assertEquals(Keyword.FEW, funcSelect(0, 2));
- assertEquals(Keyword.FEW, funcSelect(1, 2));
- assertEquals(Keyword.FEW, funcSelect(2, 2));
- assertEquals(Keyword.FEW, funcSelect(12, 2));
- assertEquals(Keyword.FEW, funcSelect(23, 2));
- assertEquals(Keyword.FEW, funcSelect(1212, 2));
- assertEquals(Keyword.FEW, funcSelect(1223, 2));
- }
- function testSimpleSelectSr() {
- var funcSelect = goog.i18n.pluralRules.srSelect_;
- assertEquals(Keyword.ONE, funcSelect(1));
- assertEquals(Keyword.ONE, funcSelect(31));
- assertEquals(Keyword.ONE, funcSelect(0.1));
- assertEquals(Keyword.ONE, funcSelect(1.1));
- assertEquals(Keyword.ONE, funcSelect(2.1));
- assertEquals(Keyword.FEW, funcSelect(3));
- assertEquals(Keyword.FEW, funcSelect(33));
- assertEquals(Keyword.FEW, funcSelect(0.2));
- assertEquals(Keyword.FEW, funcSelect(0.3));
- assertEquals(Keyword.FEW, funcSelect(0.4));
- assertEquals(Keyword.FEW, funcSelect(2.2));
- assertEquals(Keyword.OTHER, funcSelect(2.11));
- assertEquals(Keyword.OTHER, funcSelect(2.12));
- assertEquals(Keyword.OTHER, funcSelect(2.13));
- assertEquals(Keyword.OTHER, funcSelect(2.14));
- assertEquals(Keyword.OTHER, funcSelect(2.15));
- assertEquals(Keyword.OTHER, funcSelect(0));
- assertEquals(Keyword.OTHER, funcSelect(5));
- assertEquals(Keyword.OTHER, funcSelect(10));
- assertEquals(Keyword.OTHER, funcSelect(35));
- assertEquals(Keyword.OTHER, funcSelect(37));
- assertEquals(Keyword.OTHER, funcSelect(40));
- assertEquals(Keyword.OTHER, funcSelect(0.0, 1));
- assertEquals(Keyword.OTHER, funcSelect(0.5));
- assertEquals(Keyword.OTHER, funcSelect(0.6));
- assertEquals(Keyword.FEW, funcSelect(2));
- assertEquals(Keyword.ONE, funcSelect(2.1));
- assertEquals(Keyword.FEW, funcSelect(2.2));
- assertEquals(Keyword.FEW, funcSelect(2.3));
- assertEquals(Keyword.FEW, funcSelect(2.4));
- assertEquals(Keyword.OTHER, funcSelect(2.5));
- assertEquals(Keyword.OTHER, funcSelect(20));
- assertEquals(Keyword.ONE, funcSelect(21));
- assertEquals(Keyword.FEW, funcSelect(22));
- assertEquals(Keyword.FEW, funcSelect(23));
- assertEquals(Keyword.FEW, funcSelect(24));
- assertEquals(Keyword.OTHER, funcSelect(25));
- }
|