aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJan Eilers <jan.eilers@arm.com>2021-10-26 16:57:34 +0100
committerJan Eilers <jan.eilers@arm.com>2021-11-02 11:49:32 +0000
commitf39f8d8597c59057118f67cacf70d246f95fea9b (patch)
tree35c6f5b1b641a143d29e1ce478877f9e2b251569 /src
parent32c7527df494a99a97283fe09580671e10f8d398 (diff)
downloadarmnn-f39f8d8597c59057118f67cacf70d246f95fea9b.tar.gz
Move command line parsing in external delegate to DelegateOptions
* Moves the creation of a DelegateOption object from armnn_external_delegate to DelegateOptions. * This allows this code to be reused elsewhere * Allow boolean values of DelegateOptions to be passed as strings e.g. 'true' or 'false' * Add unit tests Signed-off-by: Jan Eilers <jan.eilers@arm.com> Change-Id: I0ada17f511027dd3f47a85142cae346464682f5a
Diffstat (limited to 'src')
-rw-r--r--src/armnn/test/UtilityTests.cpp29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/armnn/test/UtilityTests.cpp b/src/armnn/test/UtilityTests.cpp
index 7911fd2608..fba0dd9d52 100644
--- a/src/armnn/test/UtilityTests.cpp
+++ b/src/armnn/test/UtilityTests.cpp
@@ -3,16 +3,17 @@
// SPDX-License-Identifier: MIT
//
-#include <doctest/doctest.h>
#define ARMNN_POLYMORPHIC_CAST_TESTABLE
#define ARMNN_NUMERIC_CAST_TESTABLE
+#include <armnn/Exceptions.hpp>
#include <armnn/utility/IgnoreUnused.hpp>
#include <armnn/utility/PolymorphicDowncast.hpp>
#include <armnn/utility/NumericCast.hpp>
+#include <armnn/utility/StringUtils.hpp>
-#include <armnn/Exceptions.hpp>
+#include <doctest/doctest.h>
#include <limits>
@@ -250,4 +251,28 @@ TEST_CASE("NumericCast")
}
+TEST_CASE("StringToBool")
+ {
+ CHECK(true == armnn::stringUtils::StringToBool("1"));
+ CHECK(false == armnn::stringUtils::StringToBool("0"));
+ // Any number larger than 1 will be a failure.
+ CHECK_THROWS_AS(armnn::stringUtils::StringToBool("2"), armnn::InvalidArgumentException);
+ CHECK_THROWS_AS(armnn::stringUtils::StringToBool("23456567"), armnn::InvalidArgumentException);
+ CHECK_THROWS_AS(armnn::stringUtils::StringToBool("-23456567"), armnn::InvalidArgumentException);
+ CHECK_THROWS_AS(armnn::stringUtils::StringToBool("Not a number"), armnn::InvalidArgumentException);
+ // Empty string should be a failure.
+ CHECK_THROWS_AS(armnn::stringUtils::StringToBool(""), armnn::InvalidArgumentException);
+ CHECK(true == armnn::stringUtils::StringToBool("true"));
+ CHECK(false == armnn::stringUtils::StringToBool("false"));
+ // Should be case agnostic.
+ CHECK(true == armnn::stringUtils::StringToBool("TrUe"));
+ CHECK(false == armnn::stringUtils::StringToBool("fAlSe"));
+
+ // Same negative test cases with throw_on_error set to false.
+ CHECK(false == armnn::stringUtils::StringToBool("2", false));
+ CHECK(false == armnn::stringUtils::StringToBool("23456567", false));
+ CHECK(false == armnn::stringUtils::StringToBool("-23456567", false));
+ CHECK(false == armnn::stringUtils::StringToBool("Not a number", false));
+ CHECK(false == armnn::stringUtils::StringToBool("", false));
+ }
}