github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/utils/humannumbers/ordinal_test.go (about) 1 package humannumbers_test 2 3 import ( 4 "testing" 5 6 "github.com/lmorg/murex/test/count" 7 "github.com/lmorg/murex/utils/humannumbers" 8 ) 9 10 func TestOrdinal(t *testing.T) { 11 tests := map[int]string{ 12 -12512: "-12512th", 13 -12511: "-12511th", 14 -12510: "-12510th", 15 -1251: "-1251st", 16 -123: "-123rd", 17 -12: "-12th", 18 -11: "-11th", 19 -10: "-10th", 20 -9: "-9th", 21 -8: "-8th", 22 -7: "-7th", 23 -6: "-6th", 24 -5: "-5th", 25 -4: "-4th", 26 -3: "-3rd", 27 -2: "-2nd", 28 -1: "-1st", 29 30 0: "0th", 31 32 12512: "12512th", 33 12511: "12511th", 34 12510: "12510th", 35 1251: "1251st", 36 123: "123rd", 37 12: "12th", 38 11: "11th", 39 10: "10th", 40 9: "9th", 41 8: "8th", 42 7: "7th", 43 6: "6th", 44 5: "5th", 45 4: "4th", 46 3: "3rd", 47 2: "2nd", 48 1: "1st", 49 } 50 51 count.Tests(t, len(tests)) 52 53 for i, exp := range tests { 54 act := humannumbers.Ordinal(i) 55 56 if exp != act { 57 t.Error("Expected != Actual:") 58 t.Logf(" Integer: %d", i) 59 t.Logf(" Expected: %s", exp) 60 t.Logf(" Actual: %s", act) 61 } 62 } 63 }