MCPcopy
hub / github.com/gogf/gf / AssertEQ

Function AssertEQ

test/gtest/gtest_util.go:61–84  ·  view source on GitHub ↗

AssertEQ checks `value` and `expect` EQUAL, including their TYPES.

(value, expect any)

Source from the content-addressed store, hash-verified

59
60// AssertEQ checks `value` and `expect` EQUAL, including their TYPES.
61func 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.
87func AssertNE(value, expect any) {

Callers 15

Test_TableFieldsFunction · 0.92
TestTablesFunction · 0.92
TestTableFieldsFunction · 0.92
Test_DB_TablesFunction · 0.92
Test_DB_TableFieldsFunction · 0.92
Test_TablesFunction · 0.92
Test_Table_FieldsFunction · 0.92
TestTablesFunction · 0.92
TestTableFieldsFunction · 0.92
Test_DB_TablesFunction · 0.92
Test_DB_TableFieldsFunction · 0.92

Calls 4

IsNilFunction · 0.92
StringFunction · 0.92
compareMapFunction · 0.85
KindMethod · 0.80

Tested by 15

Test_TableFieldsFunction · 0.74
TestTablesFunction · 0.74
TestTableFieldsFunction · 0.74
Test_DB_TablesFunction · 0.74
Test_DB_TableFieldsFunction · 0.74
Test_TablesFunction · 0.74
Test_Table_FieldsFunction · 0.74
TestTablesFunction · 0.74
TestTableFieldsFunction · 0.74
Test_DB_TablesFunction · 0.74
Test_DB_TableFieldsFunction · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…