-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathordinal_test.go
36 lines (32 loc) · 977 Bytes
/
ordinal_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package messageformat
import (
"testing"
)
func TestSelectOrdinal(t *testing.T) {
doTest(t, Test{
"The {FLOOR, selectordinal, one{#st} two{#nd} few{#rd} other{#th}} floor.",
[]Expectation{
{map[string]interface{}{"FLOOR": 0}, "The 0th floor."},
{map[string]interface{}{"FLOOR": 1.0}, "The 1st floor."},
{map[string]interface{}{"FLOOR": "2"}, "The 2nd floor."},
{map[string]interface{}{"FLOOR": "3.00"}, "The 3.00rd floor."},
{map[string]interface{}{"FLOOR": 4}, "The 4th floor."},
{map[string]interface{}{"FLOOR": 101}, "The 101st floor."},
{nil, "The #th floor."},
},
})
doTestException(
t,
"{VAR,selectordinal,other{succeed}}",
map[string]interface{}{"VAR": struct{}{}},
"toString: Unsupported type: struct {}",
)
}
func BenchmarkSelectOrdinal(b *testing.B) {
doBenchmarkExecute(
b,
"The {FLOOR, selectordinal, one{#st} two{#nd} few{#rd} other{#th}} floor.",
"The 101st floor.",
map[string]interface{}{"FLOOR": 101},
)
}