diff options
author | David Beck <david.beck@arm.com> | 2018-10-04 15:43:17 +0100 |
---|---|---|
committer | Matthew Bentham <matthew.bentham@arm.com> | 2018-10-10 16:16:58 +0100 |
commit | 5eec11db435a94ba5046ba74edc5c9c412a64e9d (patch) | |
tree | 6a3d9b9126ae449fc5e83838b2eb1765a67d6aad /src/armnn/test/OptionalTest.cpp | |
parent | d806792f7fbdae2cfa8dcb1eb59b9400b84741da (diff) | |
download | armnn-5eec11db435a94ba5046ba74edc5c9c412a64e9d.tar.gz |
IVGCVSW-1964 : replace optional biases with home-grown Optional
!android-nn-driver:151788
Change-Id: Ibdc41d09b8df05e7a0360dcb8a060860dfb1bd99
Diffstat (limited to 'src/armnn/test/OptionalTest.cpp')
-rw-r--r-- | src/armnn/test/OptionalTest.cpp | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/src/armnn/test/OptionalTest.cpp b/src/armnn/test/OptionalTest.cpp new file mode 100644 index 0000000000..1b5aaa7db6 --- /dev/null +++ b/src/armnn/test/OptionalTest.cpp @@ -0,0 +1,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() |