Skip to content

Commit

Permalink
Merge f2614c9 into d94c8a4
Browse files Browse the repository at this point in the history
  • Loading branch information
srz-zumix committed Jun 13, 2023
2 parents d94c8a4 + f2614c9 commit 0e3bba4
Show file tree
Hide file tree
Showing 13 changed files with 114 additions and 53 deletions.
22 changes: 13 additions & 9 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,27 +41,31 @@ cirrus_use_lib_task:
depends_on:
- cirrus_gcc_test

cirrus_osx_14_test_task: &osx_task
cirrus_osx_17_test_task: &osx_task
only_if: *default-condition
auto_cancellation: true
osx_instance:
image: catalina-xcode
image: ghcr.io/cirruslabs/macos-ventura-base:latest
env:
- STDFLAG: -std=c++14
- STDFLAG: -std=c++17
version_script: make -C test showcxxversion
build_script: make -C test -j$((`getconf _NPROCESSORS_ONLN`))
test_script : make -C test test
report_script: make -C test report

cirrus_osx_17_test_task:
cirrus_osx_14_test_task:
<<: *osx_task
env:
- STDFLAG: -std=c++17
# https://stackoverflow.com/questions/56924853/why-xcode-11-beta-cant-use-c17s-filesystem-header
# ** Comment out because the image is mojave **
# CXXFLAGS: -mmacosx-version-min=10.15
- STDFLAG: -std=c++14
depends_on:
- cirrus_osx_17_test

cirrus_osx_20_test_task:
<<: *osx_task
env:
- STDFLAG: -std=c++20
depends_on:
- cirrus_osx_14_test
- cirrus_osx_17_test

# cirrus_worker_info_task:
# container:
Expand Down
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
# This software is released under the new BSD License,
# see LICENSE

.PHONY: help test fused editorconfig-self-lint dagger-ctest dagger-format

#
# help
#
Expand All @@ -23,3 +25,6 @@ dagger-ctest:

dagger-format:
cue fmt -s

test:
make -C test test
5 changes: 5 additions & 0 deletions include/internal/iutest_charcode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ ::std::string ShowAnyCString(const CharType* any_c_str)

#if IUTEST_HAS_CXX_HDR_CODECVT

IUTEST_PRAGMA_WARN_PUSH()
IUTEST_PRAGMA_WARN_DISABLE_DEPRECATED()

template<typename In, typename Out, typename State>
struct codecvt : public ::std::codecvt<In, Out, State> { ~codecvt() {} };

Expand All @@ -171,6 +174,8 @@ ::std::basic_string<Out> CodeConvert(const In* str)
}
#endif

IUTEST_PRAGMA_WARN_POP()

#endif

//======================================================================
Expand Down
42 changes: 30 additions & 12 deletions include/internal/iutest_compiler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* @author t.shirayanagi
* @par copyright
* Copyright (C) 2011-2022, Takazumi Shirayanagi\n
* Copyright (C) 2011-2023, Takazumi Shirayanagi\n
* This software is released under the new BSD License,
* see LICENSE
*/
Expand All @@ -31,32 +31,50 @@
#if defined(__clang__)
# if !defined(IUTEST_CLANG_MAJOR)
# if defined(__APPLE__)
# if __clang_major__ > 11
# define IUTEST_CLANG_MAJOR 10
# elif __clang_major__ > 10
# if __clang_minor__ > 3
# if __clang_major__ > 14
# define IUTEST_CLANG_MAJOR 15
# elif __clang_major__ == 14
# if __clang_patchlevel__ >= 3
# define IUTEST_CLANG_MAJOR 15
# else
# define IUTEST_CLANG_MAJOR 14
# endif
# elif __clang_major__ == 13
# if __clang_minor__ >= 1
# define IUTEST_CLANG_MAJOR 13
# else
# define IUTEST_CLANG_MAJOR 12
# endif
# elif __clang_major__ == 12
# if __clang_patchlevel__ >= 5
# define IUTEST_CLANG_MAJOR 11
# else
# define IUTEST_CLANG_MAJOR 10
# endif
# elif __clang_major__ == 11
# if __clang_patchlevel__ >= 3
# define IUTEST_CLANG_MAJOR 9
# else
# define IUTEST_CLANG_MAJOR 8
# endif
# elif __clang_major__ > 9
# if __clang_minor__ > 1
# elif __clang_major__ == 10
# if __clang_minor__ >= 1
# define IUTEST_CLANG_MAJOR 7
# else
# define IUTEST_CLANG_MAJOR 6
# endif
# elif __clang_major__ > 8
# if __clang_minor__ > 2
# elif __clang_major__ == 9
# if __clang_minor__ >= 1
# define IUTEST_CLANG_MAJOR 5
# else
# define IUTEST_CLANG_MAJOR 4
# endif
# else
# define IUTEST_CLANG_MAJOR 3
# if __clang_major__ > 7
# if __clang_major__ == 8
# define IUTEST_CLANG_MINOR 9
# elif __clang_major__ > 6
# if __clang_minor__ > 2
# elif __clang_major__ == 7
# if __clang_minor__ >= 3
# define IUTEST_CLANG_MINOR 8
# else
# define IUTEST_CLANG_MINOR 7
Expand Down
2 changes: 2 additions & 0 deletions include/internal/iutest_internal_defs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@
// https://www.cocoawithlove.com/2008/03/break-into-debugger.html
# if defined(__ppc64__) || defined(__ppc__)
# define IUTEST_BREAK() __asm__("li r0, 20\nsc\nnop\nli r0, 37\nli r4, 2\nsc\nnop\n" : : : "memory", "r0", "r3", "r4" )
# elif defined(__aarch64__)
# define IUTEST_BREAK() __asm__(".inst 0xd4200000")
# else
# define IUTEST_BREAK() __asm__("int $3\n" : : )
# endif
Expand Down
15 changes: 15 additions & 0 deletions include/internal/iutest_pragma.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,21 @@
# define IUTEST_PRAGMA_WARN_DISABLE_NONNULL()
#endif


#if !defined(IUTEST_PRAGMA_WARN_DISABLE_DEPRECATED)
# if defined(__clang__)
# define IUTEST_PRAGMA_WARN_DISABLE_DEPRECATED() IUTEST_PRAGMA_CLANG_WARN_DISABLE("-Wdeprecated-declarations")
# elif defined(__GNUC__)
# define IUTEST_PRAGMA_WARN_DISABLE_DEPRECATED() IUTEST_PRAGMA_GCC_WARN_DISABLE("-Wdeprecated-declarations")
# elif defined(_MSC_VER)
# define IUTEST_PRAGMA_WARN_DISABLE_DEPRECATED()
# endif
#endif

#if !defined(IUTEST_PRAGMA_WARN_DISABLE_DEPRECATED)
# define IUTEST_PRAGMA_WARN_DISABLE_DEPRECATED()
#endif

#if defined(__clang__)
# if IUTEST_CLANG_MAJOR > 10
# define IUTEST_PRAGMA_IUTEST_WARN_DISABLE_CLANG_11() IUTEST_PRAGMA_CLANG_WARN_DISABLE("-Wsuggest-destructor-override")
Expand Down
11 changes: 8 additions & 3 deletions include/internal/iutest_stdlib_defs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* @author t.shirayanagi
* @par copyright
* Copyright (C) 2012-2022, Takazumi Shirayanagi\n
* Copyright (C) 2012-2023, Takazumi Shirayanagi\n
* This software is released under the new BSD License,
* see LICENSE
*/
Expand Down Expand Up @@ -211,10 +211,15 @@
# endif
# if defined(__has_include)
# if !defined(IUTEST_HAS_CXX_HDR_CUCHAR) && __has_include( <cuchar> )
# define IUTEST_HAS_CXX_HDR_CUCHAR 1
# if defined(__APPLE__) && IUTEST_CLANG_MAJOR == 15
// https://github.com/llvm/llvm-project/issues/62573
# define IUTEST_HAS_CXX_HDR_CUCHAR 0
# else
# define IUTEST_HAS_CXX_HDR_CUCHAR 1
# endif
# endif
# if !defined(IUTEST_HAS_STD_TUPLE) && __has_include( <tuple> )
# define IUTEST_HAS_STD_TUPLE 1
# define IUTEST_HAS_STD_TUPLE 1
# endif
# endif
#endif
Expand Down
7 changes: 4 additions & 3 deletions include/internal/iutest_string.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* @author t.shirayanagi
* @par copyright
* Copyright (C) 2011-2021, Takazumi Shirayanagi\n
* Copyright (C) 2011-2023, Takazumi Shirayanagi\n
* This software is released under the new BSD License,
* see LICENSE
*/
Expand Down Expand Up @@ -140,12 +140,13 @@ inline int iu_vsnprintf(char* dst, size_t size, const char* format, va_list va)
{
char buffer[4096] = {0};
char* write_buffer = dst != NULL && size >= 4096 ? dst : buffer;
const int ret = vsprintf(write_buffer, format, va);
const int ret = vsnprintf(write_buffer, size, format, va);
if( dst != NULL )
{
const size_t length = static_cast<size_t>(ret);
const size_t write = (size <= length) ? size - 1 : length;
if( write_buffer == buffer ) {
if( write_buffer == buffer )
{
strncpy(dst, buffer, write);
}
dst[write] = '\0';
Expand Down
5 changes: 2 additions & 3 deletions include/internal/iutest_string_stream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* @author t.shirayanagi
* @par copyright
* Copyright (C) 2011-2021, Takazumi Shirayanagi\n
* Copyright (C) 2011-2023, Takazumi Shirayanagi\n
* This software is released under the new BSD License,
* see LICENSE
*/
Expand Down Expand Up @@ -230,8 +230,7 @@ IUTEST_PRAGMA_WARN_DISABLE_FORMAT_NONLITERAL()
static int vastring(E* dst, const E* fmt, va_list va);
static int vastring(char* dst, size_t len, const char* fmt, va_list va) IUTEST_ATTRIBUTE_FORMAT_PRINTF(3, 0)
{
(void)len;
return vsprintf(dst, fmt, va);
return vsnprintf(dst, len, fmt, va);
}
static int vastring(wchar_t* dst, size_t len, const wchar_t* fmt, va_list va)
{
Expand Down
26 changes: 13 additions & 13 deletions include/iutest_matcher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* @author t.shirayanagi
* @par copyright
* Copyright (C) 2014-2020, Takazumi Shirayanagi\n
* Copyright (C) 2014-2023, Takazumi Shirayanagi\n
* This software is released under the new BSD License,
* see LICENSE
*/
Expand Down Expand Up @@ -1092,7 +1092,7 @@ class ElementsAreMatcherBase : public IMatcher
return Check<0, tuples::tuple_size<T>::value - 1>(begin(actual), end(actual), matchers);
}
template<int N, typename T>
static ::std::string WhichIs(const T& matchers)
static ::std::string WhichIsT(const T& matchers)
{
::std::string str = "ElementsAre: {";
str += WhichIs_<T, N, tuples::tuple_size<T>::value-1>(matchers);
Expand Down Expand Up @@ -1179,7 +1179,7 @@ class ElementsAreMatcher IUTEST_CXX_FINAL : public ElementsAreMatcherBase
}
::std::string WhichIs() const IUTEST_CXX_OVERRIDE
{
return ElementsAreMatcherBase::WhichIs<0>(m_matchers);
return ElementsAreMatcherBase::WhichIsT<0>(m_matchers);
}

private:
Expand All @@ -1203,7 +1203,7 @@ class ElementsAreMatcher IUTEST_CXX_FINAL : public ElementsAreMatcherBase
}
::std::string WhichIs() const IUTEST_CXX_OVERRIDE
{
return ElementsAreMatcherBase::WhichIs<0>(m_matchers);
return ElementsAreMatcherBase::WhichIsT<0>(m_matchers);
}
private:
tuples::tuple<T0, T1> m_matchers;
Expand All @@ -1218,7 +1218,7 @@ class ElementsAreMatcher IUTEST_CXX_FINAL : public ElementsAreMatcherBase
template<typename U>AssertionResult operator ()(const U& actual) { \
return Check(m_matchers, actual); } \
::std::string WhichIs() const IUTEST_CXX_OVERRIDE { \
return ElementsAreMatcherBase::WhichIs<0>(m_matchers); } \
return ElementsAreMatcherBase::WhichIsT<0>(m_matchers); } \
private: \
tuples::tuple< IUTEST_PP_ENUM_PARAMS(n, T) > m_matchers; \
}
Expand Down Expand Up @@ -1645,7 +1645,7 @@ class AllOfMatcherBase : public IMatcher
return Check_<T, U, 0, tuples::tuple_size<T>::value-1>(matchers, actual);
}
template<int N, typename T>
static ::std::string WhichIs(const T& matchers)
static ::std::string WhichIsT(const T& matchers)
{
return WhichIs_<T, N, tuples::tuple_size<T>::value-1>(matchers);
}
Expand Down Expand Up @@ -1702,7 +1702,7 @@ class AllOfMatcher IUTEST_CXX_FINAL : public AllOfMatcherBase
}
::std::string WhichIs() const IUTEST_CXX_OVERRIDE
{
return AllOfMatcherBase::WhichIs<0>(m_matchers);
return AllOfMatcherBase::WhichIsT<0>(m_matchers);
}

private:
Expand All @@ -1726,7 +1726,7 @@ class AllOfMatcher IUTEST_CXX_FINAL : public AllOfMatcherBase
}
::std::string WhichIs() const IUTEST_CXX_OVERRIDE
{
return AllOfMatcherBase::WhichIs<0>(m_matchers);
return AllOfMatcherBase::WhichIsT<0>(m_matchers);
}
private:
tuples::tuple<T0, T1> m_matchers;
Expand All @@ -1741,7 +1741,7 @@ class AllOfMatcher IUTEST_CXX_FINAL : public AllOfMatcherBase
template<typename U>AssertionResult operator ()(const U& actual) { \
return Check(m_matchers, actual); } \
::std::string WhichIs() const IUTEST_CXX_OVERRIDE { \
return AllOfMatcherBase::WhichIs<0>(m_matchers); } \
return AllOfMatcherBase::WhichIsT<0>(m_matchers); } \
private: \
tuples::tuple< IUTEST_PP_ENUM_PARAMS(n, T) > m_matchers; \
}
Expand Down Expand Up @@ -1772,7 +1772,7 @@ class AnyOfMatcherBase : public IMatcher
return Check_<T, U, 0, tuples::tuple_size<T>::value-1>(matchers, actual);
}
template<int N, typename T>
static ::std::string WhichIs(const T& matchers)
static ::std::string WhichIsT(const T& matchers)
{
return WhichIs_<T, N, tuples::tuple_size<T>::value-1>(matchers);
}
Expand Down Expand Up @@ -1829,7 +1829,7 @@ class AnyOfMatcher IUTEST_CXX_FINAL : public AnyOfMatcherBase
}
::std::string WhichIs() const IUTEST_CXX_OVERRIDE
{
return AnyOfMatcherBase::WhichIs<0>(m_matchers);
return AnyOfMatcherBase::WhichIsT<0>(m_matchers);
}

private:
Expand All @@ -1853,7 +1853,7 @@ class AnyOfMatcher IUTEST_CXX_FINAL : public AnyOfMatcherBase
}
::std::string WhichIs() const IUTEST_CXX_OVERRIDE
{
return AnyOfMatcherBase::WhichIs<0>(m_matchers);
return AnyOfMatcherBase::WhichIsT<0>(m_matchers);
}
private:
tuples::tuple<T0, T1> m_matchers;
Expand All @@ -1868,7 +1868,7 @@ class AnyOfMatcher IUTEST_CXX_FINAL : public AnyOfMatcherBase
template<typename U>AssertionResult operator ()(const U& actual) { \
return Check(m_matchers, actual); } \
::std::string WhichIs() const IUTEST_CXX_OVERRIDE { \
return AnyOfMatcherBase::WhichIs<0>(m_matchers); } \
return AnyOfMatcherBase::WhichIsT<0>(m_matchers); } \
private: \
tuples::tuple< IUTEST_PP_ENUM_PARAMS(n, T) > m_matchers; \
}
Expand Down
4 changes: 2 additions & 2 deletions test/assertion_only_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* @author t.shirayanagi
* @par copyright
* Copyright (C) 2012-2022, Takazumi Shirayanagi\n
* Copyright (C) 2012-2023, Takazumi Shirayanagi\n
* This software is released under the new BSD License,
* see LICENSE
*/
Expand Down Expand Up @@ -42,7 +42,7 @@ void test_vprintf(const char* fmt, va_list va)
{
IUTEST_PRAGMA_CRT_SECURE_WARN_DISABLE_BEGIN()
char buf[4096];
vsprintf(buf, fmt, va);
vsnprintf(buf, sizeof(buf), fmt, va);
s_outstream << buf;
IUTEST_PRAGMA_CRT_SECURE_WARN_DISABLE_END()
}
Expand Down

0 comments on commit 0e3bba4

Please sign in to comment.