scsl/include/sctest/Assert.h

61 lines
1.9 KiB
C
Raw Normal View History

///
/// \file Test.h
/// \author K. Isom <kyle@imap.cc>
/// \date 2023-10-09
/// \brief Tooling to assist in building test programs..
///
/// Copyright 2023 K. Isom <kyle@imap.cc>
///
/// Permission to use, copy, modify, and/or distribute this software for
/// any purpose with or without fee is hereby granted, provided that
/// the above copyright notice and this permission notice appear in all /// copies.
///
/// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
/// WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
/// WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
/// AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
/// DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA
/// OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
/// TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
/// PERFORMANCE OF THIS SOFTWARE.
///
2023-10-15 01:38:01 +00:00
#ifndef SCSL_TEST_H
#define SCSL_TEST_H
2023-10-10 02:59:21 +00:00
#include <string>
2023-10-10 02:59:21 +00:00
2023-10-19 07:37:56 +00:00
namespace sctest {
2023-10-10 02:59:21 +00:00
2023-10-19 07:37:56 +00:00
/// Assert is a variant on the assert macro. This variant is intended to be
2023-10-11 01:57:43 +00:00
/// a drop-in replacement for the cassert macro: even in release mode, the tests
/// should still run.
///
2023-10-19 07:37:56 +00:00
/// If NDEBUG is set, Assert will throw an exception if condition is false.
2023-10-11 01:57:43 +00:00
/// Otherwise, it calls assert after printing the message.
///
2023-10-19 07:37:56 +00:00
/// \param condition If true, Assert throws an exception.
void Assert(bool condition);
2023-10-11 01:57:43 +00:00
2023-10-19 07:37:56 +00:00
/// Assert is a variant on the assert macro.
///
2023-10-19 07:37:56 +00:00
/// If NDEBUG is set, Assert will throw an exception if condition is false.
/// Otherwise, it calls assert after printing the message.
///
2023-10-16 00:09:31 +00:00
/// In addition to NDEBUG, SCSL_NOEXCEPT will suppress assertions.
///
/// \throws AssertionFailed
///
/// \param condition The condition to assert.
/// \param message The message that should be displayed if condition is false.
2023-10-19 07:37:56 +00:00
void Assert(bool condition, std::string message);
2023-10-10 02:59:21 +00:00
2023-10-15 01:38:01 +00:00
} // namespace scsl
2023-10-10 02:59:21 +00:00
2023-10-15 01:38:01 +00:00
#endif //SCSL_TEST_H