From 6940dd720ebb6b3d1df8ca203ab696daefe58189 Mon Sep 17 00:00:00 2001 From: Jim Flynn Date: Fri, 20 Mar 2020 12:25:56 +0000 Subject: renamed Documentation folder 20.02 and added .nojekyll file Signed-off-by: Jim Flynn --- 20.02/_utility_tests_8cpp.xhtml | 222 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 222 insertions(+) create mode 100644 20.02/_utility_tests_8cpp.xhtml (limited to '20.02/_utility_tests_8cpp.xhtml') diff --git a/20.02/_utility_tests_8cpp.xhtml b/20.02/_utility_tests_8cpp.xhtml new file mode 100644 index 0000000000..498a114208 --- /dev/null +++ b/20.02/_utility_tests_8cpp.xhtml @@ -0,0 +1,222 @@ + + + + + + + + + + + + + +ArmNN: src/armnn/test/UtilityTests.cpp File Reference + + + + + + + + + + + + + + + + +
+
+ + + + ArmNN + + + +
+
+  20.02 +
+
+
+ + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+ +
+ +
+ +
+
UtilityTests.cpp File Reference
+
+
+
#include <boost/test/unit_test.hpp>
+#include <boost/core/lightweight_test.hpp>
+#include <boost/polymorphic_cast.hpp>
+#include <armnn/utility/IgnoreUnused.hpp>
+#include <armnn/utility/PolymorphicDowncast.hpp>
+#include <armnn/utility/NumericCast.hpp>
+#include <armnn/Exceptions.hpp>
+
+

Go to the source code of this file.

+ + + + + + +

+Macros

#define ARMNN_POLYMORPHIC_CAST_TESTABLE
 
#define ARMNN_NUMERIC_CAST_TESTABLE
 
+ + + + + +

+Functions

 BOOST_AUTO_TEST_CASE (PolymorphicDowncast)
 
 BOOST_AUTO_TEST_CASE (NumericCast)
 
+

Macro Definition Documentation

+ +

◆ ARMNN_NUMERIC_CAST_TESTABLE

+ +
+
+ + + + +
#define ARMNN_NUMERIC_CAST_TESTABLE
+
+ +

Definition at line 11 of file UtilityTests.cpp.

+ +
+
+ +

◆ ARMNN_POLYMORPHIC_CAST_TESTABLE

+ +
+
+ + + + +
#define ARMNN_POLYMORPHIC_CAST_TESTABLE
+
+ +

Definition at line 10 of file UtilityTests.cpp.

+ +
+
+

Function Documentation

+ +

◆ BOOST_AUTO_TEST_CASE() [1/2]

+ +
+
+ + + + + + + + +
BOOST_AUTO_TEST_CASE (PolymorphicDowncast )
+
+ +

Definition at line 22 of file UtilityTests.cpp.

+ +

References BOOST_CHECK(), and armnn::IgnoreUnused().

+
23 {
24  using namespace armnn;
25  class Base
26  {
27  public:
28  virtual ~Base(){}
29  float v;
30  };
31 
32  class Child1 : public Base
33  {
34  public:
35  int j;
36  };
37 
38  class Child2 : public Base
39  {
40  public:
41  char b;
42  };
43 
44  Child1 child1;
45  Base* base1 = &child1;
46  auto ptr1 = dynamic_cast<Child1*>(base1);
47  BOOST_CHECK(ptr1 != nullptr);
48  BOOST_CHECK_NO_THROW(polymorphic_downcast<Child1*>(base1));
49  BOOST_CHECK(polymorphic_downcast<Child1*>(base1) == ptr1);
50 
51  auto ptr2 = dynamic_cast<Child2*>(base1);
52  BOOST_CHECK(ptr2 == nullptr);
53  BOOST_CHECK_THROW(polymorphic_downcast<Child2*>(base1), std::bad_cast);
54 
55  armnn::IgnoreUnused(ptr1, ptr2);
56 }
Copyright (c) 2020 ARM Limited.
+
void IgnoreUnused(Ts &&...)
+
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)
+
+
+
+ +

◆ BOOST_AUTO_TEST_CASE() [2/2]

+ +
+
+ + + + + + + + +
BOOST_AUTO_TEST_CASE (NumericCast )
+
+ +

Definition at line 59 of file UtilityTests.cpp.

+ +

References BOOST_AUTO_TEST_SUITE_END().

+
60 {
61  using namespace armnn;
62 
63  // To 8 bit
64  BOOST_CHECK_THROW(numeric_cast<unsigned char>(-1), std::bad_cast);
65  BOOST_CHECK_THROW(numeric_cast<unsigned char>(1 << 8), std::bad_cast);
66  BOOST_CHECK_THROW(numeric_cast<unsigned char>(1L << 16), std::bad_cast);
67  BOOST_CHECK_THROW(numeric_cast<unsigned char>(1LL << 32), std::bad_cast);
68 
69  BOOST_CHECK_THROW(numeric_cast<signed char>((1L << 8)*-1), std::bad_cast);
70  BOOST_CHECK_THROW(numeric_cast<signed char>((1L << 15)*-1), std::bad_cast);
71  BOOST_CHECK_THROW(numeric_cast<signed char>((1LL << 31)*-1), std::bad_cast);
72 
73  BOOST_CHECK_NO_THROW(numeric_cast<unsigned char>(1U));
74  BOOST_CHECK_NO_THROW(numeric_cast<unsigned char>(1L));
75  BOOST_CHECK_NO_THROW(numeric_cast<signed char>(-1));
76  BOOST_CHECK_NO_THROW(numeric_cast<signed char>(-1L));
77  BOOST_CHECK_NO_THROW(numeric_cast<signed char>((1 << 7)*-1));
78 
79  // To 16 bit
80  BOOST_CHECK_THROW(numeric_cast<uint16_t>(-1), std::bad_cast);
81  BOOST_CHECK_THROW(numeric_cast<uint16_t>(1L << 16), std::bad_cast);
82  BOOST_CHECK_THROW(numeric_cast<uint16_t>(1LL << 32), std::bad_cast);
83 
84  BOOST_CHECK_THROW(numeric_cast<int16_t>(1L << 15), std::bad_cast);
85  BOOST_CHECK_THROW(numeric_cast<int16_t>(1LL << 31), std::bad_cast);
86 
87  BOOST_CHECK_NO_THROW(numeric_cast<uint16_t>(1L << 8));
88  BOOST_CHECK_NO_THROW(numeric_cast<int16_t>(1L << 7));
89  BOOST_CHECK_NO_THROW(numeric_cast<int16_t>((1L << 15)*-1));
90 
91  // To 32 bit
92  BOOST_CHECK_NO_THROW(numeric_cast<uint32_t>(1));
93  BOOST_CHECK_NO_THROW(numeric_cast<uint32_t>(1 << 8));
94  BOOST_CHECK_NO_THROW(numeric_cast<uint32_t>(1L << 16));
95  BOOST_CHECK_NO_THROW(numeric_cast<uint32_t>(1LL << 31));
96 
97  BOOST_CHECK_NO_THROW(numeric_cast<int32_t>(-1));
98  BOOST_CHECK_NO_THROW(numeric_cast<int32_t>((1L << 8)*-1));
99  BOOST_CHECK_NO_THROW(numeric_cast<int32_t>((1L << 16)*-1));
100  BOOST_CHECK_NO_THROW(numeric_cast<int32_t>((1LL << 31)*-1));
101 }
Copyright (c) 2020 ARM Limited.
+
+
+
+
+
+ + + + -- cgit v1.2.1