ax(ueps): add missing sentinelError.Error() Good/Bad/Ugly tests
TestPacket_sentinelError_{Good,Bad,Ugly} were absent — AX requires all
three test categories for every exported and package-level function.
The Error() method on sentinelError had no direct coverage.
Co-Authored-By: Charon <charon@lethean.io>
This commit is contained in:
parent
dc68334162
commit
2dcdc48a68
1 changed files with 31 additions and 0 deletions
|
|
@ -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())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue