diff --git a/pkg/ueps/packet_test.go b/pkg/ueps/packet_test.go index 317dc1d..0e24446 100644 --- a/pkg/ueps/packet_test.go +++ b/pkg/ueps/packet_test.go @@ -206,3 +206,34 @@ func TestPacket_writeTLV_Ugly(t *testing.T) { t.Errorf("expected length 0, got %d", encodedTLV[1]) } } + +// var e sentinelError = "record not found"; e.Error() == "record not found" +func TestPacket_sentinelError_Good(t *testing.T) { + e := sentinelError("record not found") + + if e.Error() != "record not found" { + t.Errorf("expected %q, got %q", "record not found", e.Error()) + } +} + +// var e sentinelError = ""; e.Error() == "" (empty message is valid sentinel) +func TestPacket_sentinelError_Bad(t *testing.T) { + e := sentinelError("") + + if e.Error() != "" { + t.Errorf("expected empty string, got %q", e.Error()) + } +} + +// var a, b sentinelError = "x", "x"; a == b (sentinel identity: same message = same error) +func TestPacket_sentinelError_Ugly(t *testing.T) { + a := sentinelError("integrity violation") + b := sentinelError("integrity violation") + + if a != b { + t.Errorf("expected sentinel identity: %q == %q", a, b) + } + if a.Error() != b.Error() { + t.Errorf("expected identical Error() output, got %q vs %q", a.Error(), b.Error()) + } +}