From 79fbecea456ccf05a76e23ee9bf61b5b057950c9 Mon Sep 17 00:00:00 2001
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Date: Sun, 1 Mar 2020 20:44:01 +0200
Subject: test: controls: control_value: Test string control type

Add test cases for the string control type. As strings are implemented
as char arrays, arrays of strings are not supported.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
---
 test/controls/control_value.cpp | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/test/controls/control_value.cpp b/test/controls/control_value.cpp
index a7ebf60f..ad8e05d0 100644
--- a/test/controls/control_value.cpp
+++ b/test/controls/control_value.cpp
@@ -235,6 +235,28 @@ protected:
 			return TestFail;
 		}
 
+		/*
+		 * String type.
+		 */
+		std::string string{ "libcamera" };
+		value.set(string);
+		if (value.isNone() || !value.isArray() ||
+		    value.type() != ControlTypeString ||
+		    value.numElements() != string.size()) {
+			cerr << "Control type mismatch after setting to string" << endl;
+			return TestFail;
+		}
+
+		if (value.get<std::string>() != string) {
+			cerr << "Control value mismatch after setting to string" << endl;
+			return TestFail;
+		}
+
+		if (value.toString() != string) {
+			cerr << "Control string mismatch after setting to string" << endl;
+			return TestFail;
+		}
+
 		return TestPass;
 	}
 };
-- 
cgit v1.2.1