Message ID | 20200309162414.720306-5-jacopo@jmondi.org |
---|---|
State | Accepted |
Headers | show |
Series |
|
Related | show |
Hi Laurent, On Mon, Mar 09, 2020 at 05:24:07PM +0100, Jacopo Mondi wrote: > From: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > > 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> Thanks j > --- > 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 a7ebf60f6a6a..ad8e05d0b1a9 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; > } > }; > -- > 2.25.0 > > _______________________________________________ > libcamera-devel mailing list > libcamera-devel@lists.libcamera.org > https://lists.libcamera.org/listinfo/libcamera-devel
diff --git a/test/controls/control_value.cpp b/test/controls/control_value.cpp index a7ebf60f6a6a..ad8e05d0b1a9 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; } };