Skip to content

Commit

Permalink
fix newer compilers warnings, bump version, needs check with msvc
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Sommerlad committed Oct 4, 2019
1 parent 0465bf5 commit 46049b9
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 17 deletions.
8 changes: 5 additions & 3 deletions cute/cute_demangle.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,17 @@ inline std::string plain_demangle(char const *name){
::free(const_cast<char*>(toBeFreed));
return result;
}
#if defined(_LIBCPP_NAMESPACE) || defined(_GLIBCXX_USE_CXX11_ABI)
#if defined(_LIBCPP_ABI_NAMESPACE) || defined(_LIBCPP_NAMESPACE) || defined(_GLIBCXX_USE_CXX11_ABI)
inline void patch_library_namespace(std::string &mightcontaininlinenamespace) {
// libc++ uses inline namespace std::_LIBCPP_NAMESPACE:: for its classes. This breaks the tests relying on meta information. re-normalize the names back to std::
// libstdc++ (at least in version 6.3.1) puts some STL classes into the inline namespace std::_GLIBCXX_NAMESPACE_CXX11 if in C++11 mode
std::string::size_type pos=std::string::npos;
#define XNS(X) #X
#define NS(X) XNS(X)
#ifdef _LIBCPP_NAMESPACE
#if defined( _LIBCPP_NAMESPACE)
#define TOREPLACE "::" NS(_LIBCPP_NAMESPACE)
#elif defined(_LIBCPP_ABI_NAMESPACE)
#define TOREPLACE "::" NS(_LIBCPP_ABI_NAMESPACE)
#else
#define TOREPLACE "::" NS(_GLIBCXX_NAMESPACE_CXX11)
#endif
Expand All @@ -77,7 +79,7 @@ inline void patchresultforstring(std::string& result) {
inline std::string demangle(char const *name){
if (!name) return "unknown";
std::string result(cute_impl_demangle::plain_demangle(name));
#if defined(_LIBCPP_NAMESPACE) || defined(_GLIBCXX_USE_CXX11_ABI)
#if defined(_LIBCPP_ABI_NAMESPACE) || defined(_LIBCPP_NAMESPACE) || defined(_GLIBCXX_USE_CXX11_ABI)
cute_impl_demangle::patchresultforstring(result);
#endif
return result;
Expand Down
3 changes: 3 additions & 0 deletions cute/cute_equals.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ namespace cute {
,ActualValue const &actual
,DeltaValue const &delta) {
using std::abs; // allow for user-defined types with abs overload
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
return bool(abs(delta) >= abs(expected-actual)); // Accommodate non-standard boolean type with explicit conversion
#pragma GCC diagnostic pop
}
template <typename ExpectedValue, typename ActualValue, bool select_non_floating_point_type>
bool do_equals_floating(ExpectedValue const &expected
Expand Down
12 changes: 8 additions & 4 deletions cute/cute_to_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
#ifndef CUTE_TO_STRING_H_
#define CUTE_TO_STRING_H_

#include "cute_determine_version.h"

#include <string>
#include <algorithm>
#ifdef USE_STD17
Expand Down Expand Up @@ -78,6 +76,7 @@ namespace cute_to_string {
#include <set>
#endif
#include "cute_demangle.h"
#include "cute_determine_version.h"
#ifdef USE_STD11
#include "cute_integer_sequence.h"
#include <tuple>
Expand Down Expand Up @@ -111,8 +110,13 @@ namespace cute_to_string {
template <class CONT>
struct has_begin_end_const_member {
template <typename T, T, T> struct type_check;
#ifdef USE_STD17
template <typename C> static typename C::const_iterator test(
type_check<typename C::const_iterator (C::*)()const noexcept,&C::begin, &C::end>*);
#else
template <typename C> static typename C::const_iterator test(
type_check<typename C::const_iterator (C::*)()const,&C::begin, &C::end>*);
#endif
template <typename C> static char test(...);
enum e { value = (sizeof(char) != sizeof(test<CONT>(0)))
};
Expand Down Expand Up @@ -300,9 +304,9 @@ namespace cute_to_string {
bool minint=false;
if (x == std::numeric_limits<T>::min()){ // can not easily convert it, assuming 2s complement
minint=true;
x +=1;
x++; // add 1, but 1 might be incompatible type, so use ++
}
if (x < 0) x = -x;
if (x < 0) x = static_cast<T>(-x);
if (x == 0) convert += '0';
while (x > 0) {
convert += "0123456789"[x%10];
Expand Down
2 changes: 1 addition & 1 deletion cute/cute_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@
#ifndef CUTE_VERSION_H_
#define CUTE_VERSION_H_

#define CUTE_LIB_VERSION "2.2.4"
#define CUTE_LIB_VERSION "2.2.5"

#endif /*CUTE_VERSION_H_*/
14 changes: 7 additions & 7 deletions cute_tests/mock_listener.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@
namespace cute_test {
using namespace cute;
struct mock_listener {
unsigned int begincount;
unsigned int endcount;
unsigned int startcount;
unsigned int successcount;
unsigned int failurecount;
unsigned int errorcount;
unsigned int suitetestcount;
size_t begincount;
size_t endcount;
size_t startcount;
size_t successcount;
size_t failurecount;
size_t errorcount;
size_t suitetestcount;
std::vector<std::string> infomessages;
std::vector<std::string> errormessages;
std::vector<std::string> successmessages;
Expand Down
1 change: 0 additions & 1 deletion cute_tests/test_cute_equals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

#include "test_cute_equals.h"
#include "cute_base.h"
#include "cute_determine_version.h"
#include "cute_equals.h"
#include "cute_throws.h"
#include <limits>
Expand Down
6 changes: 5 additions & 1 deletion cute_tests/test_tap_listener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@
*
*********************************************************************************/

#include "test_tap_listener.h"
#ifdef USE_STD11
#include "cute.h"
#include "tap_listener.h"
#include "test_tap_listener.h"
#include <sstream>
#include "cute_runner.h"
#define MAKE_RUNNER_RUN_TO_OUT \
Expand Down Expand Up @@ -130,14 +131,17 @@ void test_tap_for_error(){
"# Unexpected exception: oops\n"
"1..1\n",out.str());
}
#endif

cute::suite make_suite_test_tap_listener(){
cute::suite s;
#ifdef USE_STD11
s.push_back(CUTE(test_tap_emptyrun));
s.push_back(CUTE(test_tap_single_success));
s.push_back(CUTE(test_tap_single_failure));
s.push_back(CUTE(test_tap_suite));
s.push_back(CUTE(test_tap_multiple_suites));
s.push_back(CUTE(test_tap_for_error));
#endif
return s;
}

0 comments on commit 46049b9

Please sign in to comment.