-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Automated registration of Unit test using boost test #1811
Conversation
Updates to use automated registration
Thanks for opening this pull request! It might take a while before we look at it, so don't worry if there seems to be no feedback. We'll get to it. |
@klausspanderen — maybe you can advise about the benchmark? |
Hi I think in this case we need to declare the benchmark test cases in quantlibbenchmark.cpp like
and change the registration towards
and replace the typedef fct_ptr by std::function<void(void)> |
I get a function undefined error in linux build. Not sure if declaring |
adds test case in quantlibbenchmark.cpp using std::bind
Hi @klausspanderen, I have updated the code with your suggested changes, however, the code fails to build on linux because of unresolved/undefined/redefinition issues. I think the reason why this happens is because the macro in
replaces the code with-
Since it is already defined and declared once in the americanoption.cpp file, doing it again in quantlibbenchmark.cpp causes redefinition. If I am not mistaken, the bind function is used to bind the One possible reason for the unresolved symbol error could be that the Please advise. |
I've added the PR#5 for your repo (from my branch test_reg). Important are just the changes to the test-suite folder. Maybe the compiled americanoption.cpp file was missing in the linker step? Please let me know if it doesn't work for you. |
declare benchmark test cases and add cpp to Makefile.am and CMakeLists.txt
Thanks so much! @klausspanderen |
…cpp and amortizingbond.cpp
Migrated asianoptions.cpp, array.cpp, andreasenhugevolatilityinterpl.…
Hi @lballabio @klausspanderen, please let me know if I'm moving in the right direction. We can keep this PR active, I'll keep adding more commits. |
Hi—yes, let's continue in this direction. Thanks! |
Automated test registration
Thanks
Thanks. I have added a similar fix in Makefile.am for linux build. |
@@ -149,9 +150,586 @@ namespace { | |||
f.enableExtrapolation(); | |||
return GaussLobattoIntegral(1000, 1e-6)(f, x.front(), x.back()); | |||
} | |||
|
|||
Real stationaryLogProbabilityFct(Real kappa, Real theta, |
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.
Don't roll back these changes; but since there are still lots of files to modify, in general I'd keep helper functions closer to the tests that use them. Incidentally, this would also reduce the diffs.
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.
Alright, I'll try to keep them as close as possible.
You will also find that in some files I have combined segregated functions belonging to same namespace into a single namespace at the top. The reason for that is that when BOOST_FIXTURE_TEST_SUITE
and BOOST_AUTO_TEST_SUITE
is declared, it creates a new namespace. If a namespace is declared before the fixture declaration- say namespace a
, that would act as a top-level namespace, however, if the same namespace is used to add more function in it between test cases, that declares a new namespace which is FixtureName::SuiteName::a
. To avoid conflicts and namespace errors I choose to restructure them and combine them into one before the fixture declaration.
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.
Oh, I see. In that case, you're right, do move them at the top.
So, should we merge what we have so far and continue in another PR? Or do you want to continue here? |
Co-authored-by: Luigi Ballabio <[email protected]>
yes, I think we can start merging. I'll finish migrating the remaining files in the next PR |
Ok, thanks. Later today I'll push a further fix to the check_test_times script and then I'll merge the PR. |
Congratulations on your first merged pull request! |
This is first step in #1780 to update the test-suite to use automated registration. The
toplevelfixture.hpp
is a fixture that fills in forQUANTLIB_TEST_CASE
macro which is to initialise and restore settings after each test case.The
QuantLibGlobalFixture
is used for a one-time setup and teardown (start/stop timer, read command line arguments, etc)The
struct if_speed
is used as a predicate in precondition for selected test cases where the test cases are run based on the speed of execution.I'm still researching on how to migrate
quantlibbenchmark.cpp
. Please suggest if you have any ideas!