blob: 1b5aaa7db6a73a47bfdb355b5e09c7006662538e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
//
// Copyright © 2017 Arm Ltd. All rights reserved.
// SPDX-License-Identifier: MIT
//
#include <boost/test/unit_test.hpp>
#include <armnn/Optional.hpp>
#include <string>
BOOST_AUTO_TEST_SUITE(OptionalTests)
BOOST_AUTO_TEST_CASE(SimpleStringTests)
{
armnn::Optional<std::string> optionalString;
BOOST_TEST(optionalString == false);
BOOST_TEST(optionalString.has_value() == false);
optionalString = std::string("Hello World");
BOOST_TEST(optionalString == true);
BOOST_TEST(optionalString.has_value() == true);
BOOST_TEST(optionalString.value() == "Hello World");
armnn::Optional<std::string> otherString;
otherString = optionalString;
BOOST_TEST(otherString == true);
BOOST_TEST(otherString.value() == "Hello World");
optionalString.reset();
BOOST_TEST(optionalString == false);
BOOST_TEST(optionalString.has_value() == false);
const std::string stringValue("Hello World");
armnn::Optional<std::string> optionalString2(stringValue);
BOOST_TEST(optionalString2 == true);
BOOST_TEST(optionalString2.has_value() == true);
BOOST_TEST(optionalString2.value() == "Hello World");
armnn::Optional<std::string> optionalString3(std::move(optionalString2));
BOOST_TEST(optionalString3 == true);
BOOST_TEST(optionalString3.has_value() == true);
BOOST_TEST(optionalString3.value() == "Hello World");
}
BOOST_AUTO_TEST_CASE(SimpleIntTests)
{
const int intValue = 123;
armnn::Optional<int> optionalInt;
BOOST_TEST(optionalInt == false);
BOOST_TEST(optionalInt.has_value() == false);
optionalInt = intValue;
BOOST_TEST(optionalInt == true);
BOOST_TEST(optionalInt.has_value() == true);
BOOST_TEST(optionalInt.value() == intValue);
armnn::Optional<int> otherOptionalInt;
otherOptionalInt = optionalInt;
BOOST_TEST(otherOptionalInt == true);
BOOST_TEST(otherOptionalInt.value() == intValue);
}
BOOST_AUTO_TEST_SUITE_END()
|