[libcamera-devel] [PATCH RFC 2/2] test: Provide TestStatus validation tests

Kieran Bingham kieran.bingham at ideasonboard.com
Mon Jan 14 10:54:17 CET 2019


Validate the return values of the objects, and the ability to use "is"
and "isnt()" correctly.

Signed-off-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
---
 test/meson.build     |  1 +
 test/test_status.cpp | 52 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 53 insertions(+)
 create mode 100644 test/test_status.cpp

diff --git a/test/meson.build b/test/meson.build
index 32152888a55e..ae5bd7b47b3b 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -6,6 +6,7 @@ public_tests = [
     ['event',           'event.cpp'],
     ['list-cameras',    'list-cameras.cpp'],
     ['signal',          'signal.cpp'],
+    ['test_status',     'test_status.cpp'],
     ['timer',           'timer.cpp'],
 ]
 
diff --git a/test/test_status.cpp b/test/test_status.cpp
new file mode 100644
index 000000000000..297cc5189f49
--- /dev/null
+++ b/test/test_status.cpp
@@ -0,0 +1,52 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (C) 2018, Google Inc.
+ *
+ * list.cpp - camera list tests
+ */
+
+#include <iostream>
+#include <string>
+
+#include "test.h"
+
+class TestStatusTest : public Test
+{
+protected:
+	int run()
+	{
+		// plan(8);
+		// note("Correct output here is 1 skip, and three failures");
+
+		/*
+		 * TestStatusPass should return 0.
+		 * Test without operator=
+		 */
+		if (TestStatusPass("[Verify TestStatusPass]"))
+			return TestStatusFail("TestStatusPass test");
+
+		/* Test an integer on the rhs. */
+		if (TestStatusFail("[Verify TestStatusFail]") != -1)
+			return TestStatusFail("TestStatusFail test");
+
+		/* Test an integer on the lhs. */
+		if (77 != TestStatusSkip("[Verify TestStatusSkip]"))
+			return TestStatusFail("TestStatusSkip test");
+
+		if (is(1, 1, "[Good is return check]") != TestStatusBase::ValuePass)
+			return TestStatusFail("Good is check failed");
+
+		if (isnt(1, 0, "[Good isn't return check]") != TestStatusBase::ValuePass)
+			return TestStatusFail("Good isn't check failed");
+
+		if (is(1, 0, "[Bad Is Check]") == TestStatusBase::ValuePass)
+			return TestStatusFail("Bad is check failed");
+
+		if (isnt(1, 1, "[Bad Isn't check]") == TestStatusBase::ValuePass)
+			return TestStatusFail("Bad isn't check failed");
+
+		return TestStatusPass("TestStatus validations");
+	}
+};
+
+TEST_REGISTER(TestStatusTest)
-- 
2.17.1



More information about the libcamera-devel mailing list