Test suite cleanups, convert Coord2D to Vector<T, 2>.
- The standard SimpleSuite setup now include flags to suppress printing the report in addition to silencing the test runs. This is useful in automated testing. - Point2D and Polar2D in Coord2D have been converted from custom types to Vector<int, 2> and Vector<double, 2>, respectively.
This commit is contained in:
@@ -219,15 +219,37 @@ geomRotatePointsAboutOrigin()
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
pointDistances()
|
||||
{
|
||||
const Point2D origin;
|
||||
const Point2D y2(0, 2);
|
||||
const Point2D x2(2, 0);
|
||||
const int dist2 = 2;
|
||||
const int dist10 = 10;
|
||||
const Point2D deg45{8, 6};
|
||||
|
||||
SCTEST_CHECK_EQ(y2.Distance(origin), dist2);
|
||||
SCTEST_CHECK_EQ(x2.Distance(origin), dist2);
|
||||
SCTEST_CHECK_EQ(deg45.Distance(origin), dist10);
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
auto noReport = false;
|
||||
auto quiet = false;
|
||||
auto flags = new scsl::Flags("test_orientation",
|
||||
"This test validates various orientation-related components in scmp.");
|
||||
flags->Register("-n", false, "don't print the report");
|
||||
flags->Register("-q", false, "suppress test output");
|
||||
|
||||
auto parsed = flags->Parse(argc, argv);
|
||||
@@ -237,6 +259,7 @@ main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
SimpleSuite suite;
|
||||
flags->GetBool("-n", noReport);
|
||||
flags->GetBool("-q", quiet);
|
||||
if (quiet) {
|
||||
suite.Silence();
|
||||
@@ -248,9 +271,10 @@ main(int argc, char *argv[])
|
||||
suite.AddTest("geomComparePoint2D", geomComparePoint2D);
|
||||
suite.AddTest("geomRotatePoint2D", geomRotatePoint2D);
|
||||
suite.AddTest("geomRotatePointsAboutOrigin", geomRotatePointsAboutOrigin);
|
||||
suite.AddTest("pointDistances", pointDistances);
|
||||
|
||||
delete flags;
|
||||
auto result = suite.Run();
|
||||
std::cout << suite.GetReport() << "\n";
|
||||
if (!noReport) { std::cout << suite.GetReport() << "\n"; }
|
||||
return result ? 0 : 1;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
#include <cmath>
|
||||
#include <sstream>
|
||||
|
||||
#include <scsl/Flags.h>
|
||||
|
||||
#include <scmp/geom/Vector.h>
|
||||
#include <scmp/geom/Quaternion.h>
|
||||
#include <scmp/Math.h>
|
||||
#include <scmp/filter/Madgwick.h>
|
||||
|
||||
#include <scmp/filter/Madgwick.h>
|
||||
#include <sctest/Assert.h>
|
||||
#include <sctest/Checks.h>
|
||||
#include <sctest/SimpleSuite.h>
|
||||
|
||||
|
||||
using namespace std;
|
||||
using namespace scmp;
|
||||
|
||||
@@ -231,10 +234,25 @@ SimpleAngularOrientation2InitialQuaterniond()
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
auto quiet = false;
|
||||
auto noReport = false;
|
||||
auto flags = new scsl::Flags("test_madgwick",
|
||||
"This test validates the Madgwick filter code");
|
||||
flags->Register("-n", false, "don't print the report");
|
||||
flags->Register("-q", false, "suppress test output");
|
||||
|
||||
auto parsed = flags->Parse(argc, argv);
|
||||
if (parsed != scsl::Flags::ParseStatus::OK) {
|
||||
std::cerr << "Failed to parse flags: "
|
||||
<< scsl::Flags::ParseStatusToString(parsed) << "\n";
|
||||
}
|
||||
|
||||
sctest::SimpleSuite suite;
|
||||
flags->GetBool("-n", noReport);
|
||||
flags->GetBool("-q", quiet);
|
||||
if (quiet) {
|
||||
suite.Silence();
|
||||
}
|
||||
|
||||
suite.AddTest("SimpleAngularOrientationFloat",
|
||||
SimpleAngularOrientationFloat);
|
||||
@@ -253,8 +271,8 @@ main(int argc, char **argv)
|
||||
suite.AddTest("SimpleAngularOrientationDouble (inital quaterniond)",
|
||||
SimpleAngularOrientation2InitialQuaterniond);
|
||||
|
||||
delete flags;
|
||||
auto result = suite.Run();
|
||||
|
||||
std::cout << suite.GetReport() << "\n";
|
||||
if (!noReport) { std::cout << suite.GetReport() << "\n"; }
|
||||
return result ? 0 : 1;
|
||||
}
|
||||
|
||||
@@ -122,9 +122,11 @@ RotateRadians()
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
auto noReport = false;
|
||||
auto quiet = false;
|
||||
auto flags = new scsl::Flags("test_orientation",
|
||||
"This test validates various orientation-related components in scmp.");
|
||||
flags->Register("-n", false, "don't print the report");
|
||||
flags->Register("-q", false, "suppress test output");
|
||||
|
||||
auto parsed = flags->Parse(argc, argv);
|
||||
@@ -134,6 +136,7 @@ main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
sctest::SimpleSuite suite;
|
||||
flags->GetBool("-n", noReport);
|
||||
flags->GetBool("-q", quiet);
|
||||
if (quiet) {
|
||||
suite.Silence();
|
||||
@@ -147,6 +150,6 @@ main(int argc, char *argv[])
|
||||
|
||||
delete flags;
|
||||
auto result = suite.Run();
|
||||
std::cout << suite.GetReport() << "\n";
|
||||
if (!noReport) { std::cout << suite.GetReport() << "\n"; }
|
||||
return result ? 0 : 1;
|
||||
}
|
||||
|
||||
@@ -88,9 +88,11 @@ Orientation3d_Heading()
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
auto noReport = false;
|
||||
auto quiet = false;
|
||||
auto flags = new scsl::Flags("test_orientation",
|
||||
"This test validates various orientation-related components in scmp.");
|
||||
flags->Register("-n", false, "don't print the report");
|
||||
flags->Register("-q", false, "suppress test output");
|
||||
|
||||
auto parsed = flags->Parse(argc, argv);
|
||||
@@ -100,6 +102,7 @@ main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
SimpleSuite suite;
|
||||
flags->GetBool("-n", noReport);
|
||||
flags->GetBool("-q", quiet);
|
||||
if (quiet) {
|
||||
suite.Silence();
|
||||
@@ -114,6 +117,6 @@ main(int argc, char *argv[])
|
||||
|
||||
delete flags;
|
||||
auto result = suite.Run();
|
||||
std::cout << suite.GetReport() << "\n";
|
||||
if (!noReport) { std::cout << suite.GetReport() << "\n"; }
|
||||
return result ? 0 : 1;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#include <cmath>
|
||||
#include <sstream>
|
||||
|
||||
#include <scsl/Flags.h>
|
||||
#include <scmp/geom/Quaternion.h>
|
||||
|
||||
#include <sctest/Checks.h>
|
||||
#include <sctest/SimpleSuite.h>
|
||||
|
||||
@@ -427,9 +427,27 @@ QuaternionMiscellanous_InitializerConstructor()
|
||||
|
||||
|
||||
int
|
||||
main(void)
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
auto noReport = false;
|
||||
auto quiet = false;
|
||||
auto flags = new scsl::Flags("test_quaternion",
|
||||
"This test validates the Quaternion class.");
|
||||
flags->Register("-n", false, "don't print the report");
|
||||
flags->Register("-q", false, "suppress test output");
|
||||
|
||||
auto parsed = flags->Parse(argc, argv);
|
||||
if (parsed != scsl::Flags::ParseStatus::OK) {
|
||||
std::cerr << "Failed to parse flags: "
|
||||
<< scsl::Flags::ParseStatusToString(parsed) << "\n";
|
||||
}
|
||||
|
||||
SimpleSuite suite;
|
||||
flags->GetBool("-n", noReport);
|
||||
flags->GetBool("-q", quiet);
|
||||
if (quiet) {
|
||||
suite.Silence();
|
||||
}
|
||||
|
||||
suite.AddTest("Quaternion_SelfTest", Quaternion_SelfTest);
|
||||
suite.AddTest("QuaternionMiscellanous_InitializerConstructor",
|
||||
@@ -465,7 +483,8 @@ main(void)
|
||||
suite.AddTest("Quaternionf_Unit", Quaternionf_Unit);
|
||||
suite.AddTest("Quaternionf_UtilityCreator", Quaternionf_UtilityCreator);
|
||||
|
||||
delete flags;
|
||||
auto result = suite.Run();
|
||||
std::cout << suite.GetReport() << "\n";
|
||||
if (!noReport) { std::cout << suite.GetReport() << "\n"; }
|
||||
return result ? 0 : 1;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <scsl/Flags.h>
|
||||
#include <sctest/SimpleSuite.h>
|
||||
|
||||
|
||||
@@ -52,16 +53,36 @@ static bool nope() { return 2 + 2 == 5; }
|
||||
|
||||
|
||||
int
|
||||
main()
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
auto noReport = false;
|
||||
auto quiet = false;
|
||||
auto flags = new scsl::Flags("test_orientation",
|
||||
"This test validates various orientation-related components in scmp.");
|
||||
flags->Register("-n", false, "don't print the report");
|
||||
flags->Register("-q", false, "suppress test output");
|
||||
|
||||
auto parsed = flags->Parse(argc, argv);
|
||||
if (parsed != scsl::Flags::ParseStatus::OK) {
|
||||
std::cerr << "Failed to parse flags: "
|
||||
<< scsl::Flags::ParseStatusToString(parsed) << "\n";
|
||||
}
|
||||
|
||||
sctest::SimpleSuite suite;
|
||||
flags->GetBool("-n", noReport);
|
||||
flags->GetBool("-q", quiet);
|
||||
if (quiet) {
|
||||
suite.Silence();
|
||||
}
|
||||
|
||||
suite.Setup(prepareTests);
|
||||
suite.Teardown(destroyTests);
|
||||
suite.AddTest("1 + 1", addOne);
|
||||
suite.AddTest("fourness", four);
|
||||
suite.AddFailingTest("self-evident truth", nope);
|
||||
auto result = suite.Run();
|
||||
|
||||
std::cout << suite.GetReport() << "\n";
|
||||
delete flags;
|
||||
auto result = suite.Run();
|
||||
if (!noReport) { std::cout << suite.GetReport() << "\n"; }
|
||||
return result ? 0 : 1;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
|
||||
#include <scsl/Flags.h>
|
||||
#include <scsl/StringUtil.h>
|
||||
#include <sctest/Assert.h>
|
||||
#include <sctest/SimpleSuite.h>
|
||||
@@ -135,9 +136,27 @@ TestWrapping()
|
||||
|
||||
|
||||
int
|
||||
main()
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
auto noReport = false;
|
||||
auto quiet = false;
|
||||
auto flags = new scsl::Flags("test_orientation",
|
||||
"This test validates various orientation-related components in scmp.");
|
||||
flags->Register("-n", false, "don't print the report");
|
||||
flags->Register("-q", false, "suppress test output");
|
||||
|
||||
auto parsed = flags->Parse(argc, argv);
|
||||
if (parsed != scsl::Flags::ParseStatus::OK) {
|
||||
std::cerr << "Failed to parse flags: "
|
||||
<< scsl::Flags::ParseStatusToString(parsed) << "\n";
|
||||
}
|
||||
|
||||
sctest::SimpleSuite suite;
|
||||
flags->GetBool("-n", noReport);
|
||||
flags->GetBool("-q", quiet);
|
||||
if (quiet) {
|
||||
suite.Silence();
|
||||
}
|
||||
|
||||
TestTrimming(" foo\t ", "foo\t ", " foo", "foo");
|
||||
TestTrimming(" foo\tbar ", "foo\tbar ", " foo\tbar", "foo\tbar");
|
||||
@@ -155,7 +174,9 @@ main()
|
||||
std::vector<std::string>{"abc", "", "def", "ghi"}));
|
||||
suite.AddTest("TestSplitKV(char)", TestSplitChar);
|
||||
suite.AddTest("TextWrapping", TestWrapping);
|
||||
|
||||
delete flags;
|
||||
auto result = suite.Run();
|
||||
std::cout << suite.GetReport() << "\n";
|
||||
if (!noReport) { std::cout << suite.GetReport() << "\n"; }
|
||||
return result ? 0 : 1;
|
||||
}
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <scmp/geom/Vector.h>
|
||||
#include <sctest/SimpleSuite.h>
|
||||
#include <sctest/Checks.h>
|
||||
#include "scsl/Flags.h"
|
||||
|
||||
|
||||
using namespace scmp;
|
||||
@@ -428,9 +429,28 @@ Vector3DoubleTests_CrossProduct()
|
||||
|
||||
|
||||
int
|
||||
main()
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
auto noReport = false;
|
||||
auto quiet = false;
|
||||
auto flags = new scsl::Flags("test_vector",
|
||||
"This test validates the vector implementation.");
|
||||
flags->Register("-n", false, "don't print the report");
|
||||
flags->Register("-q", false, "suppress test output");
|
||||
|
||||
auto parsed = flags->Parse(argc, argv);
|
||||
if (parsed != scsl::Flags::ParseStatus::OK) {
|
||||
std::cerr << "Failed to parse flags: "
|
||||
<< scsl::Flags::ParseStatusToString(parsed) << "\n";
|
||||
}
|
||||
|
||||
SimpleSuite suite;
|
||||
flags->GetBool("-n", noReport);
|
||||
flags->GetBool("-q", quiet);
|
||||
if (quiet) {
|
||||
suite.Silence();
|
||||
}
|
||||
|
||||
suite.AddTest("Vector3Miscellaneous_ExtractionOperator3d",
|
||||
Vector3Miscellaneous_ExtractionOperator3d);
|
||||
suite.AddTest("Vector3Miscellaneous_ExtractionOperator3f",
|
||||
@@ -485,8 +505,9 @@ main()
|
||||
Vector3DoubleTests_Projections);
|
||||
suite.AddTest("Vector3DoubleTests_CrossProduct",
|
||||
Vector3DoubleTests_CrossProduct);
|
||||
auto result = suite.Run();
|
||||
|
||||
std::cout << suite.GetReport() << "\n";
|
||||
delete flags;
|
||||
auto result = suite.Run();
|
||||
if (!noReport) { std::cout << suite.GetReport() << "\n"; }
|
||||
return result ? 0 : 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user