From 6ea5e431685595c8aceb63e3395adefb95931184 Mon Sep 17 00:00:00 2001 From: Michael Gratton Date: Fri, 3 Jul 2020 18:08:39 +1000 Subject: [PATCH] vala-unit: Minor test fixups --- .../vala-unit/src/test-assertions.vala | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/subprojects/vala-unit/src/test-assertions.vala b/subprojects/vala-unit/src/test-assertions.vala index b1478601..784dd9fd 100644 --- a/subprojects/vala-unit/src/test-assertions.vala +++ b/subprojects/vala-unit/src/test-assertions.vala @@ -194,7 +194,7 @@ namespace ValaUnit { private void assert_equal_enum(T actual, T expected, string? context) - throws TestError { + throws TestError { int actual_val = (int) ((int?) actual); int expected_val = (int) ((int?) expected); if (actual_val != expected_val) { @@ -203,8 +203,8 @@ namespace ValaUnit { } private void assert_equal_string(string? actual, - string? expected, - string? context) + string? expected, + string? context) throws TestError { string actual_val = (string) actual; string expected_val = (string) expected; @@ -353,7 +353,7 @@ public interface ValaUnit.TestAssertions : GLib.Object { } /** Asserts a value is null */ - public void assert_null(T actual, string? context = null) + public void assert_is_null(T actual, string? context = null) throws TestError { if (actual != null) { ValaUnit.assert( @@ -419,6 +419,17 @@ public interface ValaUnit.TestAssertions : GLib.Object { return new ArrayCollectionAssertion((E[]) actual, context); } + /** Asserts an array is null */ + public void assert_array_is_null(T[]? actual, string? context = null) + throws TestError { + if (actual != null) { + ValaUnit.assert( + "%s is non-null, expected null".printf(typeof(T).name()), + context + ); + } + } + /** Asserts a collection is non-null and empty. */ public CollectionAssertions assert_collection( Gee.Collection? actual, @@ -522,6 +533,12 @@ public interface ValaUnit.TestAssertions : GLib.Object { assert_true(actual, context); } + /** Asserts a value is null. */ + public void assert_null(T actual, string? context = null) + throws TestError { + assert_is_null(actual, context); + } + /** * Asserts this call is never made. */