libcruft-util/tap.hpp
Danny Robson 8cc4c1e82a format: reimplement format rendering
requires literal string arrays, and implements more of the specifier
specification. does not implement 'n' or '$' specifiers. falls back to
snprintf for real arguments.
2016-07-28 13:39:27 +10:00

94 lines
3.3 KiB
C++

/*
* 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.
*
* Copyright 2015 Danny Robson <danny@nerdcruft.net>
*/
#ifndef __UTIL_TAP_HPP
#define __UTIL_TAP_HPP
#include <functional>
#include <vector>
#include <initializer_list>
namespace util { namespace TAP {
/// A simple TAP (Test Anything Protocol) test case output
class logger {
public:
enum {
PASS,
FAIL,
SKIP,
TODO
};
//---------------------------------------------------------------------
logger ();
~logger ();
//---------------------------------------------------------------------
template <typename ...Args, size_t N>
void expect (bool, const char (&fmt)[N], Args&&...);
template <typename ...Args, size_t N>
void expect (const std::function<bool(Args...)>&, Args&&..., const char (&msg)[N]);
//---------------------------------------------------------------------
template <typename T, typename U, typename ...Args, size_t N>
void expect_eq (const T&, const U&, const char (&fmt)[N], Args&&...);
template <typename T, typename U, typename ...Args, size_t N>
void expect_neq (const T&, const U&, const char (&fmt)[N], Args&&...);
//---------------------------------------------------------------------
template <typename T, typename U, typename ...Args, size_t N>
void expect_gt (const T&, const U&, const char (&fmt)[N], Args&&...);
template <typename T, typename U, typename ...Args, size_t N>
void expect_ge (const T&, const U&, const char (&fmt)[N], Args&&...);
template <typename T, typename U, typename ...Args, size_t N>
void expect_lt (const T&, const U&, const char (&fmt)[N], Args&&...);
template <typename T, typename U, typename ...Args, size_t N>
void expect_le (const T&, const U&, const char (&fmt)[N], Args&&...);
//---------------------------------------------------------------------
template <typename T, typename ...Args, size_t N>
void expect_nan (const T&, const char (&fmt)[N], Args&&...);
//---------------------------------------------------------------------
template <typename T, typename ...Args, size_t N>
void expect_nothrow (T&&, const char (&fmt)[N], Args&&...);
template <typename E, typename T, typename ...Args, size_t N>
void expect_throw (T&&, const char (&fmt)[N], Args&&...);
//---------------------------------------------------------------------
void skip (const std::string &msg);
void todo (const std::string &msg);
void noop (void);
//---------------------------------------------------------------------
int status (void) const;
private:
int m_status;
size_t m_size;
};
} }
#include "tap.ipp"
#endif