From 3cf45c5a15a14a32061e24717539ae1825c3ac78 Mon Sep 17 00:00:00 2001 From: Rose Hogenson Date: Sun, 26 Oct 2025 10:27:25 -0700 Subject: Improve error messages --- asspb_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'asspb_test.go') diff --git a/asspb_test.go b/asspb_test.go index b974b2f..4280dae 100644 --- a/asspb_test.go +++ b/asspb_test.go @@ -287,3 +287,21 @@ func TestUnmarshal_Invalid(t *testing.T) { }) } } + +func TestUnmarshal_ErrorLineCol(t *testing.T) { + msg := ` + ###### This is a very important file please do not modify + ######################################################### + ################ The more ## I put the more secure it is###### + secret:12345; # oops typo + ` + err := Unmarshal([]byte(msg), new(map[string]any)) + syntaxErr, ok := err.(*syntaxError) + if !ok { + t.Errorf("Unmarshal(%q): expected *syntaxError, got error %T %[2]v", msg, err) + } + want := &syntaxError{line: 5, col: 15} + if syntaxErr.line != want.line || syntaxErr.col != want.col { + t.Errorf("Unmarshal(%q) returned error %+v, want line %d, col %d", msg, syntaxErr, want.line, want.col) + } +} -- cgit v1.3.1