diff --git a/report/custom_test.go b/report/custom_test.go index f6ffcb67..a793af44 100644 --- a/report/custom_test.go +++ b/report/custom_test.go @@ -7,6 +7,7 @@ import ( "path/filepath" "testing" + "github.com/google/go-cmp/cmp" "github.com/tenntenn/golden" ) @@ -343,3 +344,40 @@ func TestDiffCustomMetricSetMetadataTable(t *testing.T) { }) } } + +func TestConvertFormat(t *testing.T) { + tests := []struct { + n interface{} + want string + }{ + { + int(10), + "10", + }, + { + int32(3200), + "3,200", + }, + { + float32(10.0), + "10", + }, + { + float32(1000.1), + "1,000.1", + }, + { + int(1000), + "1,000", + }, + } + + for i, tt := range tests { + t.Run(fmt.Sprintf("%d", i), func(t *testing.T) { + got := convertFormat(tt.n) + if diff := cmp.Diff(got, tt.want, nil); diff != "" { + t.Error(diff) + } + }) + } +}