1 package pagination 2 3 import "testing" 4 5 func TestItoa(t *testing.T) { 6 tests := []struct { 7 num uint 8 str string 9 }{ 10 {0, "0"}, 11 {1, "1"}, 12 {2, "2"}, 13 {9, "9"}, 14 {10, "10"}, 15 {11, "11"}, 16 {20, "20"}, 17 {99, "99"}, 18 {100, "100"}, 19 {101, "101"}, 20 {999999999, "999999999"}, 21 {3999999999, "3999999999"}, 22 {4000000000, "4000000000"}, 23 {4294967295, "4294967295"}, 24 } 25 26 for n, test := range tests { 27 if numStr := itoa(test.num); numStr != test.str { 28 t.Errorf("test %d: expecting %q, got %q", n+1, test.str, numStr) 29 } 30 } 31 }