Comparar commits
2 Commits
| Autor | SHA1 | Data | |
|---|---|---|---|
| a74a954883 | |||
| 15d5085c8a |
@@ -115,6 +115,7 @@ set(engine_TEST_UTILS
|
||||
BucketGrid2DTest
|
||||
LinearAlg2DTest
|
||||
PolygonUtilsTest
|
||||
PolygonTest
|
||||
)
|
||||
|
||||
# Generating ProtoBuf protocol
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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 */
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário