The files wont get installed onto the system. They are just run during the test phase of the build process, often invoked using ctest for a cmake based build system.
C++ Unit testing framework up and running
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Re: C++ Unit testing framework up and running
Re: C++ Unit testing framework up and running
A PR is lodged. How does a reviewer/maintainer know the changes a) work, and b) don't change functionality?
Imagine if the PR includes tests
Without tests, reviewers are understandably cautious.
Tests are what makes fast merging possible (e.g. in C4) because a heavy burden is lifted off the reviewer's back.
Imagine if the PR includes tests
Code: Select all
TEST(Unit, FlowCheckThrowPos)
{
EXPECT_ANY_THROW(new Base::Unit("test",0,8,0,0,0,0,0,0));
}
TEST(Unit, GetString){
Base::Unit unit {"test",0,0,-8,0,0,0,0,0};
EXPECT_EQ(unit.getString(), "1/s^8");
}
TEST(Unit, GetStringElectricPotential){
Base::Unit unit {Base::UnitDefs::ElectricPotential};
EXPECT_EQ(unit.getString(), "mm^2*kg/(s^3*A)");
}
TEST(Unit, AsStringElectricPotential){
Base::Unit unit {Base::UnitDefs::ElectricPotential};
EXPECT_EQ(unit.asString(), "Unit: mm^2*kg/(s^3*A) (2,1,-3,-1,0,0,0,0) [ElectricPotential]");
}
TEST(Unit, NameString){
Base::Unit unit {"test",0,0,-8,0,0,0,0,0};
EXPECT_EQ(unit.nameStr(), "test");
}
Tests are what makes fast merging possible (e.g. in C4) because a heavy burden is lifted off the reviewer's back.
Re: C++ Unit testing framework up and running
Regarding using FetchContent -- according to the cMake documentation, FetchContent_MakeAvailable will use find_package first, and will only attempt to download the code itself if it cannot find it some other way. My understanding of our earlier discussion is that is basically exactly the behavior we want, right? It replicates the idea of having a git submodule, but only if that submodule is actually needed. @berniev I didn't follow the original discussion -- why did you end up removing that from the PR?
Re: C++ Unit testing framework up and running
I don't remember noticing that FetchContent_MakeAvailable will try find_package first. Good spot! I used it because it (from memory) was google's reccommended way.
I did have this in a PR, but while it languished The Boss did a commit sticking with the lib in the project source, so who was I to argue -- we were making progress. The next version was just a tidy-up of the directory structure without changing how the lib gets where it is.
I have no issue if you want to go that way.
I did have this in a PR, but while it languished The Boss did a commit sticking with the lib in the project source, so who was I to argue -- we were making progress. The next version was just a tidy-up of the directory structure without changing how the lib gets where it is.
I have no issue if you want to go that way.
Re: C++ Unit testing framework up and running
This discussion is very relevant to ongoing discussions re fmt library as well.
abdullah