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>
This commit is contained in:
Laurent Pinchart 2020-03-01 20:44:01 +02:00
parent 4e3f835126
commit 79fbecea45

View file

@ -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;
}
};