Skip to content
This repository was archived by the owner on Jun 27, 2023. It is now read-only.
This repository was archived by the owner on Jun 27, 2023. It is now read-only.

Error output is ambiguous for equivalent values with different types #190

Closed
@bradwilzon

Description

@bradwilzon

return fmt.Sprintf("is equal to %v", e.x)

When printing output for matched errors, if the expected and actual value have different types, either a special message should be printed (ie. expected value type does not match actual value type), or simply print the type with the output.

My confusing error output:

Expected call at mytest.go:467 doesn't match the argument at index 1.
Got: 8
Want: is equal to 8

In this case, I was using a const val = 8 which is resolved to an int. The const is used in the innards of a struct that expects an int32 (so the const is correctly casted). The const is then passed as the parameter to a method mocked by EXPECT() that originally takes an int32, but the mock version of the method takes an interface{}. Therefore, in the second case, the const is never casted correctly to int32 and causes a type mismatch further down the call path.

The long story short is, it's possible for gomock to print equivalent values without type information.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions