1 package flect
2
3 import (
4 "testing"
5
6 "github.com/stretchr/testify/require"
7 )
8
9 func Test_Ordinalize(t *testing.T) {
10 table := []tt{
11 {"-1", "-1st"},
12 {"-2", "-2nd"},
13 {"-3", "-3rd"},
14 {"-4", "-4th"},
15 {"-5", "-5th"},
16 {"-6", "-6th"},
17 {"-7", "-7th"},
18 {"-8", "-8th"},
19 {"-9", "-9th"},
20 {"-10", "-10th"},
21 {"-11", "-11th"},
22 {"-12", "-12th"},
23 {"-13", "-13th"},
24 {"-14", "-14th"},
25 {"-20", "-20th"},
26 {"-21", "-21st"},
27 {"-22", "-22nd"},
28 {"-23", "-23rd"},
29 {"-24", "-24th"},
30 {"-100", "-100th"},
31 {"-101", "-101st"},
32 {"-102", "-102nd"},
33 {"-103", "-103rd"},
34 {"-104", "-104th"},
35 {"-110", "-110th"},
36 {"-111", "-111th"},
37 {"-112", "-112th"},
38 {"-113", "-113th"},
39 {"-1000", "-1000th"},
40 {"-1001", "-1001st"},
41 {"0", "0th"},
42 {"1", "1st"},
43 {"2", "2nd"},
44 {"3", "3rd"},
45 {"4", "4th"},
46 {"5", "5th"},
47 {"6", "6th"},
48 {"7", "7th"},
49 {"8", "8th"},
50 {"9", "9th"},
51 {"10", "10th"},
52 {"11", "11th"},
53 {"12", "12th"},
54 {"13", "13th"},
55 {"14", "14th"},
56 {"20", "20th"},
57 {"21", "21st"},
58 {"22", "22nd"},
59 {"23", "23rd"},
60 {"24", "24th"},
61 {"100", "100th"},
62 {"101", "101st"},
63 {"102", "102nd"},
64 {"103", "103rd"},
65 {"104", "104th"},
66 {"110", "110th"},
67 {"111", "111th"},
68 {"112", "112th"},
69 {"113", "113th"},
70 {"1000", "1000th"},
71 {"1001", "1001st"},
72 }
73
74 for _, tt := range table {
75 t.Run(tt.act, func(st *testing.T) {
76 r := require.New(st)
77 r.Equal(tt.exp, Ordinalize(tt.act))
78 r.Equal(tt.exp, Ordinalize(tt.exp))
79 })
80 }
81 }
82
View as plain text