-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Port to C++11/C++14 removing superflous Boost facilities #88
Conversation
937c321
to
ec41d7c
Compare
9e9b5ed
to
f51dce4
Compare
@mat007 I'm done for the first step, appveyor failure is doc generation related and just a HTTP error. I'll rebase once #90 is merged to make this a bit smaller but you can have a look already. Next step would be replacing Boost.PP usage by variadic templates which should make the code much more understandable. If wanted I can try to port the inclusion of the benchmarks into the build to current master so we can compare build times before/after for those. Note that those are not fully accurate as one can assume the std headers are used already while the benchmarks assume a "clean state" |
@mat007 Ready. The decreased coverage is due to https://coveralls.io/builds/32087216/source?filename=include/turtle/detail/expectation_template.hpp where I reduced the number of lines by 7 which causes a decrease in relative coverage. Might be worth checking if we can test the currently uncovered serialization functions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work on the code makeover, thanks for doing this!
I’m not totally convinced on the testing of the documentation code though, I understand the value but this adds many visible side effects for the users to wonder why they’re in the docs.
Can’t we split these out to a different PR so that we can merge the rest?
doc/example/getting_started.cpp
Outdated
{ | ||
mock_view v; | ||
calculator c( v ); | ||
MOCK_EXPECT( v.display ).once().with( 0 ); // missing returns( true ) | ||
c.add( 0, 0 ); | ||
assert_failure("missing action"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is showing up in the docs, I don’t think this was intentional, was it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is. The docs say that at this point a test assertion fails that an action is missing. This highlights it AND actually tests it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m thinking some newcomers will be puzzled by this line, especially since the definition for assert_failure
will not be visible.
There should maybe at least be a comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we upgrade the required boost version to 1.59 (or higher) we can use assertions in fixtures teardown
- Initial support via
BOOST_AUTO_TEST_CASE(test, *utf::fixture<MixFixture>)
is in 1.59 - Better in 1.65 via
BOOST_FIXTURE_TEST_CASE(test, MyFixture)
(like now but teardown() is supported in 1.65+)
What shall it be?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think 1.65 is fine if that helps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Upgraded that for new CI
As many comments are for code style: would you mind creating a clangformat file for clangformat 9 which I could use? I find it pretty hard to guess how to do that otherwise... Or if you don't care which style is used I could use one from another project. Avoids the bikeshedding and confusion... About the docs: sure I can extract that but this would be hard as I had to fix them and used the new changes already there. So they would need to be merged afterwards. But then I feel that test coverage is missing. Some macros are only used there and I might miss a bug. I'll address the other comments next week when I work on this again. A style guide or definition until then would be nice. Check https://github.com/Return-To-The-Roots or https://github.com/boostorg/nowide for example configs which would be easiest |
I rebased this to current master to resolve the conflict. @mat007 I'm still waiting for your call on using clang-format which would greatly reduce the work for keeping the formatting uniform. |
@mat007 Kindly requesting on guidance how to continue on this. If wanted we could meet in a chat or so if there is stuff for discussion so it is faster than through github. I'd like to build more stuff on top of this like replacing the preprocessor generated implementations by variadic templates to make it easier to read and debug and using a macro that allows method specifiers (const, ref qualifiers) and especially override support. This will make the mock much safer and avoids many warnings we have in our code. |
Sorry, I’ve been away quite a lot over the summer.
I don’t care as long as it’s used everywhere in the code.
I liked how the reference documentation only explained each bit one at a time, but I can understand how making sure it compiles helps. Again, sorry for my poor reactivity this last couple of months! |
Tests via Fixture::teardown that the assertion is fulfilled
…r_passed_as_parameter_of_a_mock_method Only show what is required
I.e. it means the maximum allowed difference, similar to how other testing frameworks handle this and it allows a threshold of 0 to mean "equal"
This is allowed in C++20 and doesn't need to be tested anyway.
8ec89dc
to
182e070
Compare
This avoids false positives when warnings-as-error is enabled
6bce285
to
9551dea
Compare
@mat007 After some heavy fighting against the CI and some peculiarities of the Ubuntu linker I finally managed to get this working on CI again including the coverage report. After this is merged I can quickly add the formatting as discussed in #97 |
}; | ||
template<typename T> | ||
using parameter_type_t = typename parameter_type<T>::type; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to use boost::callable_traits for parameter type deduction instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be possible. But similar to is_callable
this only supports simple methods which seemingly is(/was?) enough, so this (much smaller) implementation should suffice.
And Boost.CallableTraits was introduced in Boost 1.66, i.e. it would need another increase in the minimum Boost version required which I wanted to avoid at the time of writing this.
{}; | ||
template<typename T> | ||
struct is_callable: is_callable_impl< std::remove_cv_t<T> > | ||
{}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really. I tried to translate what was there before and this whole thing isn't really good anyway: Besides a plain function there isn't a Type "callable" (this trait only takes a single parameter!)
Actually you would need to check if you can invoke something with specific parameters as is_invocable
does. But we don't have those.
So a better name would be e.g. is_function
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Flamefire this is a huge achievement, and I have to tip my hat off to you for your commitment! 😁
I can either merge the PR, or I can add you as a collaborator to the project and you can merge it yourself? (you don’t have to accept if you don’t feel like it, no worries)
{ | ||
mock_concept b; | ||
MOCK_EXPECT(b.method_int).once().with(42); | ||
MOCK_EXPECT(b.method_string).once().with(mock::equal(std::string("string"))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still think mock::equal<std::string>
is a bit clearer, as in meaning «equal as a string», but that’s pretty minor.
Either is fine for me ;) |
This addresses #69 by replacing Boost components for which equivalents or improved versions in C++11/14 exist.
This will reduce compile times for real world projects and potentially make test easier to debug.