This is an automated email from the ASF dual-hosted git repository. bneradt pushed a commit to branch errata-consolidation in repository https://gitbox.apache.org/repos/asf/trafficserver-libswoc.git
commit 4e11a5407b348d3ee2d76268bd1b6f02f4c541a0 Author: Alan M. Carroll <a...@apache.org> AuthorDate: Fri Sep 17 16:11:09 2021 -0500 Errata: additional cleanup. --- unit_tests/ex_Errata_Severity.h | 28 ---------------------------- unit_tests/ex_UnitParser.cc | 1 - unit_tests/test_Errata.cc | 18 ++++++++++++++++-- unit_tests/unit_test_main.cc | 14 +++----------- 4 files changed, 19 insertions(+), 42 deletions(-) diff --git a/unit_tests/ex_Errata_Severity.h b/unit_tests/ex_Errata_Severity.h deleted file mode 100644 index 1e7d5e2..0000000 --- a/unit_tests/ex_Errata_Severity.h +++ /dev/null @@ -1,28 +0,0 @@ -/** @file - - Errata initialization for testing. - Useful as an examle. - - @section license License - - Licensed to the Apache Software Foundation (ASF) under one or more contributor license - agreements. See the NOTICE file distributed with this work for additional information regarding - copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with the License. You may - obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software distributed under the - License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either - express or implied. See the License for the specific language governing permissions and - limitations under the License. -*/ - -#include "swoc/Errata.h" - -static constexpr swoc::Errata::Severity ERRATA_DBG{0}; -static constexpr swoc::Errata::Severity ERRATA_DIAG{1}; -static constexpr swoc::Errata::Severity ERRATA_INFO{2}; -static constexpr swoc::Errata::Severity ERRATA_WARN{3}; -static constexpr swoc::Errata::Severity ERRATA_ERROR{4}; diff --git a/unit_tests/ex_UnitParser.cc b/unit_tests/ex_UnitParser.cc index fc80a0b..5b0a98f 100644 --- a/unit_tests/ex_UnitParser.cc +++ b/unit_tests/ex_UnitParser.cc @@ -10,7 +10,6 @@ #include "swoc/Lexicon.h" #include "swoc/Errata.h" -#include "ex_Errata_Severity.h" #include "catch.hpp" using swoc::TextView; diff --git a/unit_tests/test_Errata.cc b/unit_tests/test_Errata.cc index 47e2ce5..9442a31 100644 --- a/unit_tests/test_Errata.cc +++ b/unit_tests/test_Errata.cc @@ -8,7 +8,6 @@ #include <errno.h> #include "swoc/Errata.h" #include "swoc/swoc_file.h" -#include "ex_Errata_Severity.h" #include "catch.hpp" using swoc::Errata; @@ -17,7 +16,22 @@ using Severity = swoc::Errata::Severity; using namespace std::literals; using namespace swoc::literals; -// Note - Some of these tests depend on initialization done in "unit_test_main.cc". +static constexpr swoc::Errata::Severity ERRATA_DBG{0}; +static constexpr swoc::Errata::Severity ERRATA_DIAG{1}; +static constexpr swoc::Errata::Severity ERRATA_INFO{2}; +static constexpr swoc::Errata::Severity ERRATA_WARN{3}; +static constexpr swoc::Errata::Severity ERRATA_ERROR{4}; + +std::array<swoc::TextView, 5> Severity_Names { { + "Debug", "Diag", "Info", "Warn", "Error" +}}; + +// Call from unit test main before starting tests. +void test_Errata_init() { + swoc::Errata::DEFAULT_SEVERITY = ERRATA_ERROR; + swoc::Errata::FAILURE_SEVERITY = ERRATA_WARN; + swoc::Errata::SEVERITY_NAMES = swoc::MemSpan<swoc::TextView>(Severity_Names.data(), Severity_Names.size()); +} Errata Noteworthy(std::string_view text) diff --git a/unit_tests/unit_test_main.cc b/unit_tests/unit_test_main.cc index e82bc96..f282566 100644 --- a/unit_tests/unit_test_main.cc +++ b/unit_tests/unit_test_main.cc @@ -25,22 +25,14 @@ #include <array> -#include "ex_Errata_Severity.h" - -std::array<swoc::TextView, 5> Severity_Names { { - "Debug", "Diag", "Info", "Warn", "Error" -}}; - -void EX_BWF_Format_Init(); +extern void EX_BWF_Format_Init(); +extern void test_Errata_init(); int main(int argc, char *argv[]) { EX_BWF_Format_Init(); - - swoc::Errata::DEFAULT_SEVERITY = ERRATA_ERROR; - swoc::Errata::FAILURE_SEVERITY = ERRATA_WARN; - swoc::Errata::SEVERITY_NAMES = swoc::MemSpan<swoc::TextView>(Severity_Names.data(), Severity_Names.size()); + test_Errata_init(); int result = Catch::Session().run(argc, argv);