Use diffs for tests
This commit is contained in:
@@ -94,6 +94,11 @@ modified = true
|
|||||||
result = result[:cmd.From] + cmd.With + result[cmd.To:]
|
result = result[:cmd.From] + cmd.With + result[cmd.To:]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
diff := cmp.Diff(result, tt.expected)
|
||||||
|
if diff != "" {
|
||||||
|
t.Errorf("Differences:\n%s", diff)
|
||||||
|
}
|
||||||
|
|
||||||
// Check the actual result matches expected
|
// Check the actual result matches expected
|
||||||
if result != tt.expected {
|
if result != tt.expected {
|
||||||
t.Errorf("Expected:\n%s\n\nGot:\n%s", tt.expected, result)
|
t.Errorf("Expected:\n%s\n\nGot:\n%s", tt.expected, result)
|
||||||
@@ -180,6 +185,11 @@ modified = true
|
|||||||
result = result[:cmd.From] + cmd.With + result[cmd.To:]
|
result = result[:cmd.From] + cmd.With + result[cmd.To:]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
diff := cmp.Diff(result, expected)
|
||||||
|
if diff != "" {
|
||||||
|
t.Errorf("Differences:\n%s", diff)
|
||||||
|
}
|
||||||
|
|
||||||
// Check that the result matches expected (preserves formatting and changes weight)
|
// Check that the result matches expected (preserves formatting and changes weight)
|
||||||
if result != expected {
|
if result != expected {
|
||||||
t.Errorf("Expected:\n%s\n\nGot:\n%s", expected, result)
|
t.Errorf("Expected:\n%s\n\nGot:\n%s", expected, result)
|
||||||
@@ -502,6 +512,11 @@ func TestSurgicalJSONPreservesFormatting2(t *testing.T) {
|
|||||||
result = result[:cmd.From] + cmd.With + result[cmd.To:]
|
result = result[:cmd.From] + cmd.With + result[cmd.To:]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
diff := cmp.Diff(result, expected)
|
||||||
|
if diff != "" {
|
||||||
|
t.Errorf("Differences:\n%s", diff)
|
||||||
|
}
|
||||||
|
|
||||||
// Check that the result matches expected (preserves formatting and changes weight)
|
// Check that the result matches expected (preserves formatting and changes weight)
|
||||||
if result != expected {
|
if result != expected {
|
||||||
t.Errorf("Expected:\n%s\n\nGot:\n%s", expected, result)
|
t.Errorf("Expected:\n%s\n\nGot:\n%s", expected, result)
|
||||||
@@ -594,6 +609,10 @@ func TestRetardedJSONEditing(t *testing.T) {
|
|||||||
result = result[:cmd.From] + cmd.With + result[cmd.To:]
|
result = result[:cmd.From] + cmd.With + result[cmd.To:]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
diff := cmp.Diff(result, expected)
|
||||||
|
if diff != "" {
|
||||||
|
t.Errorf("Differences:\n%s", diff)
|
||||||
|
}
|
||||||
|
|
||||||
// Check that the weight was changed
|
// Check that the weight was changed
|
||||||
if result != expected {
|
if result != expected {
|
||||||
@@ -601,7 +620,6 @@ func TestRetardedJSONEditing(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func TestRetardedJSONEditing2(t *testing.T) {
|
func TestRetardedJSONEditing2(t *testing.T) {
|
||||||
original := `
|
original := `
|
||||||
{
|
{
|
||||||
@@ -781,7 +799,6 @@ func TestRetardedJSONEditing2(t *testing.T) {
|
|||||||
"ParentTags": []
|
"ParentTags": []
|
||||||
}
|
}
|
||||||
,"AdditionalStats": {"(Value=\"BaseDeepMiningDrillSpeed_+%\")":4000}}
|
,"AdditionalStats": {"(Value=\"BaseDeepMiningDrillSpeed_+%\")":4000}}
|
||||||
}
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
@@ -819,9 +836,12 @@ func TestRetardedJSONEditing2(t *testing.T) {
|
|||||||
result = result[:cmd.From] + cmd.With + result[cmd.To:]
|
result = result[:cmd.From] + cmd.With + result[cmd.To:]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
diff := cmp.Diff(result, expected)
|
diff := cmp.Diff(result, expected)
|
||||||
if diff != "" {
|
if diff != "" {
|
||||||
t.Errorf("Differences:\n%s", diff)
|
t.Errorf("Differences:\n%s", diff)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if result != expected {
|
||||||
|
t.Errorf("Expected:\n%s\nGot:\n%s", expected, result)
|
||||||
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user