Fix CAPTURE macro for nontrivial uses

The previous implemetation was just plain broken for most of
possible uses, the new one should work (even though it is ugly
as all hell, and should be improved ASAP).

Fixes #1436
This commit is contained in:
Martin Hořeňovský
2018-11-19 23:06:06 +01:00
parent 77f29c2f1c
commit 59087f74d9
9 changed files with 217 additions and 33 deletions

View File

@@ -228,6 +228,8 @@ Approx.tests.cpp:<line number>: passed: NAN != Approx(NAN) for: nanf != Approx(
Approx.tests.cpp:<line number>: passed: !(NAN == Approx(NAN)) for: !(nanf == Approx( nan ))
Tricky.tests.cpp:<line number>: passed: y.v == 0 for: 0 == 0
Tricky.tests.cpp:<line number>: passed: 0 == y.v for: 0 == 0
Message.tests.cpp:<line number>: passed: with 7 messages: 'a := 1' and 'b := 2' and 'c := 3' and 'a + b := 3' and 'a+b := 3' and 'c > b := true' and 'a == 1 := true'
Message.tests.cpp:<line number>: passed: with 7 messages: 'std::vector<int>{1, 2, 3}[0, 1, 2] := 3' and 'std::vector<int>{1, 2, 3}[(0, 1)] := 2' and 'std::vector<int>{1, 2, 3}[0] := 1' and '(helper_1436<int, int>{12, -12}) := { 12, -12 }' and '(helper_1436<int, int>(-12, 12)) := { -12, 12 }' and '(1, 2) := 2' and '(2, 3) := 3'
ToStringGeneral.tests.cpp:<line number>: passed: true with 1 message: 'i := 2'
ToStringGeneral.tests.cpp:<line number>: passed: true with 1 message: '3'
ToStringGeneral.tests.cpp:<line number>: passed: tab == '\t' for: '\t' == '\t'

View File

@@ -1126,6 +1126,6 @@ due to unexpected exception with message:
Why would you throw a std::string?
===============================================================================
test cases: 226 | 170 passed | 52 failed | 4 failed as expected
assertions: 1308 | 1176 passed | 111 failed | 21 failed as expected
test cases: 228 | 172 passed | 52 failed | 4 failed as expected
assertions: 1310 | 1178 passed | 111 failed | 21 failed as expected

View File

@@ -2108,6 +2108,38 @@ Tricky.tests.cpp:<line number>: PASSED:
with expansion:
0 == 0
-------------------------------------------------------------------------------
CAPTURE can deal with complex expressions
-------------------------------------------------------------------------------
Message.tests.cpp:<line number>
...............................................................................
Message.tests.cpp:<line number>: PASSED:
with messages:
a := 1
b := 2
c := 3
a + b := 3
a+b := 3
c > b := true
a == 1 := true
-------------------------------------------------------------------------------
CAPTURE can deal with complex expressions involving commas
-------------------------------------------------------------------------------
Message.tests.cpp:<line number>
...............................................................................
Message.tests.cpp:<line number>: PASSED:
with messages:
std::vector<int>{1, 2, 3}[0, 1, 2] := 3
std::vector<int>{1, 2, 3}[(0, 1)] := 2
std::vector<int>{1, 2, 3}[0] := 1
(helper_1436<int, int>{12, -12}) := { 12, -12 }
(helper_1436<int, int>(-12, 12)) := { -12, 12 }
(1, 2) := 2
(2, 3) := 3
-------------------------------------------------------------------------------
Capture and info messages
Capture should stringify like assertions
@@ -10432,6 +10464,6 @@ Misc.tests.cpp:<line number>
Misc.tests.cpp:<line number>: PASSED:
===============================================================================
test cases: 226 | 157 passed | 65 failed | 4 failed as expected
assertions: 1322 | 1176 passed | 125 failed | 21 failed as expected
test cases: 228 | 159 passed | 65 failed | 4 failed as expected
assertions: 1324 | 1178 passed | 125 failed | 21 failed as expected

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuitesloose text artifact
>
<testsuite name="<exe-name>" errors="17" failures="109" tests="1323" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
<testsuite name="<exe-name>" errors="17" failures="109" tests="1325" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
<testcase classname="<exe-name>.global" name="# A test name that starts with a #" time="{duration}"/>
<testcase classname="<exe-name>.global" name="#1005: Comparing pointer to int and long (NULL can be either on various systems)" time="{duration}"/>
<testcase classname="<exe-name>.global" name="#1027" time="{duration}"/>
@@ -141,6 +141,8 @@ Exception.tests.cpp:<line number>
<testcase classname="<exe-name>.global" name="Assertions then sections/A section/Another other section" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Assorted miscellaneous tests" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Bitfields can be captured (#1027)" time="{duration}"/>
<testcase classname="<exe-name>.global" name="CAPTURE can deal with complex expressions" time="{duration}"/>
<testcase classname="<exe-name>.global" name="CAPTURE can deal with complex expressions involving commas" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Capture and info messages/Capture should stringify like assertions" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Capture and info messages/Info should NOT stringify the way assertions do" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Character pretty printing/Specifically escaped" time="{duration}"/>

View File

@@ -1986,6 +1986,54 @@
</Expression>
<OverallResult success="true"/>
</TestCase>
<TestCase name="CAPTURE can deal with complex expressions" tags="[capture][messages]" filename="projects/<exe-name>/UsageTests/Message.tests.cpp" >
<Info>
a := 1
</Info>
<Info>
b := 2
</Info>
<Info>
c := 3
</Info>
<Info>
a + b := 3
</Info>
<Info>
a+b := 3
</Info>
<Info>
c > b := true
</Info>
<Info>
a == 1 := true
</Info>
<OverallResult success="true"/>
</TestCase>
<TestCase name="CAPTURE can deal with complex expressions involving commas" tags="[capture][messages]" filename="projects/<exe-name>/UsageTests/Message.tests.cpp" >
<Info>
std::vector&lt;int>{1, 2, 3}[0, 1, 2] := 3
</Info>
<Info>
std::vector&lt;int>{1, 2, 3}[(0, 1)] := 2
</Info>
<Info>
std::vector&lt;int>{1, 2, 3}[0] := 1
</Info>
<Info>
(helper_1436&lt;int, int>{12, -12}) := { 12, -12 }
</Info>
<Info>
(helper_1436&lt;int, int>(-12, 12)) := { -12, 12 }
</Info>
<Info>
(1, 2) := 2
</Info>
<Info>
(2, 3) := 3
</Info>
<OverallResult success="true"/>
</TestCase>
<TestCase name="Capture and info messages" filename="projects/<exe-name>/UsageTests/ToStringGeneral.tests.cpp" >
<Section name="Capture should stringify like assertions" filename="projects/<exe-name>/UsageTests/ToStringGeneral.tests.cpp" >
<Info>
@@ -12051,7 +12099,7 @@ loose text artifact
</Section>
<OverallResult success="true"/>
</TestCase>
<OverallResults successes="1176" failures="126" expectedFailures="21"/>
<OverallResults successes="1178" failures="126" expectedFailures="21"/>
</Group>
<OverallResults successes="1176" failures="125" expectedFailures="21"/>
<OverallResults successes="1178" failures="125" expectedFailures="21"/>
</Catch>