Skip to content

Commit

Permalink
update r863
Browse files Browse the repository at this point in the history
  • Loading branch information
srz-zumix committed May 31, 2015
1 parent e0583e7 commit 079acf6
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 32 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*.sdf
*.opensdf
*.user
*.nupkg
coverage.info
test/*.xml
lib
2 changes: 1 addition & 1 deletion doc/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions include/internal/iutest_internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_
16 changes: 10 additions & 6 deletions include/iutest_static_assertion.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-2014, Takazumi Shirayanagi\n
* Copyright (C) 2012-2015, Takazumi Shirayanagi\n
* This software is released under the new BSD License,
* see LICENSE
*/
Expand Down Expand Up @@ -48,20 +48,24 @@ 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

/**
* @brief static_assert
*/
#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

Expand Down Expand Up @@ -120,9 +124,9 @@ struct StaticAssertTypeEqHelper
#endif

/** @private */
template<bool b>struct StaticAssertionFailure;
template<bool b>struct static_assert_failure;
/** @overload */
template<> struct StaticAssertionFailure<true> { enum { value = 1 }; };
template<> struct static_assert_failure<true> { enum { value = 1 }; };

/** @private */
template<int x>struct StaticAssertionTest {};
Expand Down
4 changes: 2 additions & 2 deletions include/iutest_ver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/CommonMakefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -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 \

2 changes: 1 addition & 1 deletion test/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion test/iutest_check_strict_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
}
Expand Down
11 changes: 8 additions & 3 deletions test/iutest_static_assertion_failure_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,21 @@

#if IUTEST_HAS_STATIC_ASSERT_TYPEEQ

IUTEST_TEST_COMPILEERROR("false")
template<bool a, bool b>struct test_struct : public iutest_type_traits::bool_constant<a> {};

IUTEST_TEST_COMPILEERROR("static_assert_typeeq")
bool b = ::iutest::StaticAssertTypeEq<int, float>();

IUTEST(StaticAssertTypeEqTest, Fail)
{
IUTEST_TEST_COMPILEERROR("false")
IUTEST_TEST_COMPILEERROR("static_assert_typeeq")
::iutest::StaticAssertTypeEq<float, int>();

IUTEST_TEST_COMPILEERROR("false")
IUTEST_TEST_STATICASSERT("static_assert")
IUTEST_STATIC_ASSERT(false);

IUTEST_TEST_STATICASSERT("static_assert")
IUTEST_STATIC_ASSERT(test_struct<false, false>::value);
}

#endif
50 changes: 33 additions & 17 deletions tools/python/iutest_compile_error_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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'
Expand All @@ -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):
Expand Down Expand Up @@ -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
Expand All @@ -320,22 +336,22 @@ 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)
result = False
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
Expand Down

0 comments on commit 079acf6

Please sign in to comment.