Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/tscore/Errata.h
Original file line number Diff line number Diff line change
Expand Up @@ -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...))
{
Expand Down
3 changes: 2 additions & 1 deletion src/tscore/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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 += \
Expand Down
60 changes: 60 additions & 0 deletions src/tscore/unit_tests/test_Errata.cc
Original file line number Diff line number Diff line change
@@ -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);
}