From e96d7ca1e03790d1efe22b5a15e77b486434e490 Mon Sep 17 00:00:00 2001 From: Lene Preuss Date: Fri, 28 Mar 2014 21:41:49 +0100 Subject: [PATCH] separated tests for ComplexFunction out of Test_Surface (#30) --- tests/Test_ComplexFunction.cpp | 54 ++++++++++++++++++++++++++++++++++ tests/Test_ComplexFunction.h | 36 +++++++++++++++++++++++ tests/Test_Surface.cpp | 53 --------------------------------- tests/Test_Surface.h | 28 ++++++++---------- tests/main.cpp | 6 ++-- tests/tests.pro | 2 ++ 6 files changed, 108 insertions(+), 71 deletions(-) create mode 100644 tests/Test_ComplexFunction.cpp create mode 100644 tests/Test_ComplexFunction.h diff --git a/tests/Test_ComplexFunction.cpp b/tests/Test_ComplexFunction.cpp new file mode 100644 index 00000000..c45ec2d2 --- /dev/null +++ b/tests/Test_ComplexFunction.cpp @@ -0,0 +1,54 @@ +/* + * File: Test_ComplexFunction.cpp + * Author: lene + * + * Created on March 28, 2014, 7:54 PM + */ + +#include "Test_ComplexFunction.h" + +#include "Surface/ComplexFunction.h" + +void Test_ComplexFunction::t_z2() { + performSurfaceTest("z2"); +} +void Test_ComplexFunction::t_z3() { + performSurfaceTest("z3"); +} +void Test_ComplexFunction::t_zA() { + performSurfaceTest("zA"); +} +void Test_ComplexFunction::t_ez() { + performSurfaceTest("e^a*z"); +} +void Test_ComplexFunction::t_emz2() { + performSurfaceTest("emz2"); +} +void Test_ComplexFunction::t_zm1() { + performSurfaceTest("zm1"); +} +void Test_ComplexFunction::t_zm2() { + performSurfaceTest("zm2"); +} +void Test_ComplexFunction::t_sqrtz() { + performSurfaceTest("sqrtz"); +} +void Test_ComplexFunction::t_lnz() { + performSurfaceTest("lnz"); +} +void Test_ComplexFunction::t_sinz() { + performSurfaceTest("sinz"); +} +void Test_ComplexFunction::t_cosz() { + performSurfaceTest("cosz"); +} +void Test_ComplexFunction::t_sinhz() { + performSurfaceTest("sinhz"); +} +void Test_ComplexFunction::t_coshz() { + performSurfaceTest("coshz"); +} +void Test_ComplexFunction::t_tanz() { + performSurfaceTest("tanz"); +} + diff --git a/tests/Test_ComplexFunction.h b/tests/Test_ComplexFunction.h new file mode 100644 index 00000000..8fa5ee74 --- /dev/null +++ b/tests/Test_ComplexFunction.h @@ -0,0 +1,36 @@ +/* + * File: Test_ComplexFunction.h + * Author: lene + * + * Created on March 28, 2014, 7:54 PM + */ + +#ifndef TEST_COMPLEXFUNCTION_H +#define TEST_COMPLEXFUNCTION_H + +#include "Test_Surface.h" + +class Test_ComplexFunction: public Test_Surface { + + Q_OBJECT + +private slots: + void t_z2(); + void t_z3(); + void t_zA(); + void t_ez(); + void t_emz2(); + void t_zm1(); + void t_zm2(); + void t_sqrtz(); + void t_lnz(); + void t_sinz(); + void t_cosz(); + void t_sinhz(); + void t_coshz(); + void t_tanz(); + +}; + +#endif /* TEST_COMPLEXFUNCTION_H */ + diff --git a/tests/Test_Surface.cpp b/tests/Test_Surface.cpp index fba8af2a..1b66de21 100644 --- a/tests/Test_Surface.cpp +++ b/tests/Test_Surface.cpp @@ -21,10 +21,8 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "Test_Surface.h" #include "MockView.h" -#include "GlobalFunctions.h" #include "Surface/SurfaceImplementations.h" -#include "Surface/ComplexFunction.h" #include "ColorManager.h" #include "FunctionFactory.h" @@ -237,57 +235,6 @@ void Test_Surface::horizon() { void Test_Surface::torus3() { performSurfaceTest("Torus3"); } -void Test_Surface::t_z2() { - performSurfaceTest("z2"); -} -void Test_Surface::t_z3() { - performSurfaceTest("z3"); -} -void Test_Surface::t_zA() { - performSurfaceTest("zA"); -} -void Test_Surface::t_ez() { - performSurfaceTest("e^a*z"); -} -void Test_Surface::t_emz2() { - performSurfaceTest("emz2"); -} -void Test_Surface::t_zm1() { - performSurfaceTest("zm1"); -} -void Test_Surface::t_zm2() { - performSurfaceTest("zm2"); -} -void Test_Surface::t_sqrtz() { - performSurfaceTest("sqrtz"); -} -void Test_Surface::t_lnz() { - performSurfaceTest("lnz"); -} -void Test_Surface::t_sinz() { - performSurfaceTest("sinz"); -} -void Test_Surface::t_cosz() { - performSurfaceTest("cosz"); -} -void Test_Surface::t_sinhz() { - performSurfaceTest("sinhz"); -} -void Test_Surface::t_coshz() { - performSurfaceTest("coshz"); -} -void Test_Surface::t_tanz() { - performSurfaceTest("tanz"); -} - - -template -void Test_Surface::performSurfaceTest(const std::string &fname) { - SurfaceType f(-1., 1., 0.5, -1., 1., 0.5); - testEqual(f.getNumParameters(), num_parameters); - testFunction(f); - testDynamicallyCreatedFunction(fname); -} void Test_Surface::testFunction(Surface &f) { qsrand(1); diff --git a/tests/Test_Surface.h b/tests/Test_Surface.h index e117d2d0..81c473ba 100644 --- a/tests/Test_Surface.h +++ b/tests/Test_Surface.h @@ -72,26 +72,13 @@ class Test_Surface: public QObject { void surface1(); void horizon(); void torus3(); - void t_z2(); - void t_z3(); - void t_zA(); - void t_ez(); - void t_emz2(); - void t_zm1(); - void t_zm2(); - void t_sqrtz(); - void t_lnz(); - void t_sinz(); - void t_cosz(); - void t_sinhz(); - void t_coshz(); - void t_tanz(); - - private: +protected: template void performSurfaceTest(const std::string &fname); +private: + void testFunction(Surface &f); void testDynamicallyCreatedFunction(const std::string &fname); @@ -99,5 +86,14 @@ class Test_Surface: public QObject { MockView *view_; }; +#include "GlobalFunctions.h" + +template +void Test_Surface::performSurfaceTest(const std::string &fname) { + SurfaceType f(-1., 1., 0.5, -1., 1., 0.5); + UnitTests::testEqual(f.getNumParameters(), num_parameters); + testFunction(f); + testDynamicallyCreatedFunction(fname); +} #endif diff --git a/tests/main.cpp b/tests/main.cpp index bded801b..b866b3f5 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -19,7 +19,7 @@ with this program; if not, write to the Free Software Foundation, Inc., */ /// Otherwise, only run the latest test suites, as manually defined below -#define RUN_ALL_TESTS 1 +#define RUN_ALL_TESTS 0 #include "Test_Rotope.h" #include "Test_Displayable.h" @@ -46,6 +46,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "Test_PartitionedMultithreadedMap.h" #include "Test_FacePolygon.h" #include "Test_ChangeDir.h" +#include "Test_ComplexFunction.h" #include "Auxiliary/TestRunner.h" @@ -79,6 +80,7 @@ void fillTestsMap() { tests_by_name.insert(std::pair("Util", new Test_Util)); tests_by_name.insert(std::pair("FacePolygon", new Test_FacePolygon)); tests_by_name.insert(std::pair("ChangeDir", new Test_ChangeDir)); + tests_by_name.insert(std::pair("ComplexFunction", new Test_ComplexFunction)); } int main(int argc, char **argv) { @@ -102,7 +104,7 @@ int main(int argc, char **argv) { # else // runner.run(new Test_ArrayList); // runner.run(new Test_FacePolygon); - runner.run(new Test_ChangeDir); + runner.run(new Test_ComplexFunction); # endif } else { for (auto test: tests_to_run) { diff --git a/tests/tests.pro b/tests/tests.pro index 0b78e987..1d37b368 100644 --- a/tests/tests.pro +++ b/tests/tests.pro @@ -62,6 +62,7 @@ HEADERS += \ Test_Util.h \ Test_ChangeDir.h \ Test_Composite.h \ + Test_ComplexFunction.h \ Test_Rotope.h \ Test_Object.h \ Test_ArrayList.h \ @@ -89,6 +90,7 @@ SOURCES += \ Test_Util.cpp \ Test_ChangeDir.cpp \ Test_Composite.cpp \ + Test_ComplexFunction.cpp \ Test_Rotope.cpp \ Test_Object.cpp \ Test_ArrayList.cpp \