mirror of
https://github.com/wneessen/niljson.git
synced 2024-11-22 05:30:49 +01:00
Refactor error messages in niljson_test.go
Replaced hardcoded error strings with `ErrExpectedJSONInt` constant for consistency. This improves maintainability and readability of the test code by centralizing error message definitions.
This commit is contained in:
parent
98bcb37c50
commit
9584d3ec3c
1 changed files with 8 additions and 7 deletions
|
@ -16,6 +16,7 @@ const (
|
||||||
ErrUnmarshalFailed = "failed to unmarshal json with nil types: %s"
|
ErrUnmarshalFailed = "failed to unmarshal json with nil types: %s"
|
||||||
ErrMarshalFailed = "failed to marshal json with nil types: %s"
|
ErrMarshalFailed = "failed to marshal json with nil types: %s"
|
||||||
ErrExpectedJSONString = "expected json to be %q, got %q"
|
ErrExpectedJSONString = "expected json to be %q, got %q"
|
||||||
|
ErrExpectedJSONInt = "expected json to be %d, got %d"
|
||||||
)
|
)
|
||||||
|
|
||||||
var jsonBytes = []byte(
|
var jsonBytes = []byte(
|
||||||
|
@ -240,7 +241,7 @@ func TestVariable_UnmarshalJSON_Int(t *testing.T) {
|
||||||
t.Errorf("expected nil, but got value")
|
t.Errorf("expected nil, but got value")
|
||||||
}
|
}
|
||||||
if jt.Value.Value() != expected {
|
if jt.Value.Value() != expected {
|
||||||
t.Errorf("expected value to be %d, got %d", expected, jt.Value.Value())
|
t.Errorf(ErrExpectedJSONInt, expected, jt.Value.Value())
|
||||||
}
|
}
|
||||||
|
|
||||||
jt.Value.Reset()
|
jt.Value.Reset()
|
||||||
|
@ -287,7 +288,7 @@ func TestVariable_UnmarshalJSON_Int64(t *testing.T) {
|
||||||
t.Errorf("expected nil, but got value")
|
t.Errorf("expected nil, but got value")
|
||||||
}
|
}
|
||||||
if jt.Value.Value() != expected {
|
if jt.Value.Value() != expected {
|
||||||
t.Errorf("expected value to be %d, got %d", expected, jt.Value.Value())
|
t.Errorf(ErrExpectedJSONInt, expected, jt.Value.Value())
|
||||||
}
|
}
|
||||||
|
|
||||||
jt.Value.Reset()
|
jt.Value.Reset()
|
||||||
|
@ -381,7 +382,7 @@ func TestVariable_UnmarshalJSON_UInt(t *testing.T) {
|
||||||
t.Errorf("expected nil, but got value")
|
t.Errorf("expected nil, but got value")
|
||||||
}
|
}
|
||||||
if jt.Value.Value() != expected {
|
if jt.Value.Value() != expected {
|
||||||
t.Errorf("expected value to be %d, got %d", expected, jt.Value.Value())
|
t.Errorf(ErrExpectedJSONInt, expected, jt.Value.Value())
|
||||||
}
|
}
|
||||||
|
|
||||||
jt.Value.Reset()
|
jt.Value.Reset()
|
||||||
|
@ -428,7 +429,7 @@ func TestVariable_UnmarshalJSON_UInt8(t *testing.T) {
|
||||||
t.Errorf("expected nil, but got value")
|
t.Errorf("expected nil, but got value")
|
||||||
}
|
}
|
||||||
if jt.Value.Value() != expected {
|
if jt.Value.Value() != expected {
|
||||||
t.Errorf("expected value to be %d, got %d", expected, jt.Value.Value())
|
t.Errorf(ErrExpectedJSONInt, expected, jt.Value.Value())
|
||||||
}
|
}
|
||||||
|
|
||||||
jt.Value.Reset()
|
jt.Value.Reset()
|
||||||
|
@ -475,7 +476,7 @@ func TestVariable_UnmarshalJSON_UInt16(t *testing.T) {
|
||||||
t.Errorf("expected nil, but got value")
|
t.Errorf("expected nil, but got value")
|
||||||
}
|
}
|
||||||
if jt.Value.Value() != expected {
|
if jt.Value.Value() != expected {
|
||||||
t.Errorf("expected value to be %d, got %d", expected, jt.Value.Value())
|
t.Errorf(ErrExpectedJSONInt, expected, jt.Value.Value())
|
||||||
}
|
}
|
||||||
|
|
||||||
jt.Value.Reset()
|
jt.Value.Reset()
|
||||||
|
@ -522,7 +523,7 @@ func TestVariable_UnmarshalJSON_UInt32(t *testing.T) {
|
||||||
t.Errorf("expected nil, but got value")
|
t.Errorf("expected nil, but got value")
|
||||||
}
|
}
|
||||||
if jt.Value.Value() != expected {
|
if jt.Value.Value() != expected {
|
||||||
t.Errorf("expected value to be %d, got %d", expected, jt.Value.Value())
|
t.Errorf(ErrExpectedJSONInt, expected, jt.Value.Value())
|
||||||
}
|
}
|
||||||
|
|
||||||
jt.Value.Reset()
|
jt.Value.Reset()
|
||||||
|
@ -569,7 +570,7 @@ func TestVariable_UnmarshalJSON_UInt64(t *testing.T) {
|
||||||
t.Errorf("expected nil, but got value")
|
t.Errorf("expected nil, but got value")
|
||||||
}
|
}
|
||||||
if jt.Value.Value() != expected {
|
if jt.Value.Value() != expected {
|
||||||
t.Errorf("expected value to be %d, got %d", expected, jt.Value.Value())
|
t.Errorf(ErrExpectedJSONInt, expected, jt.Value.Value())
|
||||||
}
|
}
|
||||||
|
|
||||||
jt.Value.Reset()
|
jt.Value.Reset()
|
||||||
|
|
Loading…
Reference in a new issue