Permalink
Browse files

Unit tests reorganisation

  • Loading branch information...
feragon committed Aug 4, 2016
1 parent ad23acd commit 36ddfc917ccc0d78b7e5fbf949675cd8a862fe2c
View
@@ -26,18 +26,22 @@ FIND_PACKAGE ( Threads REQUIRED )
set(src
main.cpp
entitytest.cpp
code.cpp
lckernel/primitive/entitytest.cpp
lckernel/math/code.cpp
lckernel/math/testmath.cpp
lckernel/operations/buildertest.cpp
lckernel/geometry/testgeoarc.cpp
lckernel/geometry/testgeocircle.cpp
lckernel/functions/testintersect.cpp
lckernel/math/testmatrices.cpp
lckernel/geometry/beziertest.cpp
lcviewernoqt/testselection.cpp
)
set(hdrs
entitytest.h
code.h
testmath.h
testmatrices.h
beziertest.h
testselection.h
testintersect.h)
lckernel/primitive/entitytest.h
lckernel/math/code.h
)
if(WITH_QTUI)
find_package(Qt5Widgets)
find_package(Qt5Core)
@@ -53,7 +57,6 @@ if(WITH_QTUI)
Qt5::Test)
set(hdrs
${hdrs}
ui/testcommandline.h
ui/clicommandtest.h
ui/uitests.h
ui/widgets/layers.h
@@ -66,7 +69,8 @@ if(WITH_QTUI)
ui/testluaoperations.cpp
ui/uitests.cpp
ui/testlayers.cpp
ui/testlinepatterns.cpp)
ui/testlinepatterns.cpp
ui/testcommandline.cpp)
include_directories("${CMAKE_SOURCE_DIR}/lcUI")
include_directories("${PROJECT_BINARY_DIR}/../lcUI") #Include ui_* files
View

This file was deleted.

Oops, something went wrong.
View

This file was deleted.

Oops, something went wrong.
@@ -6,13 +6,6 @@
//
// Created by R. van Twisk on 5/6/15.
//
#ifndef LC_TESTINTERSECT_H
#define LC_TESTINTERSECT_H
#endif //LC_TESTINTERSECT_H
TEST(IntersectTest, LineLine1) {
lc::entity::CADEntity_CSPtr i1=std::make_shared<lc::entity::Line>(lc::geo::Coordinate(0,0), lc::geo::Coordinate(10,10), nullptr);
lc::entity::CADEntity_CSPtr i2=std::make_shared<lc::entity::Line>(lc::geo::Coordinate(0,10), lc::geo::Coordinate(10,0), nullptr);
@@ -1,7 +1,9 @@
#include <gtest/gtest.h>
#include "cad/geometry/geobezier.h"
#include "cad/math/intersectionhandler.h"
#include "cad/geometry/geovector.h"
#include <cmath>
TEST(BEZIER, LENGTH) {
auto p1 = lc::geo::Coordinate(50,230);
auto p2 = lc::geo::Coordinate(50,50);
@@ -42,7 +44,7 @@ TEST(BEZIER, NORMAL) {
// lc::maths::Intersection::BezierLine(bezier_, line_);
//}
TEST(BEZIER, CIRCLE) {
/*TEST(BEZIER, CIRCLE) {
auto c1 = lc::geo::Coordinate(0,0);
auto circle_ = lc::geo::Circle(c1, 200.);
@@ -59,4 +61,4 @@ TEST(BEZIER, CIRCLE) {
for(auto r : ret) {
std::cout << r << std::endl;
}
}
}*/
@@ -1,12 +1,10 @@
#include <cmath>
#include <gtest/gtest.h>
#include <cad/geometry/geoarc.h>
//
// Created by R. van Twisk on 5/5/15.
//
#pragma once
using namespace lc;
using namespace geo;
@@ -1,12 +1,11 @@
#include <cmath>
#include <cad/geometry/geocircle.h>
#include <gtest/gtest.h>
//
// Created by R. van Twisk on 5/5/15.
//
#pragma once
using namespace lc;
using namespace geo;
File renamed without changes.
@@ -0,0 +1,63 @@
#pragma once
#include <gtest/gtest.h>
#include <vector>
#include <cad/primitive/circle.h>
#include <cad/primitive/line.h>
#include <cad/meta/layer.h>
#include <cad/primitive/point.h>
class test {
public:
test() {
}
std::vector<double> quad(double x, double c);
std::vector<double> cubic(double x2, double x, double c);
std::vector<double> quartic(double x3, double x2, double x, double c);
std::vector<lc::geo::Coordinate> intr(lc::entity::Line&, lc::entity::Circle&);
std::vector<lc::geo::Coordinate> testin();
template <typename e1, typename e2>
std::vector<lc::geo::Coordinate>intersec(e1, e2);
};
TEST(test, quad) {
test c;
EXPECT_DOUBLE_EQ(-2, c.quad(5, 6)[0]);
EXPECT_DOUBLE_EQ(-3, c.quad(5, 6)[1]);
EXPECT_TRUE(fabs(c.quad(100, 50)[0]) - 0.50252531694167146 < 0.000000001);
EXPECT_DOUBLE_EQ(-99.497474683058329, c.quad(100, 50)[1]);
// EXPECT_DOUBLE_EQ(-2, c.quad(5, 6)[0]);
// EXPECT_DOUBLE_EQ(-3, c.quad(5, 6)[1]);
// EXPECT_DOUBLE_EQ(-2, c.quad(5, 6)[0]);
// EXPECT_DOUBLE_EQ(-3, c.quad(5, 6)[1]);
}
TEST(test, cubic) {
test c;
EXPECT_TRUE(fabs(c.cubic(5, 6, 1)[0]) - 0.19806226419516171 < .00000001);
EXPECT_DOUBLE_EQ(-1.5549581320873713, c.cubic(5, 6, 1)[1]);
EXPECT_DOUBLE_EQ(-3.2469796037174667, c.cubic(5, 6, 1)[2]);
}
TEST(test, quartic) {
test c;
EXPECT_DOUBLE_EQ(-2.0, c.quartic(5, 6, 1, 2)[0]);
EXPECT_DOUBLE_EQ(-3.1038034027355366, c.quartic(5, 6, 1, 2)[1]);
}
TEST(test, testin) {
test a;
const double rootY = 200. / sqrt(100. * 100. + 1.);
const double rootX = 100. * rootY;
EXPECT_DOUBLE_EQ(-rootX, a.testin()[0].x());
EXPECT_DOUBLE_EQ(-rootY, a.testin()[0].y());
EXPECT_DOUBLE_EQ(rootX, a.testin()[1].x());
EXPECT_DOUBLE_EQ(rootY, a.testin()[1].y());
}
@@ -1,13 +1,12 @@
#include <cmath>
#include <cad/math/lcmath.h>
#include <cad/const.h>
#include <gtest/gtest.h>
//
// Created by R. van Twisk on 5/5/15.
//
#pragma once
TEST(MathTest, getAngleDifferenceShort) {
ASSERT_NEAR(0.1, lc::Math::getAngleDifferenceShort(0., 0.1, true), LCARCTOLERANCE);
ASSERT_NEAR(M_PI, lc::Math::getAngleDifferenceShort(0., M_PI, true), LCARCTOLERANCE);
@@ -1,3 +1,4 @@
#include <gtest/gtest.h>
#include "cad/math/equation.h"
#include "cad/math/intersectionhandler.h"
#include "cad/geometry/geovector.h"
@@ -1,3 +1,4 @@
#include <gtest/gtest.h>
#include "entitytest.h"
#include <iostream>
#include <memory>
@@ -736,4 +737,4 @@ std::vector<Ellipse_CSPtr> entitytest::EllipseScale() {
}
return ellipses;
}
}
Oops, something went wrong.

0 comments on commit 36ddfc9

Please sign in to comment.