This is an automated email from the ASF dual-hosted git repository.

amc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new c75c654  Add member initialization to the Errata class. (#7132)
c75c654 is described below

commit c75c6549fb0c64d04c36ffdfd9dae37c2111c5b3
Author: Damian Meden <[email protected]>
AuthorDate: Fri Aug 21 17:01:55 2020 +0100

    Add member initialization to the Errata class. (#7132)
    
    Co-authored-by: Damian Meden <[email protected]>
---
 include/tscore/Errata.h              |  4 +--
 src/tscore/Makefile.am               |  3 +-
 src/tscore/unit_tests/test_Errata.cc | 60 ++++++++++++++++++++++++++++++++++++
 3 files changed, 64 insertions(+), 3 deletions(-)

diff --git a/include/tscore/Errata.h b/include/tscore/Errata.h
index b28a291..758d218 100644
--- a/include/tscore/Errata.h
+++ b/include/tscore/Errata.h
@@ -728,8 +728,8 @@ MakeRv(R const &r,     ///< The function result
 /* ----------------------------------------------------------------------- */
 // Inline methods.
 inline Errata::Message::Message(std::string const &text) : m_text(text) {}
-inline Errata::Message::Message(Id id, std::string const &text) : m_text(text) 
{}
-inline Errata::Message::Message(Id id, Code code, std::string const &text) : 
m_text(text) {}
+inline Errata::Message::Message(Id id, std::string const &text) : m_id(id), 
m_text(text) {}
+inline Errata::Message::Message(Id id, Code code, std::string const &text) : 
m_id(id), m_code(code), m_text(text) {}
 template <typename... Args>
 Errata::Message::Message(Id id, Code code, Args const &... text) : m_id(id), 
m_code(code), m_text(stringify(text...))
 {
diff --git a/src/tscore/Makefile.am b/src/tscore/Makefile.am
index 76cd274..ed6788e 100644
--- a/src/tscore/Makefile.am
+++ b/src/tscore/Makefile.am
@@ -185,7 +185,8 @@ test_tscore_SOURCES = \
        unit_tests/test_scoped_resource.cc \
        unit_tests/test_Tokenizer.cc \
        unit_tests/test_ts_file.cc \
-       unit_tests/test_Version.cc
+       unit_tests/test_Version.cc \
+       unit_tests/test_Errata.cc
 
 if HAS_HKDF
 test_tscore_SOURCES += \
diff --git a/src/tscore/unit_tests/test_Errata.cc 
b/src/tscore/unit_tests/test_Errata.cc
new file mode 100644
index 0000000..a234f77
--- /dev/null
+++ b/src/tscore/unit_tests/test_Errata.cc
@@ -0,0 +1,60 @@
+/**
+  @file Test for Errata
+
+  @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 "catch.hpp"
+
+#include "tscore/Errata.h"
+
+TEST_CASE("Basic Errata with text only", "[errata]")
+{
+  ts::Errata err;
+  std::string text{"Some error text"};
+  err.push(text);
+  REQUIRE(err.isOK()); // as code is 0 by default.
+  REQUIRE(err.top().text() == text);
+}
+
+TEST_CASE("Basic Errata test with id and text", "[errata]")
+{
+  ts::Errata err;
+  int id{1};
+  std::string text{"Some error text"};
+
+  err.push(id, text);
+
+  REQUIRE(err.isOK()); // as code is 0 by default.
+  REQUIRE(err.top().text() == text);
+}
+
+TEST_CASE("Basic Errata test with id,code and text", "[errata]")
+{
+  ts::Errata err;
+  int id{1};
+  int code{2};
+  std::string text{"Some error text"};
+
+  err.push(id, code, text);
+
+  REQUIRE(!err.isOK()); // This should not be ok as code now is 2
+  REQUIRE(err.top().getCode() == code);
+  REQUIRE(err.top().text() == text);
+}

Reply via email to