libcruft-util/tap.hpp

94 lines
3.2 KiB
C++
Raw Normal View History

2015-01-29 15:45:30 +11:00
/*
2015-04-13 18:05:28 +10:00
* 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
2015-01-29 15:45:30 +11:00
*
2015-04-13 18:05:28 +10:00
* http://www.apache.org/licenses/LICENSE-2.0
2015-01-29 15:45:30 +11:00
*
2015-04-13 18:05:28 +10:00
* 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.
2015-01-29 15:45:30 +11:00
*
* Copyright 2015 Danny Robson <danny@nerdcruft.net>
*/
#ifndef __UTIL_TAP_HPP
#define __UTIL_TAP_HPP
2015-04-13 16:43:49 +10:00
#include <functional>
#include <vector>
#include <initializer_list>
2015-01-29 15:45:30 +11:00
2015-04-13 16:43:49 +10:00
namespace util { namespace TAP {
/// A simple TAP (Test Anything Protocol) test case output
class logger {
public:
enum {
PASS,
FAIL,
SKIP,
TODO
};
2015-01-29 15:45:30 +11:00
2015-04-13 21:45:49 +10:00
//---------------------------------------------------------------------
2015-04-13 16:43:49 +10:00
logger ();
~logger ();
2015-01-29 15:45:30 +11:00
2015-04-13 21:45:49 +10:00
//---------------------------------------------------------------------
template <typename ...Args>
void expect (bool, const std::string &fmt, Args&&...);
2015-01-29 15:45:30 +11:00
2015-04-13 21:45:49 +10:00
template <typename ...Args>
void expect (std::function<bool(Args...)>, Args&&..., const std::string& msg);
2015-01-29 15:45:30 +11:00
2015-04-13 21:45:49 +10:00
//---------------------------------------------------------------------
2015-07-21 02:53:46 +10:00
template <typename T, typename U, typename ...Args>
2015-07-21 03:17:20 +10:00
void expect_eq (const T&, const U&, const std::string &fmt, Args&...);
2015-07-21 02:53:46 +10:00
template <typename T, typename U, typename ...Args>
2015-07-21 03:17:20 +10:00
void expect_neq (const T&, const U&, const std::string &fmt, Args&...);
2015-01-29 15:45:30 +11:00
2015-04-13 21:45:49 +10:00
//---------------------------------------------------------------------
2015-07-21 02:53:46 +10:00
template <typename T, typename U, typename ...Args>
2015-07-21 03:17:20 +10:00
void expect_gt (const T&, const U&, const std::string &fmt, Args&...);
2015-07-21 02:53:46 +10:00
template <typename T, typename U, typename ...Args>
2015-07-21 03:17:20 +10:00
void expect_ge (const T&, const U&, const std::string &fmt, Args&...);
2015-07-21 02:53:46 +10:00
template <typename T, typename U, typename ...Args>
2015-07-21 03:17:20 +10:00
void expect_lt (const T&, const U&, const std::string &fmt, Args&...);
2015-07-21 02:53:46 +10:00
template <typename T, typename U, typename ...Args>
2015-07-21 03:17:20 +10:00
void expect_le (const T&, const U&, const std::string &fmt, Args&...);
2015-01-29 15:45:30 +11:00
2015-04-13 21:46:56 +10:00
//---------------------------------------------------------------------
2015-07-21 02:53:46 +10:00
template <typename T, typename ...Args>
2015-07-21 03:17:20 +10:00
void expect_nan (const T&, const std::string &fmt, Args&...);
2015-04-13 21:46:56 +10:00
2015-07-02 17:03:36 +10:00
//---------------------------------------------------------------------
2015-07-21 02:53:46 +10:00
template <typename T, typename ...Args>
2015-07-21 03:17:20 +10:00
void expect_nothrow (T&&, const std::string &fmt, Args&...);
2015-07-21 02:53:46 +10:00
template <typename E, typename T, typename ...Args>
2015-07-21 03:17:20 +10:00
void expect_throw (T&&, const std::string &fmt, Args&...);
2015-07-02 17:03:36 +10:00
2015-04-13 21:46:56 +10:00
//---------------------------------------------------------------------
2015-04-13 16:43:49 +10:00
void skip (const std::string &msg);
void todo (const std::string &msg);
void noop (void);
2015-01-29 15:45:30 +11:00
2015-04-13 21:45:49 +10:00
//---------------------------------------------------------------------
2015-04-13 16:43:49 +10:00
int status (void) const;
2015-01-29 15:45:30 +11:00
2015-04-13 16:43:49 +10:00
private:
int m_status;
size_t m_size;
};
} }
#include "tap.ipp"
2015-01-29 15:45:30 +11:00
#endif