DryChem 1.0.0
A generic, compile-time C++ toolbox with no dependencies for the modern computational chemistry project.
Loading...
Searching...
No Matches
testErrorTypes.hpp
Go to the documentation of this file.
1// Copyright (c) 2020-2025 Cody R. Drisko. All rights reserved.
2// Licensed under the MIT License. See the LICENSE file in the project root for more information.
3//
4// Name: testErrorTypes.hpp
5// Author: crdrisko
6// Date: 08/26/2020-15:02:42
7// Description: Provides ~100% unit test coverage over all error types and associated functions
8
9#ifndef DRYCHEM_COMMON_UTILITIES_LIBS_ERRORS_TESTS_TESTUTILITIES_TESTERRORTYPES_HPP
10#define DRYCHEM_COMMON_UTILITIES_LIBS_ERRORS_TESTS_TESTUTILITIES_TESTERRORTYPES_HPP
11
13#include <gtest/gtest.h>
14
15GTEST_TEST(testErrorTypes, errorSeveritiesConvertToCorrectValues)
16{
17 ASSERT_FALSE(static_cast<bool>(DryChem::ErrorSeverity::Warning));
18 ASSERT_TRUE(static_cast<bool>(DryChem::ErrorSeverity::Fatal));
19
20 ASSERT_TRUE(static_cast<int>(DryChem::ErrorSeverity::Warning) == 0);
21 ASSERT_TRUE(static_cast<int>(DryChem::ErrorSeverity::Fatal) == 1);
22}
23
24GTEST_TEST(testErrorTypes, errorMessagesCanBeSetByIndividualValues)
25{
26 DryChem::ErrorMessage err {};
27
28 ASSERT_TRUE(err.programName.empty() && err.message.empty() && err.fileName.empty() && err.lineNumber == 0ul);
29
30 err.programName = "Common-Utilities";
31 err.message = "This is the error message.";
32 err.fileName = __FILE__;
33 err.lineNumber = __LINE__;
34
35 ASSERT_EQ("Common-Utilities", err.programName);
36 ASSERT_EQ("This is the error message.", err.message);
37 ASSERT_EQ("testErrorTypes.hpp", err.fileName.substr(err.fileName.find_last_of('/') + 1, err.fileName.length()));
38 ASSERT_EQ(33ul, err.lineNumber);
39}
40
41GTEST_TEST(testErrorTypes, errorMessagesCanBeSetByConstructor)
42{
43 DryChem::ErrorMessage err {"Common-Utilities", "This is the error message.", __FILE__, __LINE__};
44
45 ASSERT_EQ("Common-Utilities", err.programName);
46 ASSERT_EQ("This is the error message.", err.message);
47 ASSERT_EQ("testErrorTypes.hpp", err.fileName.substr(err.fileName.find_last_of('/') + 1, err.fileName.length()));
48 ASSERT_EQ(43ul, err.lineNumber);
49}
50
51#endif
GTEST_TEST(testErrorTypes, errorSeveritiesConvertToCorrectValues)
Definition testErrorTypes.hpp:15