AssertEQ checks `value` and `expect` EQUAL, including their TYPES.
(value, expect any)
| 59 | |
| 60 | // AssertEQ checks `value` and `expect` EQUAL, including their TYPES. |
| 61 | func AssertEQ(value, expect any) { |
| 62 | // Value assert. |
| 63 | rvExpect := reflect.ValueOf(expect) |
| 64 | if empty.IsNil(value) { |
| 65 | value = nil |
| 66 | } |
| 67 | if rvExpect.Kind() == reflect.Map { |
| 68 | if err := compareMap(value, expect); err != nil { |
| 69 | panic(err) |
| 70 | } |
| 71 | return |
| 72 | } |
| 73 | strValue := gconv.String(value) |
| 74 | strExpect := gconv.String(expect) |
| 75 | if strValue != strExpect { |
| 76 | panic(fmt.Sprintf(`[ASSERT] EXPECT %v == %v`, strValue, strExpect)) |
| 77 | } |
| 78 | // Type assert. |
| 79 | t1 := reflect.TypeOf(value) |
| 80 | t2 := reflect.TypeOf(expect) |
| 81 | if t1 != t2 { |
| 82 | panic(fmt.Sprintf(`[ASSERT] EXPECT TYPE %v[%v] == %v[%v]`, strValue, t1, strExpect, t2)) |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | // AssertNE checks `value` and `expect` NOT EQUAL. |
| 87 | func AssertNE(value, expect any) { |
searching dependent graphs…