Make TestCase.assert_string robust in the face of null actuals
This commit is contained in:
parent
4d1e86e5d1
commit
4e484e237d
1 changed files with 10 additions and 4 deletions
|
|
@ -53,11 +53,17 @@ public void assert_string(string expected, string? actual, string? context = nul
|
|||
if (a.length > 32) {
|
||||
a = a[0:32] + "…";
|
||||
}
|
||||
string b = actual;
|
||||
if (b.length > 32) {
|
||||
b = b[0:32] + "…";
|
||||
string? b = actual;
|
||||
if (b != null) {
|
||||
if (b.length > 32) {
|
||||
b = b[0:32] + "…";
|
||||
}
|
||||
}
|
||||
if (b != null) {
|
||||
print_assert("Expected: \"%s\", was: \"%s\"".printf(a, b), context);
|
||||
} else {
|
||||
print_assert("Expected: \"%s\", was null".printf(a), context);
|
||||
}
|
||||
print_assert("Expected: \"%s\", was: \"%s\"".printf(a, b), context);
|
||||
assert_not_reached();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue