clang-tidy fixes, documentation, refactoring.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
///
|
||||
/// \file Exceptions.h
|
||||
/// \file include/sctest/Exceptions.h
|
||||
/// \author K. Isom <kyle@imap.cc>
|
||||
/// \date 2023-10-10
|
||||
/// \brief Custom exceptions for use in SCSL used in writing test programs.
|
||||
@@ -31,7 +31,7 @@
|
||||
namespace sctest {
|
||||
|
||||
|
||||
/// NotImplemented is an exception reserved for unsupported platforms.
|
||||
/// \brief Exception reserved for unsupported platforms.
|
||||
///
|
||||
/// It is used to mark functionality included for compatibility, and useful for
|
||||
/// debugging.
|
||||
|
||||
@@ -1,26 +1,25 @@
|
||||
//
|
||||
// Project: scccl
|
||||
// File: include/test/Report.h
|
||||
// Author: Kyle Isom
|
||||
// Date: 2017-06-05
|
||||
// Namespace: test
|
||||
//
|
||||
// Report.h defines a Report structure that contains information about
|
||||
// the results of unit tests.
|
||||
//
|
||||
// Copyright 2017 Kyle Isom <kyle@imap.cc>
|
||||
//
|
||||
// Licensed 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.
|
||||
///
|
||||
/// \file include/sctest/Report.h
|
||||
/// \author K. Isom <kyle@imap.cc>
|
||||
/// \date 2017-06-05
|
||||
/// \brief Unit test reporting class.
|
||||
///
|
||||
/// Copyright 2017 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.
|
||||
///
|
||||
|
||||
#ifndef SCTEST_REPORT_H
|
||||
#define SCTEST_REPORT_H
|
||||
|
||||
@@ -28,9 +27,15 @@
|
||||
|
||||
namespace sctest {
|
||||
|
||||
|
||||
/// \brief A Report holds test run results.
|
||||
///
|
||||
/// This is designed to work with SimpleSuite, but might be useful
|
||||
/// for other things.
|
||||
class Report {
|
||||
public:
|
||||
/// \brief Construct a new Report, zeroed out.
|
||||
Report();
|
||||
|
||||
/// \brief Failing returns the count of failed tests.
|
||||
///
|
||||
/// \details If a test is run and expected to pass, but fails,
|
||||
@@ -40,24 +45,48 @@ public:
|
||||
/// \return The number of tests that failed.
|
||||
size_t Failing() const;
|
||||
|
||||
/// \brief Returns the number of tests that have passed
|
||||
/// successfully.
|
||||
/// \brief The number of tests that have passed successfully.
|
||||
size_t Passing() const;
|
||||
|
||||
/// \brief Total is the number of tests registered.
|
||||
/// \brief The number of tests registered.
|
||||
size_t Total() const;
|
||||
|
||||
/// \brief Report a test as having failed.
|
||||
void Failed();
|
||||
|
||||
/// \brief Report a test as having passed.
|
||||
void Passed();
|
||||
|
||||
/// \brief Register more tests in the report.
|
||||
///
|
||||
/// This is used to track the total number of tests in the
|
||||
/// report.
|
||||
void AddTest(size_t testCount = 0);
|
||||
|
||||
/// \brief Reset the internal state.
|
||||
///
|
||||
/// All fields in the Report will be zeroed out.
|
||||
///
|
||||
/// \param testCount
|
||||
void Reset(size_t testCount = 0);
|
||||
|
||||
/// \brief Mark the start of test runs.
|
||||
///
|
||||
/// This is used for tracking how long the tests took to complete.
|
||||
void Start();
|
||||
|
||||
/// \brief Mark the end of test runs.
|
||||
///
|
||||
/// This is used for tracking how long the tests took to complete.
|
||||
void End();
|
||||
|
||||
/// \brief Retrieve how long the tests took to run.
|
||||
///
|
||||
/// This only makes sense to run after called to Start and End.
|
||||
///
|
||||
/// \return The number of milliseconds that have elapsed.
|
||||
std::chrono::duration<double, std::milli>
|
||||
Elapsed() const;
|
||||
|
||||
Report();
|
||||
private:
|
||||
size_t failing;
|
||||
size_t passed;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
///
|
||||
/// \file SimpleSuite.h
|
||||
/// \file include/sctest/SimpleSuite.h
|
||||
/// \author K. Isom <kyle@imap.cc>
|
||||
/// \date 2017-06-05
|
||||
/// \brief Defines a simple unit testing framework.
|
||||
@@ -33,8 +33,9 @@
|
||||
namespace sctest {
|
||||
|
||||
|
||||
/// \brief UnitTest describes a single unit test. It is a predicate:
|
||||
/// did the test pass?
|
||||
/// \brief UnitTest describes a single unit test.
|
||||
///
|
||||
/// It is a predicate: did the test pass?
|
||||
struct UnitTest {
|
||||
/// What name should be shown when running tests?
|
||||
std::string name;
|
||||
@@ -99,12 +100,13 @@ public:
|
||||
/// resetting the suite's internal state.
|
||||
void Reset();
|
||||
|
||||
/// \brief
|
||||
// HasRun returns true if a report is ready.
|
||||
/// \brief Returns true if Run has been called.
|
||||
bool HasRun() const;
|
||||
|
||||
// Report returns a Report.
|
||||
Report GetReport(void);
|
||||
/// \brief Retrieve the test run results.
|
||||
///
|
||||
/// The results will only be valid if Run has been called.
|
||||
Report GetReport();
|
||||
|
||||
private:
|
||||
bool quiet;
|
||||
|
||||
37
include/sctest/sctest.h
Normal file
37
include/sctest/sctest.h
Normal file
@@ -0,0 +1,37 @@
|
||||
///
|
||||
/// \file include/sctest/sctest.h
|
||||
/// \author K. Isom <kyle@imap.cc>
|
||||
/// \date 2023-10-20
|
||||
/// \brief Shimmering Clarity testing code.
|
||||
///
|
||||
/// 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.
|
||||
///
|
||||
|
||||
#include <sctest/Assert.h>
|
||||
#include <sctest/Checks.h>
|
||||
#include <sctest/Debug.h>
|
||||
#include <sctest/Exceptions.h>
|
||||
#include <sctest/Report.h>
|
||||
#include <sctest/SimpleSuite.h>
|
||||
|
||||
#ifndef SCSL_SCTEST_H
|
||||
#define SCSL_SCTEST_H
|
||||
|
||||
/// \brief Shimmering Clarity testing library.
|
||||
namespace sctest {}
|
||||
|
||||
|
||||
#endif // SCSL_SCTEST_H
|
||||
Reference in New Issue
Block a user