Comparar commits

...

2 Commits

Autor SHA1 Mensagem Data
Ghostkeeper a74a954883 Fix CppUnit assert call
Storing it in a variable first seems to work. Don't know why.

Contributes to issue CURA-891.
2016-07-20 10:33:38 +02:00
Ghostkeeper 15d5085c8a Add basic test case for Polygon::inside
The test case fails at the moment.

Contributes to issue CURA-891.
2016-07-19 17:39:11 +02:00
3 arquivos alterados com 88 adições e 0 exclusões
+1
Ver Arquivo
@@ -115,6 +115,7 @@ set(engine_TEST_UTILS
BucketGrid2DTest
LinearAlg2DTest
PolygonUtilsTest
PolygonTest
)
# Generating ProtoBuf protocol
+43
Ver Arquivo
@@ -0,0 +1,43 @@
//Copyright (c) 2016 Ultimaker B.V.
//CuraEngine is released under the terms of the AGPLv3 or higher.
#define LARGE_TEST_SIZE 10000
#include "PolygonTest.h"
namespace cura
{
CPPUNIT_TEST_SUITE_REGISTRATION(PolygonTest);
void PolygonTest::setUp()
{
ClipperLib::Path small_path;
small_polygon = PolygonRef(small_path);
small_polygon.emplace_back(0, 0);
small_polygon.emplace_back(0, 100);
small_polygon.emplace_back(100, 100);
small_polygon.emplace_back(100, 0);
ClipperLib::Path large_path;
large_polygon = PolygonRef(large_path);
for (size_t vertex_id = 0; vertex_id < LARGE_TEST_SIZE; ++vertex_id)
{
large_polygon.emplace_back(vertex_id % 2 * 1000, vertex_id * 10); //Creates a sawtooth shape.
}
large_polygon.emplace_back(-10, LARGE_TEST_SIZE * 10 + 10);
large_polygon.emplace_back(-10, 0);
}
void PolygonTest::tearDown()
{
//Nothing to do. The polygons don't need changing.
}
void PolygonTest::insideTest()
{
bool test = small_polygon.inside(Point(50, 50));
CPPUNIT_ASSERT(test);
}
}
+44
Ver Arquivo
@@ -0,0 +1,44 @@
//Copyright (c) 2016 Ultimaker B.V.
//CuraEngine is released under the terms of the AGPLv3 or higher.
#ifndef POLYGONTEST_H
#define POLYGONTEST_H
#include <clipper/clipper.hpp> //To create the paths.
#include <cppunit/TestFixture.h> //Making unit tests.
#include <cppunit/extensions/HelperMacros.h>
#include "../src/utils/polygon.h" //The polygon we're testing.
namespace cura
{
class PolygonTest : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(PolygonTest);
CPPUNIT_TEST(insideTest);
CPPUNIT_TEST_SUITE_END();
public:
/*!
* \brief Sets up the test suite to prepare for testing.
*/
void setUp();
/*!
* \brief Tears down the test suite when testing is done.
*/
void tearDown();
//The actual test cases.
void insideTest();
private:
Polygon small_polygon;
Polygon large_polygon;
};
}
#endif /* POLYGONTEST_H */