15 #ifndef INCG_IRIS_IUTEST_INTERNAL_DEFS_HPP_4B0AF5C2_8E8D_43EF_BFC5_F385E68F18DB_
16 #define INCG_IRIS_IUTEST_INTERNAL_DEFS_HPP_4B0AF5C2_8E8D_43EF_BFC5_F385E68F18DB_
21 #include "../iutest_defs.hpp"
30 #if IUTEST_HAS_HDR_CXXABI
40 #ifdef __INTEL_COMPILER
41 # define IUTEST_AMBIGUOUS_ELSE_BLOCKER_
43 # define IUTEST_AMBIGUOUS_ELSE_BLOCKER_ switch(::iutest::detail::AlwaysZero()) case 0: default:
46 #define IUTEST_SUPPRESS_UNREACHABLE_CODE_WARNING(statement) if( ::iutest::detail::AlwaysTrue() ) statement
49 #define IUTEST_MBS_CODE_UNKNOWN 0
50 #define IUTEST_MBS_CODE_UTF8 1
51 #define IUTEST_MBS_CODE_WINDOWS31J 2
52 #ifndef IUTEST_MBS_CODE
53 # if defined(IUTEST_OS_WINDOWS)
54 # define IUTEST_MBS_CODE IUTEST_MBS_CODE_WINDOWS31J
56 # define IUTEST_MBS_CODE IUTEST_MBS_CODE_UTF8
65 # define NULL (void*)0
70 # if defined(IUTEST_OS_WINDOWS_MINGW)
71 # define IUTEST_BREAK() DebugBreak()
72 # elif defined(_MSC_VER)
74 # define IUTEST_BREAK() __debugbreak()
76 # define IUTEST_BREAK() DebugBreak()
78 # elif defined(IUTEST_OS_MAC)
80 # if defined(__ppc64__) || defined(__ppc__)
81 # define IUTEST_BREAK() __asm__("li r0, 20\nsc\nnop\nli r0, 37\nli r4, 2\nsc\nnop\n" : : : "memory", "r0", "r3", "r4" )
83 # define IUTEST_BREAK() __asm__("int $3\n" : : )
85 # elif defined(__GUNC__) && (defined (__i386__) || defined (__x86_64__))
86 # define IUTEST_BREAK() do { __asm { int 3 } } while(::iutest::detail::AlwaysFalse())
87 # elif defined(__clang__) || defined(__GNUC__)
88 # define IUTEST_BREAK() __builtin_trap()
89 # elif defined(__ARMCC_VERSION)
90 # define IUTEST_BREAK() do { __breakpoint(0xF02C); } while(::iutest::detail::AlwaysFalse())
92 # define IUTEST_BREAK() *static_cast<volatile int*>(NULL) = 1
97 #if IUTEST_HAS_IF_EXISTS
98 # define IUTEST_IF_EXISTS(identifier_, statement_) __if_exists(identifier_) { statement_ }
99 # define IUTEST_IF_NOT_EXISTS(identifier_, statement_) __if_not_exists(identifier_) { statement_ }
100 # define IUTEST_STATIC_EXISTS(identifier_) IUTEST_IF_EXISTS(identifier_, true) IUTEST_IF_NOT_EXISTS(identifier_, false)
102 # define IUTEST_IF_EXISTS(identifier_, statement_)
103 # define IUTEST_IF_NOT_EXISTS(identifier_, statement_)
104 # define IUTEST_STATIC_EXISTS(identifier_)
107 #if IUTEST_HAS_LIB && IUTEST_HAS_EXTERN_TEMPLATE
109 IUTEST_PRAGMA_EXTERN_TEMPLATE_WARN_DISABLE_BEGIN()
111 extern template class ::std::vector< ::std::basic_string<
char> >;
112 extern template class ::std::vector< ::std::basic_string<
wchar_t> >;
114 IUTEST_PRAGMA_EXTERN_TEMPLATE_WARN_DISABLE_END()
121 namespace type_traits = iutest_type_traits;
128 #if IUTEST_HAS_NULLPTR && !defined(IUTEST_NO_NULL_TO_NULLPTR_T)
129 typedef ::std::nullptr_t iu_nullptr_convertible_t;
131 typedef ::iutest_compatible::IsNullLiteralHelper::Object* iu_nullptr_convertible_t;
140 inline bool AlwaysTrue() {
return true; }
145 inline bool AlwaysFalse() {
return !AlwaysTrue(); }
150 inline int AlwaysZero() {
return 0; }
155 inline bool IsTrue(
bool b) {
return b; }
161 using namespace iutest_type_traits;
162 using namespace iutest_compatible;
164 #if !defined(IUTEST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
169 template<
typename Ite>
170 struct IteratorTraits
172 typedef typename Ite::value_type type;
175 struct IteratorTraits<T*>
180 struct IteratorTraits<const T*>
191 inline void Delete(T* ptr)
209 struct explicit_type_t {};
211 #if defined(IUTEST_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS)
212 # define IUTEST_EXPLICIT_TEMPLATE_TYPE_(t) ::iutest::detail::explicit_type_t<t>*
213 # define IUTEST_APPEND_EXPLICIT_TEMPLATE_TYPE_(t) , ::iutest::detail::explicit_type_t<t>*
215 # define IUTEST_EXPLICIT_TEMPLATE_TYPE_(t)
216 # define IUTEST_APPEND_EXPLICIT_TEMPLATE_TYPE_(t)
220 inline explicit_type_t<T>* explicit_type() {
return NULL; }
226 class TypeUniqueCounter
230 static size_t count() {
return value++; }
232 template<
typename T>
size_t TypeUniqueCounter<T>::value = 0;
235 inline size_t GetTypeUniqueCounter() {
return TypeUniqueCounter<T>::count(); }
246 explicit auto_ptr(T* p = NULL) : m_ptr(p) {}
247 auto_ptr(
const auto_ptr& rhs) : m_ptr(rhs.m_ptr) { rhs.m_ptr = NULL; }
248 ~auto_ptr() {
if( m_ptr != NULL )
delete m_ptr; }
250 T& operator * ()
const {
return *m_ptr; }
251 T* operator -> ()
const {
return m_ptr; }
253 auto_ptr& operator = (auto_ptr& rhs) { m_ptr = rhs.m_ptr; rhs.m_ptr = NULL;
return *
this; }
255 T* get() {
return m_ptr; }
267 explicit scoped_ptr(T* p=NULL) : m_ptr(p) {}
268 ~scoped_ptr() { reset(); }
270 T& operator * ()
const {
return *m_ptr; }
271 T* operator -> ()
const {
return m_ptr; }
273 T* get()
const {
return m_ptr; }
281 void reset(T* p=NULL)
285 if( IsTrue(
sizeof(T) > 0) )
300 #define IUTEST_IS_NULLLITERAL(x) \
301 (sizeof(::iutest::detail::IsNullLiteralHelper::IsNullLiteral(x)) == 1)
307 struct IsContainerHelper
314 ,
typename T::iterator* =NULL,
typename T::const_iterator* =NULL) {
return 0; }
317 static IUTEST_CXX_CONSTEXPR no_t IsContainer(
long IUTEST_APPEND_EXPLICIT_TEMPLATE_TYPE_(T)) {
return 0; }
324 inline ::std::string GetTypeName()
327 const char*
const name =
typeid(T).name();
329 #if IUTEST_HAS_HDR_CXXABI
330 using abi::__cxa_demangle;
332 char*
const read_name = __cxa_demangle(name, 0, 0, &status);
333 ::std::string str(status == 0 ? read_name : name);
334 #if defined(_IUTEST_DEBUG)
336 fprintf(stderr,
"Unable to demangle \"%s\" -> \"%s\". (status=%d)\n", name, read_name ? read_name :
"", status);
353 #define IIUT_GeTypeNameSpecialization(type) \
354 template<>inline ::std::string GetTypeName<type>() { return #type; } \
355 template<>inline ::std::string GetTypeName<type*>() { return #type "*"; }
357 #define IIUT_GeTypeNameSpecialization2(type) \
358 IIUT_GeTypeNameSpecialization(type) \
359 IIUT_GeTypeNameSpecialization(unsigned type)
361 IIUT_GeTypeNameSpecialization2(
char)
362 IIUT_GeTypeNameSpecialization2(
short)
363 IIUT_GeTypeNameSpecialization2(
int)
364 IIUT_GeTypeNameSpecialization2(
long)
365 IIUT_GeTypeNameSpecialization(
float)
366 IIUT_GeTypeNameSpecialization(
double)
367 IIUT_GeTypeNameSpecialization(
bool)
369 #undef IIUT_GeTypeNameSpecialization
370 #undef IIUT_GeTypeNameSpecialization2
378 struct GetTypeNameProxy
380 static ::std::string GetTypeName() {
return detail::GetTypeName<T>(); }
internal gtest/iutest compatible definition
#define IUTEST_CXX_CONSTEXPR
constexpr
Definition: iutest_compiler.hpp:372
#define IUTEST_PP_DISALLOW_COPY_AND_ASSIGN(TypeName)
コピー禁止定義
Definition: iutest_pp.hpp:31
iris unit test iu_basic_ostream implimentaion
iris unit test char/wchar_t mediator
iutest root namespace
Definition: iutest_charcode.hpp:33