snitch-org / snitch

Lightweight C++20 testing framework.
Boost Software License 1.0
252 stars 7 forks source link

Fix compilation error if expression length != message length #163

Closed cschreib closed 2 months ago

cschreib commented 2 months ago

Reported in #158. The *REQUIRE_THAT macros were assuming that SNITCH_MAX_MESSAGE_LENGTH and SNITCH_MAX_EXPR_LENGTH were the same. If they weren't, this would cause a compilation error. The tests have now been modified so none of the lengths are identical, to catch future instances of this problem.

Also fixes https://github.com/snitch-org/snitch/issues/164.

cschreib commented 2 months ago

I still need to update the approval test data. But first I need to fix another issue, which was highlighted by these test failures: in the XML or TeamCity reporters, we need to escape some of the strings before reporting them. When the resulting string is too long and truncated, there is a risk of truncating halfway through an escaped sequence, which would render the escaped string invalid. I opened the bug ticket https://github.com/snitch-org/snitch/issues/164 to capture this.

I'm working on a solution.

codecov[bot] commented 2 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 94.05%. Comparing base (ccd3afa) to head (65ee518). Report is 7 commits behind head on main.

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/snitch-org/snitch/pull/163/graphs/tree.svg?width=650&height=150&src=pr&token=X422DE81PN&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=snitch-org)](https://app.codecov.io/gh/snitch-org/snitch/pull/163?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=snitch-org) ```diff @@ Coverage Diff @@ ## main #163 +/- ## ========================================== + Coverage 93.87% 94.05% +0.18% ========================================== Files 27 27 Lines 1664 1698 +34 ========================================== + Hits 1562 1597 +35 + Misses 102 101 -1 ``` | [Files](https://app.codecov.io/gh/snitch-org/snitch/pull/163?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=snitch-org) | Coverage Δ | | |---|---|---| | [include/snitch/snitch\_registry.hpp](https://app.codecov.io/gh/snitch-org/snitch/pull/163?src=pr&el=tree&filepath=include%2Fsnitch%2Fsnitch_registry.hpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=snitch-org#diff-aW5jbHVkZS9zbml0Y2gvc25pdGNoX3JlZ2lzdHJ5LmhwcA==) | `82.85% <ø> (ø)` | | | [include/snitch/snitch\_string\_utility.hpp](https://app.codecov.io/gh/snitch-org/snitch/pull/163?src=pr&el=tree&filepath=include%2Fsnitch%2Fsnitch_string_utility.hpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=snitch-org#diff-aW5jbHVkZS9zbml0Y2gvc25pdGNoX3N0cmluZ191dGlsaXR5LmhwcA==) | `100.00% <ø> (ø)` | | | [src/snitch\_reporter\_catch2\_xml.cpp](https://app.codecov.io/gh/snitch-org/snitch/pull/163?src=pr&el=tree&filepath=src%2Fsnitch_reporter_catch2_xml.cpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=snitch-org#diff-c3JjL3NuaXRjaF9yZXBvcnRlcl9jYXRjaDJfeG1sLmNwcA==) | `94.59% <100.00%> (+0.07%)` | :arrow_up: | | [src/snitch\_reporter\_teamcity.cpp](https://app.codecov.io/gh/snitch-org/snitch/pull/163?src=pr&el=tree&filepath=src%2Fsnitch_reporter_teamcity.cpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=snitch-org#diff-c3JjL3NuaXRjaF9yZXBvcnRlcl90ZWFtY2l0eS5jcHA=) | `100.00% <100.00%> (ø)` | | | [src/snitch\_string\_utility.cpp](https://app.codecov.io/gh/snitch-org/snitch/pull/163?src=pr&el=tree&filepath=src%2Fsnitch_string_utility.cpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=snitch-org#diff-c3JjL3NuaXRjaF9zdHJpbmdfdXRpbGl0eS5jcHA=) | `100.00% <100.00%> (ø)` | | ... and [2 files with indirect coverage changes](https://app.codecov.io/gh/snitch-org/snitch/pull/163/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=snitch-org) ------ [Continue to review full report in Codecov by Sentry](https://app.codecov.io/gh/snitch-org/snitch/pull/163?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=snitch-org). > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=snitch-org) > `Δ = absolute (impact)`, `ø = not affected`, `? = missing data` > Powered by [Codecov](https://app.codecov.io/gh/snitch-org/snitch/pull/163?dropdown=coverage&src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=snitch-org). Last update [ccd3afa...65ee518](https://app.codecov.io/gh/snitch-org/snitch/pull/163?dropdown=coverage&src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=snitch-org). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=snitch-org).