[geary/wip/3.32-avatars: 46/50] Make TestCase.assert_string robust in the face of null actuals
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/3.32-avatars: 46/50] Make TestCase.assert_string robust in the face of null actuals
- Date: Sat, 9 Mar 2019 09:18:15 +0000 (UTC)
commit 4e484e237dd9dab61d39617062d0209d7b93a8f5
Author: Michael Gratton <mike vee net>
Date: Sat Mar 9 19:57:16 2019 +1100
Make TestCase.assert_string robust in the face of null actuals
test/test-case.vala | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/test/test-case.vala b/test/test-case.vala
index bb684967..ef4228ec 100644
--- a/test/test-case.vala
+++ b/test/test-case.vala
@@ -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();
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]