github.com/amarpal/go-tools@v0.0.0-20240422043104-40142f59f616/analysis/report/report_test.go (about) 1 package report 2 3 import "testing" 4 5 func TestOrdinal(t *testing.T) { 6 tests := []struct { 7 num int 8 want string 9 }{ 10 {0, "0th"}, {1, "1st"}, {2, "2nd"}, {3, "3rd"}, {4, "4th"}, {5, "5th"}, {6, "6th"}, {7, "7th"}, {8, "8th"}, {9, "9th"}, 11 {10, "10th"}, {11, "11th"}, {12, "12th"}, {13, "13th"}, {14, "14th"}, {15, "15th"}, {16, "16th"}, {17, "17th"}, {18, "18th"}, {19, "19th"}, 12 {20, "20th"}, {21, "21st"}, {22, "22nd"}, {23, "23rd"}, {24, "24th"}, {25, "25th"}, {26, "26th"}, {27, "27th"}, {28, "28th"}, {29, "29th"}, 13 } 14 for _, tt := range tests { 15 if got := Ordinal(tt.num); got != tt.want { 16 t.Errorf("Ordinal(%d) = %s, want %s", tt.num, got, tt.want) 17 } 18 } 19 }