Sketcher: Add gtest unit test framework

This commit is contained in:
Chris Hennes
2023-04-19 22:21:41 -05:00
committed by abdullahtahiriyo
parent 069b5859e0
commit 22d8c8f0dd
7 changed files with 78 additions and 2 deletions

View File

@@ -0,0 +1 @@
add_subdirectory(planegcs)

View File

@@ -0,0 +1,5 @@
target_sources(
Sketcher_tests_run
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/GCS.cpp
)

View File

@@ -0,0 +1,50 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
#include "gtest/gtest.h"
#include "Mod/Sketcher/App/planegcs/GCS.h"
class SystemTest : public GCS::System{
public:
size_t getNumberOfConstraints(int tagID = -1) {
return _getNumberOfConstraints(tagID);
}
};
class GCSTest: public ::testing::Test
{
protected:
void SetUp() override
{
_system = std::make_unique<SystemTest>();
}
void TearDown() override
{
_system.reset();
}
SystemTest* System()
{
return _system.get();
}
private:
std::unique_ptr<SystemTest> _system;
};
TEST_F(GCSTest, clearConstraints) // NOLINT
{
// Arrange
const size_t numConstraints {100};
for (size_t i = 0; i < numConstraints; ++i) {
System()->addConstraint(new GCS::Constraint());
}
ASSERT_EQ(numConstraints, System()->getNumberOfConstraints());
// Act
System()->clear();
// Assert
EXPECT_EQ(0, System()->getNumberOfConstraints());
}

View File

@@ -0,0 +1 @@
add_subdirectory(App)