1 package kmp 2 3 import ( 4 "testing" 5 6 "gotest.tools/v3/assert" 7 "gotest.tools/v3/assert/cmp" 8 ) 9 10 // Common test case and running logic for basic comparison tests. 11 12 type testCase struct { 13 cmp cmp.Comparison 14 success bool 15 } 16 17 // TODO(aw185176): We could assert on error/failure content if we passed a fake 18 // testing.T to assert.Assert in order to capture the t.Log output 19 func run(t *testing.T, tc testCase) { 20 t.Helper() 21 switch { 22 case tc.success: 23 assert.Assert(t, tc.cmp, "expected successful comparison") 24 case tc.cmp().Success(): 25 t.Fatal("expected unsuccessful comparison") 26 } 27 } 28