diff --git a/.gitignore b/.gitignore index d1b50fe7c1..dda1353992 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,7 @@ *.sdf *.opensdf *.user +*.nupkg coverage.info test/*.xml lib diff --git a/doc/Doxyfile b/doc/Doxyfile index 19fce175c3..5786b44c4d 100644 --- a/doc/Doxyfile +++ b/doc/Doxyfile @@ -38,7 +38,7 @@ PROJECT_NAME = iutest # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.11.99.20 +PROJECT_NUMBER = 1.11.99.21 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/include/internal/iutest_internal.hpp b/include/internal/iutest_internal.hpp index 15991d1ee3..fd00ae2f1c 100644 --- a/include/internal/iutest_internal.hpp +++ b/include/internal/iutest_internal.hpp @@ -487,4 +487,17 @@ # define IUTEST_TEST_COMPILEERROR(e) IUTEST_PRAGMA_MESSAGE("IUTEST_TEST_COMPILEERROR( " #e " )") #endif +/** +* @brief static_assert チェックタグ +* @{ +*/ +#if IUTEST_HAS_STATIC_ASSERT +# define IUTEST_TEST_STATICASSERT(e) IUTEST_TEST_COMPILEERROR(e) +#else +# define IUTEST_TEST_STATICASSERT(e) IUTEST_TEST_COMPILEERROR("static_assert") +#endif +/** +* @} +*/ + #endif // INCG_IRIS_IUTEST_INTERNAL_HPP_A5BD9FBB_B57A_4C1D_B205_0ADB7798DBF9_ diff --git a/include/iutest_static_assertion.hpp b/include/iutest_static_assertion.hpp index f1a8968277..18d05239de 100644 --- a/include/iutest_static_assertion.hpp +++ b/include/iutest_static_assertion.hpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2012-2014, Takazumi Shirayanagi\n + * Copyright (C) 2012-2015, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -48,10 +48,14 @@ static bool StaticAssertTypeEq(void) * @brief static_assert */ #if IUTEST_HAS_STATIC_ASSERT +#if defined(_MSC_VER) +# define IUTEST_STATIC_ASSERT_MSG(B, Msg) static_assert(B, "static_assert: " Msg) +#else # define IUTEST_STATIC_ASSERT_MSG(B, Msg) static_assert(B, Msg) +#endif #else # define IUTEST_STATIC_ASSERT_MSG(B, Msg) \ - typedef ::iutest::detail::StaticAssertionTest< sizeof(::iutest::detail::StaticAssertionFailure< (bool)B >) > IUTEST_PP_CAT(iutest_static_assert_typedef_, IUTEST_PP_COUNTER) + typedef ::iutest::detail::static_assert_failure< sizeof(::iutest::detail::static_assert_failure< (bool)B >) > IUTEST_PP_CAT(iutest_static_assert_typedef_, IUTEST_PP_COUNTER) #endif /** @@ -59,9 +63,9 @@ static bool StaticAssertTypeEq(void) */ #ifdef IUTEST_STATIC_ASSERT_MSG # ifdef IUTEST_NO_VARIADIC_MACROS -# define IUTEST_STATIC_ASSERT(B) IUTEST_STATIC_ASSERT_MSG(B, "") +# define IUTEST_STATIC_ASSERT(B) IUTEST_STATIC_ASSERT_MSG(B, #B) # else -# define IUTEST_STATIC_ASSERT(...) IUTEST_STATIC_ASSERT_MSG((__VA_ARGS__), "") +# define IUTEST_STATIC_ASSERT(...) IUTEST_STATIC_ASSERT_MSG((__VA_ARGS__), #__VA_ARGS__) # endif #endif @@ -120,9 +124,9 @@ struct StaticAssertTypeEqHelper #endif /** @private */ -templatestruct StaticAssertionFailure; +templatestruct static_assert_failure; /** @overload */ -template<> struct StaticAssertionFailure { enum { value = 1 }; }; +template<> struct static_assert_failure { enum { value = 1 }; }; /** @private */ templatestruct StaticAssertionTest {}; diff --git a/include/iutest_ver.hpp b/include/iutest_ver.hpp index f458378478..8466a33068 100644 --- a/include/iutest_ver.hpp +++ b/include/iutest_ver.hpp @@ -17,11 +17,11 @@ //====================================================================== // define -#define IUTEST_VER 0x01119920u //!< iutest version 1.11.99.20 +#define IUTEST_VER 0x01119921u //!< iutest version 1.11.99.21 #define IUTEST_MAJORVER 0x01u //!< Major Version #define IUTEST_MINORVER 0x11u //!< Minor Version #define IUTEST_BUILD 0x99u //!< Build -#define IUTEST_REVISION 0x20u //!< Revision +#define IUTEST_REVISION 0x21u //!< Revision /** * @mainpage diff --git a/test/CommonMakefile.in b/test/CommonMakefile.in index eb0fbe859a..bf6e14a029 100644 --- a/test/CommonMakefile.in +++ b/test/CommonMakefile.in @@ -113,7 +113,7 @@ TARGETS_IUTEST_ONLY = \ COMPILEERROR_TARGETS=\ iutest_check_strict_tests \ - iutest_static_assertion_failure_tests + iutest_static_assertion_failure_tests \ BUILD_ONLY = iutest_break_on_failure_tests \ diff --git a/test/GNUmakefile b/test/GNUmakefile index 20c16bfd71..a9eefd9f07 100644 --- a/test/GNUmakefile +++ b/test/GNUmakefile @@ -352,7 +352,7 @@ $(TARGETS_EXCLUDE_ALLTESTS) : $(SRCS) $(IUTEST_HEADERS) $(MAKEFILE) $(ERR_TARGETS) : $(SRCS) $(IUTEST_HEADERS) $(MAKEFILE) #-$(CXX) $(IUTEST_INCLUDE) $(CXXFLAGS) -o $@ $@.cpp $(IUTEST_LIB_) $(LDFLAGS) - -$(CXX) $(IUTEST_INCLUDE) $(CXXFLAGS) -o $@ $@.cpp $(IUTEST_LIB_) $(LDFLAGS) 2>&1 | python ../tools/python/iutest_compile_error_test.py -c $(CXX) + $(CXX) $(IUTEST_INCLUDE) $(CXXFLAGS) -o $@ $@.cpp $(IUTEST_LIB_) $(LDFLAGS) 2>&1 | python ../tools/python/iutest_compile_error_test.py -c $(CXX) endif diff --git a/test/iutest_check_strict_tests.cpp b/test/iutest_check_strict_tests.cpp index b5c4b5172d..fc11147cf7 100644 --- a/test/iutest_check_strict_tests.cpp +++ b/test/iutest_check_strict_tests.cpp @@ -29,7 +29,7 @@ class TestFixture : public ::iutest::Test virtual void SetUp() {} }; -IUTEST_TEST_COMPILEERROR("TestFixture is fixture class, mistake the IUTEST_F?") +IUTEST_TEST_STATICASSERT("TestFixture is fixture class, mistake the IUTEST_F?") IUTEST(TestFixture, Test) { } diff --git a/test/iutest_static_assertion_failure_tests.cpp b/test/iutest_static_assertion_failure_tests.cpp index 89ca9cb46a..469bbd65bf 100644 --- a/test/iutest_static_assertion_failure_tests.cpp +++ b/test/iutest_static_assertion_failure_tests.cpp @@ -19,16 +19,21 @@ #if IUTEST_HAS_STATIC_ASSERT_TYPEEQ -IUTEST_TEST_COMPILEERROR("false") +templatestruct test_struct : public iutest_type_traits::bool_constant {}; + +IUTEST_TEST_COMPILEERROR("static_assert_typeeq") bool b = ::iutest::StaticAssertTypeEq(); IUTEST(StaticAssertTypeEqTest, Fail) { - IUTEST_TEST_COMPILEERROR("false") + IUTEST_TEST_COMPILEERROR("static_assert_typeeq") ::iutest::StaticAssertTypeEq(); - IUTEST_TEST_COMPILEERROR("false") + IUTEST_TEST_STATICASSERT("static_assert") IUTEST_STATIC_ASSERT(false); + + IUTEST_TEST_STATICASSERT("static_assert") + IUTEST_STATIC_ASSERT(test_struct::value); } #endif diff --git a/tools/python/iutest_compile_error_test.py b/tools/python/iutest_compile_error_test.py index 264a8756a2..8007df8736 100644 --- a/tools/python/iutest_compile_error_test.py +++ b/tools/python/iutest_compile_error_test.py @@ -59,17 +59,17 @@ def is_warning(self): def has_error(self): if self.type == "error": return True - elif self.parent: - return self.parent.has_error() + elif self.parent and self.parent.has_error_parent(): + return True + elif self.child and self.child.has_error_child(): + return True return False def has_error_parent(self): if self.type == "error": return True - elif self.parent and self.parent.has_error_parent(): - return True - elif self.child and self.child.has_error_child(): - return True + elif self.parent: + return self.parent.has_error() return False def has_error_parent(self): @@ -164,6 +164,7 @@ def parse_gcc_clang(options, f, r_expansion, note_is_child): re_infile = re.compile(r'In file included from (\S+):(\d+):(\d+)(.*)') re_message = re.compile(r'.*:\d+:\d+: (\S*): (.*)') re_expansion = re.compile(r_expansion) + re_declaration = re.compile(r'.*declaration of\s*(.*)') msg_list = [] msg = None prev = None @@ -193,7 +194,12 @@ def parse_gcc_clang(options, f, r_expansion, note_is_child): is_child = note_is_child and msg.is_note() is_type_none = prev and prev.is_type_none() - if is_child or is_type_none or re_expansion.search(msg.message): + is_declaration = False + n = re_declaration.match(line) + if n and prev and prev.message.find(n.group(1)) != -1: + is_declaration = True + + if is_child or is_type_none or is_declaration or re_expansion.search(msg.message): prev.child = msg msg.parent = prev else: @@ -217,7 +223,7 @@ def parse_clang(options, f): # parse_vc def parse_vc(options, f): re_fatal = re.compile(r'(\S+)\s*:\s*fatal\s*error\s*.*') - re_file = re.compile(r'(\S+)\((\d+)\)\s*:') + re_file = re.compile(r'(\s*)(\S+)\((\d+)\)\s*:\s*(.*)') re_message = re.compile(r'.*\(\d+\)\s*: (\S*) (\S*: .*)') msg_list = [] msg = None @@ -233,13 +239,20 @@ def parse_vc(options, f): msg_list.append(msg) prev = msg msg = ErrorMessage() - msg.file = m.group(1) - msg.line = int(m.group(2)) + msg.file = m.group(2) + msg.line = int(m.group(3)) msg.type = "" n = re_message.match(line) if n: msg.set_type(n.group(1)) msg.message += n.group(2) + else: + msg.set_type('') + msg.message += m.group(4) + + if m.group(1) and prev: + prev.child = msg + msg.parent = prev else: if msg: msg.message += '\n' @@ -256,7 +269,10 @@ def dump_msg(m): else: print "%s:%d: %s: %s" % (m.file, m.line, m.type, m.message) else: - print "%s(%d): %s %s" % (m.file, m.line, m.type, m.message) + if m.parent: + print "\t%s(%d): %s %s" % (m.file, m.line, m.type, m.message) + else: + print "%s(%d): %s %s" % (m.file, m.line, m.type, m.message) def dump_msgs(m): @@ -311,7 +327,7 @@ def iutest(l): if mm: if msg.parent: continue - if check: + if check and not check.checked: dump_msg(check) test_result(False, re_m.group(0), check) check = None @@ -320,14 +336,14 @@ def iutest(l): check = msg re_m = mm elif msg.has_error(): - #print '%s - %d' % (msg.file, msg.line) + #print '%s - %d' % (msg.file, msg.line) if check and msg.file in check.file and msg.line == check.line+1: actual = msg.get_error() expect = re_m.group(1).strip('"') - if actual.message.find(expect) != -1: - check = None - e = None + if not expect or actual.message.find(expect) != -1: + check.checked = True msg.checked = True + e = None test_result(True, re_m.group(0), check) elif msg.is_tail() and not msg.is_checked(): dump_msgs(msg) @@ -335,7 +351,7 @@ def iutest(l): elif msg.is_warning(): dump_msg(msg) - if check: + if check and not check.checked: test_result(False, re_m.group(0), check) result = False return result