Closed nilssass closed 8 months ago
I don't quite get the point with the unit test for index44(). Do you want to test whether integer addition and multiplication works OK? If it doesn't I think it would signal a dead CPU ...
Hi @yukarpenko, the philosophy of unit tests is to ensure that all parts of a code work as expected. This might sound trivial at some places but especially if information is passed between several stages, one would be surprised how many errors one does not anticipate from even simple functions. In this very case the unit test for index44() runs through all possible valid variables and ensures that it returns the expected values. This does not change the behavior of the code itself, it just builds test executables that can be ran after changes in the code to ensure that nothing broke.
However, this PR is mainly meant to start tests and start with the easiest example in gen(). This is because I am currently working on sampling spin from the hypersurface, meaning to add quite some functions that interact with the code at several places. For these functions I definitely need tests to make sure that every possible error is caught and does not brake the code.
I hope this clarified my need for this PR :)
ok it is understandable if it is only the start with the unit tests. I would expect that there are much less trivial places in the code which would benefit from such.
A git thing: from my side, I see the error "Merging is blocked The base branch does not allow updates." Were some branch setting changed? Or it was like that but noone was doing a merge into the main branch yet?
Yes merging is indeed blocked because a year ago we decided to have different main
and develop
branches. This is necessary because of the close interlocking of SMASH and the sampler, so if SMASH updates on develop, we might need changes in the sampler too, but we don't want the main branch to be broken wrt tagged SMASH.
Therefore, features are to be merged into the develop
branch.
ok it is understandable if it is only the start with the unit tests. I would expect that there are much less trivial places in the code which would benefit from such.
Yes, this is definitely meant to have some starting point. I didn't want to add an empty file, so I took the easiest case, just to have it not empty and to set up the structure so that people know how to proceed. In the future there will be way more non trivial tests and also tests for the other files.
Then I will change this PR and merge it into develop
@yukarpenko I have changed the base branch, so that this PR will be merged into develop
. Do you agree to merge it?
Fine with me.
Great, thank you!
This PR adds unit tests to the sampler including one first test for gen::index44(...)