From e2d611e4502fb5dce8b8a398ccfc8d7ef29da96b Mon Sep 17 00:00:00 2001 From: Mike Kelly Date: Thu, 14 Oct 2021 12:35:58 +0100 Subject: IVGCVSW-6428 Remove asserts * Changed asserts to check for errors and return appropriate values or throw exceptions * Changed unit tests to use Doctest's long macro names as the short macro names clashed with Android's Logging macros * Removed unused #includes * Clarified ambiguous #includes Signed-off-by: Mike Kelly Change-Id: Ice92a37590df727fd581d3be5ff2716665f26a13 --- test/UtilsTests.cpp | 43 +++++++++++++++++++------------------------ 1 file changed, 19 insertions(+), 24 deletions(-) (limited to 'test/UtilsTests.cpp') diff --git a/test/UtilsTests.cpp b/test/UtilsTests.cpp index fcb0c4f5..c2d8bb4a 100644 --- a/test/UtilsTests.cpp +++ b/test/UtilsTests.cpp @@ -1,24 +1,19 @@ // -// Copyright © 2017 Arm Ltd. All rights reserved. +// Copyright © 2017 Arm Ltd and Contributors. All rights reserved. // SPDX-License-Identifier: MIT // #include "DriverTestHelpers.hpp" #include -#include "../Utils.hpp" #include #include -#include #include #include -#include "armnn/NetworkFwd.hpp" #include -#include - using namespace android; using namespace android::nn; using namespace android::hardware; @@ -147,10 +142,10 @@ private: } // namespace -TEST_SUITE("UtilsTests") +DOCTEST_TEST_SUITE("UtilsTests") { -TEST_CASE("ExportToEmptyDirectory") +DOCTEST_TEST_CASE("ExportToEmptyDirectory") { // Set the fixture for this test. ExportNetworkGraphFixture fixture(""); @@ -170,10 +165,10 @@ TEST_CASE("ExportToEmptyDirectory") fixture.m_RequestInputsAndOutputsDumpDir); // Check that the output file does not exist. - CHECK(!fixture.FileExists()); + DOCTEST_CHECK(!fixture.FileExists()); } -TEST_CASE("ExportNetwork") +DOCTEST_TEST_CASE("ExportNetwork") { // Set the fixture for this test. ExportNetworkGraphFixture fixture; @@ -194,13 +189,13 @@ TEST_CASE("ExportNetwork") fixture.m_RequestInputsAndOutputsDumpDir); // Check that the output file exists and that it has the correct name. - CHECK(fixture.FileExists()); + DOCTEST_CHECK(fixture.FileExists()); // Check that the content of the output file matches the mock content. - CHECK(fixture.GetFileContent() == mockSerializedContent); + DOCTEST_CHECK(fixture.GetFileContent() == mockSerializedContent); } -TEST_CASE("ExportNetworkOverwriteFile") +DOCTEST_TEST_CASE("ExportNetworkOverwriteFile") { // Set the fixture for this test. ExportNetworkGraphFixture fixture; @@ -220,10 +215,10 @@ TEST_CASE("ExportNetworkOverwriteFile") fixture.m_RequestInputsAndOutputsDumpDir); // Check that the output file exists and that it has the correct name. - CHECK(fixture.FileExists()); + DOCTEST_CHECK(fixture.FileExists()); // Check that the content of the output file matches the mock content. - CHECK(fixture.GetFileContent() == mockSerializedContent); + DOCTEST_CHECK(fixture.GetFileContent() == mockSerializedContent); // Update the mock serialized content of the network. mockSerializedContent = "This is ANOTHER mock serialized content!"; @@ -238,13 +233,13 @@ TEST_CASE("ExportNetworkOverwriteFile") fixture.m_RequestInputsAndOutputsDumpDir); // Check that the output file still exists and that it has the correct name. - CHECK(fixture.FileExists()); + DOCTEST_CHECK(fixture.FileExists()); // Check that the content of the output file matches the mock content. - CHECK(fixture.GetFileContent() == mockSerializedContent); + DOCTEST_CHECK(fixture.GetFileContent() == mockSerializedContent); } -TEST_CASE("ExportMultipleNetworks") +DOCTEST_TEST_CASE("ExportMultipleNetworks") { // Set the fixtures for this test. ExportNetworkGraphFixture fixture1; @@ -266,29 +261,29 @@ TEST_CASE("ExportMultipleNetworks") fixture1.m_RequestInputsAndOutputsDumpDir); // Check that the output file exists and that it has the correct name. - CHECK(fixture1.FileExists()); + DOCTEST_CHECK(fixture1.FileExists()); // Check that the content of the output file matches the mock content. - CHECK(fixture1.GetFileContent() == mockSerializedContent); + DOCTEST_CHECK(fixture1.GetFileContent() == mockSerializedContent); // Export the mock optimized network. fixture2.m_FileName = armnn_driver::ExportNetworkGraphToDotFile(mockOptimizedNetwork, fixture2.m_RequestInputsAndOutputsDumpDir); // Check that the output file exists and that it has the correct name. - CHECK(fixture2.FileExists()); + DOCTEST_CHECK(fixture2.FileExists()); // Check that the content of the output file matches the mock content. - CHECK(fixture2.GetFileContent() == mockSerializedContent); + DOCTEST_CHECK(fixture2.GetFileContent() == mockSerializedContent); // Export the mock optimized network. fixture3.m_FileName = armnn_driver::ExportNetworkGraphToDotFile(mockOptimizedNetwork, fixture3.m_RequestInputsAndOutputsDumpDir); // Check that the output file exists and that it has the correct name. - CHECK(fixture3.FileExists()); + DOCTEST_CHECK(fixture3.FileExists()); // Check that the content of the output file matches the mock content. - CHECK(fixture3.GetFileContent() == mockSerializedContent); + DOCTEST_CHECK(fixture3.GetFileContent() == mockSerializedContent); } } -- cgit v1.2.1