Comments (7)
Sorry for the late response. I wasn't sure what should be done about it but after some thinking, I get into the conclusion that we don't wanna print in all cases and hence it's better not to print it all not to confuse the users 🤔 But I'm happy to be
convinced otherwise ☝️
To illustrate what I'm talking about let's magine the case that after the fatal assertion we will try to print out range value - that would sig segv 😞
std::vector v{1, 2, 3};
(std::size(v) == 3_i >> fatal) << "incorrect" << v[4];
from ut.
Wouldn't that be an issue even if the assertion was not fatal or am I missing something?
from ut.
Yes, it would but that's why you would use a fatal assertion to avoid it, right?
from ut.
Aww, I see what you mean. What if a user wants helpful error information when a fatal assertion occurs? This is my use case.
from ut.
I understand the use case (which is obviously a valid one) just have concerns that by allowing streaming anything after fatal assertion the guarantee that the assertion will bail out and won't crash (the main purpose of it) may be broken. It's not an issue if you just print a string or something but it might be if a value out of range will be tried to be accessed. We potentially can allow just safe
output in the output stream after fatal so that the sig segv ain't gonna happen, not sure 🤔
from ut.
This appears to come down to a ease-of-use / safety problem. A user could just workaround this situation by using an if
statement to log output and then explicitly fail the test but this isn't very convenient. I like your idea about safe
output - I'm guessing safe
output would need to evaluate to a string at compile-time. Perhaps an opt-in approach could allow the unsafe
behavior, i.e.:
- Safe, compiles, and logs the given output as expected.
std::vector v{1, 2, 3};
(std::size(v) == 2_i >> fatal) << "Surprised?";
- Unsafe so it fails to compile.
std::vector v{1, 2, 3};
(std::size(v) == 3_i >> fatal) << "I like to play it safe." << v[4];
- Unsafe but compiles because the user explicitly opted in.
std::vector v{1, 2, 3};
(std::size(v) == 3_i >> fatal) << "I swear I know what I'm doing!" << unsafe << v[4];
from ut.
I don't understand the concern. The message will only be printed in the case that the assertion fails, right? So using the assertion to guard against some unsafe behavior in the message seems very strange.
In any case this is very counter to all other testing frameworks I've used and caused me a lot of wasted time trying to figure out where my test was failing.
from ut.
Related Issues (20)
- running clang-format on ut.hpp in master produces changes?
- 7 tests fail
- Would be nice if the _i operator accepted hex constants HOT 1
- Boost review process
- `using namespace boost::ut;` breaks piping views that are copied to local variable.
- Test crashes in aarch64 built with clang++ HOT 1
- clang-scan-deps fails on ut.hpp
- Tests fail due to global instances destroyed HOT 1
- Leak when a source file starts with an A
- std::cout blocked from printing, is there an option to set?
- Version 2.0.1 segfaults when using std::format and std::cout on multiple threads HOT 24
- aborts support on Windows?
- Tests are always skipped when ut is #included into a module
- Number of asserts is reported wrongly HOT 1
- Fatal expression with custom message compile error HOT 2
- Custom message for fatal expressions not shown
- Add the option to display a diff when comparing strings
- Unnecessary CPM.cmake to Get PackageProject.cmake
- Disable Install Targets If It Is a Subproject HOT 1
- SEGV when using Clang [12, 16] HOT 12
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ut.