5 #include <boost/test/unit_test.hpp> 32 BOOST_TEST(static_cast<bool>(optionalString) ==
false);
33 BOOST_TEST(optionalString.
has_value() ==
false);
36 optionalString = std::string(
"Hello World");
37 BOOST_TEST(static_cast<bool>(optionalString) ==
true);
38 BOOST_TEST(optionalString.
has_value() ==
true);
39 BOOST_TEST(optionalString.
value() ==
"Hello World");
43 otherString = optionalString;
44 BOOST_TEST(static_cast<bool>(otherString) ==
true);
45 BOOST_TEST(otherString.
value() ==
"Hello World");
47 optionalString.
reset();
48 BOOST_TEST(static_cast<bool>(optionalString) ==
false);
49 BOOST_TEST(optionalString.
has_value() ==
false);
51 const std::string stringValue(
"Hello World");
53 BOOST_TEST(static_cast<bool>(optionalString2) ==
true);
54 BOOST_TEST(optionalString2.
has_value() ==
true);
55 BOOST_TEST(optionalString2.
value() ==
"Hello World");
58 BOOST_TEST(static_cast<bool>(optionalString3) ==
true);
59 BOOST_TEST(optionalString3.has_value() ==
true);
60 BOOST_TEST(optionalString3.value() ==
"Hello World");
66 BOOST_TEST(optionalStringRef.has_value() ==
false);
68 PassStringRef(optionalStringRef);
69 PassStringRefWithDefault();
73 std::string helloWorld(
"Hello World");
75 std::string& helloWorldRef = helloWorld;
77 BOOST_TEST(optionalHelloRef.
has_value() ==
true);
78 BOOST_TEST(optionalHelloRef.
value() ==
"Hello World");
81 BOOST_TEST(optionalHelloRef2.has_value() ==
true);
82 BOOST_TEST(optionalHelloRef2.value() ==
"Hello World");
85 BOOST_TEST(optionalHelloRef3.has_value() ==
true);
86 BOOST_TEST(optionalHelloRef3.value() ==
"Hello World");
89 BOOST_TEST(optionalHelloRef4.has_value() ==
true);
90 BOOST_TEST(optionalHelloRef4.value() ==
"Hello World");
93 optionalHelloRef4.
value().assign(
"Long Other String");
94 BOOST_TEST(helloWorld ==
"Long Other String");
95 BOOST_TEST(optionalHelloRef.
value() ==
"Long Other String");
96 BOOST_TEST(optionalHelloRef2.value() ==
"Long Other String");
97 BOOST_TEST(optionalHelloRef3.value() ==
"Long Other String");
102 const int intValue = 123;
105 BOOST_TEST(static_cast<bool>(optionalInt) ==
false);
106 BOOST_TEST(optionalInt.
has_value() ==
false);
109 optionalInt = intValue;
110 BOOST_TEST(static_cast<bool>(optionalInt) ==
true);
111 BOOST_TEST(optionalInt.
has_value() ==
true);
112 BOOST_TEST(optionalInt.
value() == intValue);
116 otherOptionalInt = optionalInt;
117 BOOST_TEST(static_cast<bool>(otherOptionalInt) ==
true);
118 BOOST_TEST(otherOptionalInt.
value() == intValue);
126 SimpleObject(
const std::string& name,
int value)
133 return m_Name == other.m_Name &&
134 m_Value == other.m_Value;
142 std::string objectName(
"SimpleObject");
144 SimpleObject referenceObject(objectName, objectValue);
148 BOOST_CHECK(static_cast<bool>(optionalObject1) ==
true);
154 BOOST_CHECK(static_cast<bool>(optionalObject1) ==
true);
BOOST_AUTO_TEST_SUITE(TensorflowLiteParser)
BOOST_AUTO_TEST_CASE(SimpleStringTests)
#define CONSTRUCT_IN_PLACE
void IgnoreUnused(Ts &&...)
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)
bool operator==(const armnn::DataLayout &dataLayout, const DataLayoutIndexed &indexed)
Equality methods.
bool has_value() const noexcept
BOOST_AUTO_TEST_SUITE_END()
EmptyOptional is used to initialize the Optional class in case we want to have default value for an O...