(t *testing.T)
| 1008 | } |
| 1009 | |
| 1010 | func TestFormatter_FormatValue(t *testing.T) { |
| 1011 | var formatter = &DefaultFormatter{} |
| 1012 | |
| 1013 | checkAll := func(t *testing.T, fn func(interface{}) string) { |
| 1014 | var tnil *typedStingerNil |
| 1015 | var tnilPtr fmt.Stringer = tnil |
| 1016 | |
| 1017 | assert.Nil(t, tnilPtr) |
| 1018 | assert.NotEqual(t, nil, tnilPtr) |
| 1019 | |
| 1020 | check := func(s string) { |
| 1021 | t.Logf("\n%s", s) |
| 1022 | assert.NotEmpty(t, s) |
| 1023 | } |
| 1024 | |
| 1025 | check(fn(nil)) |
| 1026 | check(fn(tnil)) |
| 1027 | check(fn(tnilPtr)) |
| 1028 | check(fn(123)) |
| 1029 | check(fn(float32(123))) |
| 1030 | check(fn(float64(123))) |
| 1031 | check(fn("hello")) |
| 1032 | check(fn(time.Second)) |
| 1033 | check(fn(time.Unix(0, 0))) |
| 1034 | check(fn([]interface{}{1, 2})) |
| 1035 | check(fn(map[string]string{"a": "b"})) |
| 1036 | check(fn(make(chan int))) |
| 1037 | check(fn(AssertionRange{1, 2})) |
| 1038 | check(fn(&AssertionRange{1, 2})) |
| 1039 | check(fn(AssertionRange{"a", "b"})) |
| 1040 | check(fn(AssertionList([]interface{}{1, 2}))) |
| 1041 | } |
| 1042 | |
| 1043 | t.Run("formatValue", func(t *testing.T) { |
| 1044 | checkAll(t, formatter.formatValue) |
| 1045 | }) |
| 1046 | |
| 1047 | t.Run("formatTypedValue", func(t *testing.T) { |
| 1048 | checkAll(t, formatter.formatTypedValue) |
| 1049 | }) |
| 1050 | |
| 1051 | t.Run("formatMatchValue", func(t *testing.T) { |
| 1052 | checkAll(t, formatter.formatMatchValue) |
| 1053 | }) |
| 1054 | |
| 1055 | t.Run("formatRangeValue", func(t *testing.T) { |
| 1056 | checkAll(t, func(v interface{}) string { |
| 1057 | return strings.Join(formatter.formatRangeValue(v), "") |
| 1058 | }) |
| 1059 | }) |
| 1060 | |
| 1061 | t.Run("formatListValue", func(t *testing.T) { |
| 1062 | checkAll(t, func(v interface{}) string { |
| 1063 | return strings.Join(formatter.formatListValue(v), "") |
| 1064 | }) |
| 1065 | }) |
| 1066 | } |
| 1067 |
nothing calls this directly
no test coverage detected
searching dependent graphs…