Add unit tests for Error class

This commit is contained in:
Luis Diaz 2022-03-10 20:56:07 +01:00
parent 7119b7676f
commit 65568b056e
2 changed files with 23 additions and 0 deletions

View File

@ -6,6 +6,7 @@ add_executable(unit_tests
test_bmpimage.cpp
test_cr2header_int.cpp
test_datasets.cpp
test_Error.cpp
test_DateValue.cpp
test_enforce.cpp
test_FileIo.cpp

22
unitTests/test_Error.cpp Normal file
View File

@ -0,0 +1,22 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#include <exiv2/error.hpp>
#include <gtest/gtest.h>
using namespace Exiv2;
TEST(Error, parameterInsertion)
{
const Error err_with_3_params(ErrorCode::kerGeneralError, "foo", "bar", "baz");
ASSERT_STREQ(err_with_3_params.what(), "Error 1: arg2=bar, arg3=baz, arg1=foo.");
const Error err_with_no_params(ErrorCode::kerSuccess);
ASSERT_STREQ(err_with_no_params.what(), "Success");
}
TEST(Error, tooManyParameters)
{
const Error err_with_no_params(ErrorCode::kerSuccess, "a param", "another param");
ASSERT_STREQ(err_with_no_params.what(), "Success");
}