File size: 20,145 Bytes
985c397 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 | // SPDX-License-Identifier: LGPL-2.1-or-later
#include <FCConfig.h>
#include <Base/Reader.h>
#include <Base/Writer.h>
#include <Mod/Sketcher/App/Constraint.h>
#include <gtest/gtest.h>
#include <xercesc/util/PlatformUtils.hpp>
#include <QTemporaryFile>
#include <src/App/InitApplication.h>
// Ensure Xerces is initialized before running tests which uses xml
class XercesEnvironment: public ::testing::Environment
{
public:
void SetUp() override
{
try {
xercesc::XMLPlatformUtils::Initialize();
}
catch (const xercesc::XMLException& e) {
FAIL() << "Xerces init failed: " << xercesc::XMLString::transcode(e.getMessage());
}
}
void TearDown() override
{
xercesc::XMLPlatformUtils::Terminate();
}
};
::testing::Environment* const xercesEnv = ::testing::AddGlobalTestEnvironment(new XercesEnvironment);
class ConstraintPointsAccess: public ::testing::Test
{
protected:
static void SetUpTestSuite()
{
tests::initApplication();
}
};
TEST_F(ConstraintPointsAccess, testDefaultGeoElementIdsAreSane) // NOLINT
{
// Arrange
auto constraint = Sketcher::Constraint();
// Act - no action needed, we are testing the default state
// Assert
#if SKETCHER_CONSTRAINT_USE_LEGACY_ELEMENTS
// Old way of accessing elements
EXPECT_EQ(constraint.First, Sketcher::GeoEnum::GeoUndef);
EXPECT_EQ(constraint.FirstPos, Sketcher::PointPos::none);
EXPECT_EQ(constraint.Second, Sketcher::GeoEnum::GeoUndef);
EXPECT_EQ(constraint.SecondPos, Sketcher::PointPos::none);
EXPECT_EQ(constraint.Third, Sketcher::GeoEnum::GeoUndef);
EXPECT_EQ(constraint.ThirdPos, Sketcher::PointPos::none);
// New way of accessing elements
#endif
EXPECT_EQ(
constraint.getElement(0),
Sketcher::GeoElementId(Sketcher::GeoEnum::GeoUndef, Sketcher::PointPos::none)
);
EXPECT_EQ(
constraint.getElement(1),
Sketcher::GeoElementId(Sketcher::GeoEnum::GeoUndef, Sketcher::PointPos::none)
);
EXPECT_EQ(
constraint.getElement(2),
Sketcher::GeoElementId(Sketcher::GeoEnum::GeoUndef, Sketcher::PointPos::none)
);
}
#if SKETCHER_CONSTRAINT_USE_LEGACY_ELEMENTS
TEST_F(ConstraintPointsAccess, testOldWriteIsReadByNew) // NOLINT
{
// Arrange
auto constraint = Sketcher::Constraint();
// Act
constraint.First = 23;
constraint.FirstPos = Sketcher::PointPos::start;
constraint.Second = 34;
constraint.SecondPos = Sketcher::PointPos::end;
constraint.Third = 45;
constraint.ThirdPos = Sketcher::PointPos::mid;
// Assert
EXPECT_EQ(
constraint.getElement(0),
Sketcher::GeoElementId(Sketcher::GeoElementId(23, Sketcher::PointPos::start))
);
EXPECT_EQ(
constraint.getElement(1),
Sketcher::GeoElementId(Sketcher::GeoElementId(34, Sketcher::PointPos::end))
);
EXPECT_EQ(
constraint.getElement(2),
Sketcher::GeoElementId(Sketcher::GeoElementId(45, Sketcher::PointPos::mid))
);
}
TEST_F(ConstraintPointsAccess, testNewWriteIsReadByOld) // NOLINT
{
// Arrange
auto constraint = Sketcher::Constraint();
// Act
constraint.setElement(0, Sketcher::GeoElementId(23, Sketcher::PointPos::start));
constraint.setElement(1, Sketcher::GeoElementId(34, Sketcher::PointPos::end));
constraint.setElement(2, Sketcher::GeoElementId(45, Sketcher::PointPos::mid));
// Assert
EXPECT_EQ(constraint.First, 23);
EXPECT_EQ(constraint.FirstPos, Sketcher::PointPos::start);
EXPECT_EQ(constraint.Second, 34);
EXPECT_EQ(constraint.SecondPos, Sketcher::PointPos::end);
EXPECT_EQ(constraint.Third, 45);
EXPECT_EQ(constraint.ThirdPos, Sketcher::PointPos::mid);
}
#endif
TEST_F(ConstraintPointsAccess, testThreeElementsByDefault) // NOLINT
{
// Arrange
auto constraint = Sketcher::Constraint();
// Act - no action needed, we are testing the default state
// Assert
EXPECT_EQ(constraint.getElementsSize(), 3);
}
TEST_F(ConstraintPointsAccess, testFourElementsWhenAddingOne) // NOLINT
{
// Arrange
auto constraint = Sketcher::Constraint();
// Act
constraint.addElement(Sketcher::GeoElementId(1, Sketcher::PointPos::start));
// Assert
EXPECT_EQ(constraint.getElementsSize(), 4);
}
#if SKETCHER_CONSTRAINT_USE_LEGACY_ELEMENTS
TEST_F(ConstraintPointsAccess, testElementSerializationWhenAccessingOldWay) // NOLINT
{
// Arrange
auto constraint = Sketcher::Constraint();
// Act
constraint.First = 23;
constraint.FirstPos = Sketcher::PointPos::start;
constraint.Second = 34;
constraint.SecondPos = Sketcher::PointPos::end;
constraint.Third = 45;
constraint.ThirdPos = Sketcher::PointPos::mid;
Base::StringWriter writer = {};
constraint.Save(writer);
// Assert
std::string serialized = writer.getString();
EXPECT_TRUE(serialized.find("First=\"23\"") != std::string::npos);
EXPECT_TRUE(serialized.find("FirstPos=\"1\"") != std::string::npos);
EXPECT_TRUE(serialized.find("Second=\"34\"") != std::string::npos);
EXPECT_TRUE(serialized.find("SecondPos=\"2\"") != std::string::npos);
EXPECT_TRUE(serialized.find("Third=\"45\"") != std::string::npos);
EXPECT_TRUE(serialized.find("ThirdPos=\"3\"") != std::string::npos);
EXPECT_TRUE(serialized.find("ElementIds=\"23 34 45\"") != std::string::npos);
EXPECT_TRUE(serialized.find("ElementPositions=\"1 2 3\"") != std::string::npos);
}
#endif
TEST_F(ConstraintPointsAccess, testElementSerializationWhenAccessingNewWay) // NOLINT
{
// Arrange
auto constraint = Sketcher::Constraint();
// Act
constraint.setElement(0, Sketcher::GeoElementId(23, Sketcher::PointPos::start));
constraint.setElement(1, Sketcher::GeoElementId(34, Sketcher::PointPos::end));
constraint.setElement(2, Sketcher::GeoElementId(45, Sketcher::PointPos::mid));
Base::StringWriter writer = {};
constraint.Save(writer);
// Assert
std::string serialized = writer.getString();
EXPECT_TRUE(serialized.find("First=\"23\"") != std::string::npos);
EXPECT_TRUE(serialized.find("FirstPos=\"1\"") != std::string::npos);
EXPECT_TRUE(serialized.find("Second=\"34\"") != std::string::npos);
EXPECT_TRUE(serialized.find("SecondPos=\"2\"") != std::string::npos);
EXPECT_TRUE(serialized.find("Third=\"45\"") != std::string::npos);
EXPECT_TRUE(serialized.find("ThirdPos=\"3\"") != std::string::npos);
EXPECT_TRUE(serialized.find("ElementIds=\"23 34 45\"") != std::string::npos);
EXPECT_TRUE(serialized.find("ElementPositions=\"1 2 3\"") != std::string::npos);
}
#if SKETCHER_CONSTRAINT_USE_LEGACY_ELEMENTS
TEST_F(ConstraintPointsAccess, testElementSerializationWhenMixingOldAndNew) // NOLINT
{
// Arrange
auto constraint = Sketcher::Constraint();
// Act
constraint.setElement(0, Sketcher::GeoElementId(23, Sketcher::PointPos::start));
constraint.setElement(1, Sketcher::GeoElementId(34, Sketcher::PointPos::end));
constraint.Second = 45; // Old way
constraint.SecondPos = Sketcher::PointPos::mid;
Base::StringWriter writer = {};
constraint.Save(writer);
// Assert
std::string serialized = writer.getString();
EXPECT_TRUE(serialized.find("First=\"23\"") != std::string::npos);
EXPECT_TRUE(serialized.find("FirstPos=\"1\"") != std::string::npos);
// Old way wrote this data
// ensure mid is 3 for next test
EXPECT_EQ(Sketcher::PointPos::mid, static_cast<Sketcher::PointPos>(3));
EXPECT_TRUE(serialized.find("SecondPos=\"3\"") != std::string::npos);
EXPECT_TRUE(serialized.find("Second=\"45\"") != std::string::npos);
EXPECT_TRUE(serialized.find("Third=\"-2000\"") != std::string::npos);
EXPECT_TRUE(serialized.find("ThirdPos=\"0\"") != std::string::npos);
// Second and SecondPos is reflected in the elements data too
EXPECT_TRUE(serialized.find("ElementIds=\"23 45 -2000\"") != std::string::npos);
EXPECT_TRUE(serialized.find("ElementPositions=\"1 3 0\"") != std::string::npos);
}
#endif
TEST_F(ConstraintPointsAccess, testElementsRestoredFromSerialization) // NOLINT
{
// Arrange
Sketcher::Constraint constraint;
constraint.setElement(0, Sketcher::GeoElementId(23, Sketcher::PointPos::start));
constraint.setElement(1, Sketcher::GeoElementId(34, Sketcher::PointPos::end));
constraint.setElement(2, Sketcher::GeoElementId(45, Sketcher::PointPos::mid));
Base::StringWriter writer;
writer.Stream() << "<root>\n"; // Wrap in a root element to make constraint.Save happy
constraint.Save(writer);
writer.Stream() << "</root>";
// Write to temporary file
QTemporaryFile tempFile;
tempFile.setAutoRemove(true);
ASSERT_TRUE(tempFile.open());
tempFile.write(writer.getString().c_str(), writer.getString().size());
tempFile.flush();
// Open with std::ifstream and parse
std::string filename = tempFile.fileName().toStdString();
std::ifstream inputFile(filename);
ASSERT_TRUE(inputFile.is_open());
Base::XMLReader reader(tempFile.fileName().toStdString().c_str(), inputFile);
Sketcher::Constraint restoredConstraint;
restoredConstraint.Restore(reader);
// Assert
EXPECT_EQ(restoredConstraint.getElement(0), Sketcher::GeoElementId(23, Sketcher::PointPos::start));
EXPECT_EQ(restoredConstraint.getElement(1), Sketcher::GeoElementId(34, Sketcher::PointPos::end));
EXPECT_EQ(restoredConstraint.getElement(2), Sketcher::GeoElementId(45, Sketcher::PointPos::mid));
inputFile.close();
}
TEST_F(
ConstraintPointsAccess,
testElementsRestoredFromSerializationWithoutNewElementStorage
) // NOLINT
{
// Arrange
// Manually craft a serialized version, only parts in "{}" are important.
// New way of storing elements is not present, like if it is an older file.
std::string serializedConstraint = fmt::format(
"<Constrain "
R"(Name="" )"
R"(Type="0" )"
R"(Value="0" )"
R"(LabelDistance="10" )"
R"(LabelPosition="0" )"
R"(IsDriving="1" )"
R"(IsInVirtualSpace="0" )"
R"(IsActive="1" )"
R"(First="{}" )"
R"(Second="{}" )"
R"(Third="{}" )"
R"(FirstPos="{}" )"
R"(SecondPos="{}" )"
R"(ThirdPos="{}" )"
"/>",
67,
78,
89,
static_cast<int>(Sketcher::PointPos::mid),
static_cast<int>(Sketcher::PointPos::start),
static_cast<int>(Sketcher::PointPos::end)
);
Base::StringWriter writer;
auto& stream {writer.Stream()};
stream << "<root>\n"; // Wrap in a root element to make constraint.
stream << serializedConstraint;
stream << "</root>";
// Write to temporary file
QTemporaryFile tempFile;
tempFile.setAutoRemove(true);
ASSERT_TRUE(tempFile.open());
tempFile.write(writer.getString().c_str(), writer.getString().size());
tempFile.flush();
// Open with std::ifstream and parse
std::string filename = tempFile.fileName().toStdString();
std::ifstream inputFile(filename);
ASSERT_TRUE(inputFile.is_open());
Base::XMLReader reader(tempFile.fileName().toStdString().c_str(), inputFile);
Sketcher::Constraint restoredConstraint;
restoredConstraint.Restore(reader);
// Assert
EXPECT_EQ(restoredConstraint.getElement(0), Sketcher::GeoElementId(67, Sketcher::PointPos::mid));
EXPECT_EQ(restoredConstraint.getElement(1), Sketcher::GeoElementId(78, Sketcher::PointPos::start));
EXPECT_EQ(restoredConstraint.getElement(2), Sketcher::GeoElementId(89, Sketcher::PointPos::end));
inputFile.close();
}
TEST_F(
ConstraintPointsAccess,
testLegacyIsPreferedDuringSerializationWithoutLegacyElementStorage
) // NOLINT
{
// Arrange
// Manually craft a serialized version, only parts in "{}" are important.
// Only new way of storing elements is present.
std::string serializedConstraint = fmt::format(
"<Constrain "
R"(Name="" )"
R"(Type="0" )"
R"(Value="0" )"
R"(LabelDistance="10" )"
R"(LabelPosition="0" )"
R"(IsDriving="1" )"
R"(IsInVirtualSpace="0" )"
R"(IsActive="1" )"
// New way
R"(ElementIds="{} {} {}" )"
R"(ElementPositions="{} {} {}" )"
"/>",
// New way data
23,
34,
45,
static_cast<int>(Sketcher::PointPos::start),
static_cast<int>(Sketcher::PointPos::end),
static_cast<int>(Sketcher::PointPos::mid)
);
Base::StringWriter writer;
auto& stream {writer.Stream()};
stream << "<root>\n"; // Wrap in a root element to make constraint.
stream << serializedConstraint;
stream << "</root>";
// Write to temporary file
QTemporaryFile tempFile;
tempFile.setAutoRemove(true);
ASSERT_TRUE(tempFile.open());
tempFile.write(writer.getString().c_str(), writer.getString().size());
tempFile.flush();
// Open with std::ifstream and parse
std::string filename = tempFile.fileName().toStdString();
std::ifstream inputFile(filename);
ASSERT_TRUE(inputFile.is_open());
Base::XMLReader reader(tempFile.fileName().toStdString().c_str(), inputFile);
Sketcher::Constraint restoredConstraint;
restoredConstraint.Restore(reader);
// Assert
EXPECT_EQ(restoredConstraint.getElement(0), Sketcher::GeoElementId(23, Sketcher::PointPos::start));
EXPECT_EQ(restoredConstraint.getElement(1), Sketcher::GeoElementId(34, Sketcher::PointPos::end));
EXPECT_EQ(restoredConstraint.getElement(2), Sketcher::GeoElementId(45, Sketcher::PointPos::mid));
inputFile.close();
}
TEST_F(ConstraintPointsAccess, testLegacyIsPreferedDuringSerializationIfContradicting) // NOLINT
{
// Arrange
// Manually craft a serialized version, only parts in "{}" are important.
// It is not important if legacy is included before or after, legacy should always be preferred.
std::string serializedConstraint = fmt::format(
"<Constrain "
R"(Name="" )"
R"(Type="0" )"
R"(Value="0" )"
R"(LabelDistance="10" )"
R"(LabelPosition="0" )"
R"(IsDriving="1" )"
R"(IsInVirtualSpace="0" )"
R"(IsActive="1" )"
// New way
R"(ElementIds="{} {} {}" )"
R"(ElementPositions="{} {} {}" )"
// Legacy
R"(First="{}" )"
R"(Second="{}" )"
R"(Third="{}" )"
R"(FirstPos="{}" )"
R"(SecondPos="{}" )"
R"(ThirdPos="{}" )"
"/>",
// New way data
23,
34,
45,
static_cast<int>(Sketcher::PointPos::start),
static_cast<int>(Sketcher::PointPos::end),
static_cast<int>(Sketcher::PointPos::mid),
// Contradicting legacy data, this should be preferred if available
67,
78,
89,
static_cast<int>(Sketcher::PointPos::mid),
static_cast<int>(Sketcher::PointPos::start),
static_cast<int>(Sketcher::PointPos::end)
);
Base::StringWriter writer;
auto& stream {writer.Stream()};
stream << "<root>\n"; // Wrap in a root element to make constraint.
stream << serializedConstraint;
stream << "</root>";
// Write to temporary file
QTemporaryFile tempFile;
tempFile.setAutoRemove(true);
ASSERT_TRUE(tempFile.open());
tempFile.write(writer.getString().c_str(), writer.getString().size());
tempFile.flush();
// Open with std::ifstream and parse
std::string filename = tempFile.fileName().toStdString();
std::ifstream inputFile(filename);
ASSERT_TRUE(inputFile.is_open());
Base::XMLReader reader(tempFile.fileName().toStdString().c_str(), inputFile);
Sketcher::Constraint restoredConstraint;
restoredConstraint.Restore(reader);
// Assert
EXPECT_EQ(restoredConstraint.getElement(0), Sketcher::GeoElementId(67, Sketcher::PointPos::mid));
EXPECT_EQ(restoredConstraint.getElement(1), Sketcher::GeoElementId(78, Sketcher::PointPos::start));
EXPECT_EQ(restoredConstraint.getElement(2), Sketcher::GeoElementId(89, Sketcher::PointPos::end));
inputFile.close();
}
TEST_F(ConstraintPointsAccess, testSubstituteIndex) // NOLINT
{
// Arrange
Sketcher::Constraint constraint;
constraint.setElement(0, Sketcher::GeoElementId(10, Sketcher::PointPos::start));
constraint.setElement(1, Sketcher::GeoElementId(20, Sketcher::PointPos::end));
constraint.setElement(2, Sketcher::GeoElementId(10, Sketcher::PointPos::mid)); // same GeoId as 0
// Act
constraint.substituteIndex(10, 99);
// Assert
EXPECT_EQ(constraint.getElement(0), Sketcher::GeoElementId(99, Sketcher::PointPos::start));
EXPECT_EQ(constraint.getElement(1), Sketcher::GeoElementId(20, Sketcher::PointPos::end));
EXPECT_EQ(constraint.getElement(2), Sketcher::GeoElementId(99, Sketcher::PointPos::mid));
}
TEST_F(ConstraintPointsAccess, testSubstituteIndexAndPos) // NOLINT
{
// Arrange
Sketcher::Constraint constraint;
constraint.setElement(0, Sketcher::GeoElementId(10, Sketcher::PointPos::start));
constraint.setElement(1, Sketcher::GeoElementId(20, Sketcher::PointPos::start));
constraint.setElement(2, Sketcher::GeoElementId(10, Sketcher::PointPos::mid));
// Act
constraint.substituteIndexAndPos(10, Sketcher::PointPos::start, 42, Sketcher::PointPos::end);
// Assert
EXPECT_EQ(constraint.getElement(0), Sketcher::GeoElementId(42, Sketcher::PointPos::end));
EXPECT_EQ(constraint.getElement(1), Sketcher::GeoElementId(20, Sketcher::PointPos::start));
EXPECT_EQ(constraint.getElement(2), Sketcher::GeoElementId(10, Sketcher::PointPos::mid)); // unchanged
}
TEST_F(ConstraintPointsAccess, testInvolvesGeoId) // NOLINT
{
// Arrange
Sketcher::Constraint constraint;
constraint.setElement(0, Sketcher::GeoElementId(10, Sketcher::PointPos::start));
constraint.setElement(1, Sketcher::GeoElementId(20, Sketcher::PointPos::end));
// Act & Assert
EXPECT_TRUE(constraint.involvesGeoId(10));
EXPECT_TRUE(constraint.involvesGeoId(20));
EXPECT_FALSE(constraint.involvesGeoId(99));
}
TEST_F(ConstraintPointsAccess, testInvolvesGeoIdAndPosId) // NOLINT
{
// Arrange
Sketcher::Constraint constraint;
constraint.setElement(0, Sketcher::GeoElementId(10, Sketcher::PointPos::start));
constraint.setElement(1, Sketcher::GeoElementId(20, Sketcher::PointPos::mid));
constraint.setElement(2, Sketcher::GeoElementId(30, Sketcher::PointPos::end));
// Act & Assert
EXPECT_TRUE(constraint.involvesGeoIdAndPosId(10, Sketcher::PointPos::start));
EXPECT_TRUE(constraint.involvesGeoIdAndPosId(20, Sketcher::PointPos::mid));
EXPECT_FALSE(constraint.involvesGeoIdAndPosId(20, Sketcher::PointPos::start));
EXPECT_FALSE(constraint.involvesGeoIdAndPosId(99, Sketcher::PointPos::end));
}
#if SKETCHER_CONSTRAINT_USE_LEGACY_ELEMENTS
TEST_F(ConstraintPointsAccess, testLegacyWriteReflectedInInvolvesAndSubstitute) // NOLINT
{
// Arrange
Sketcher::Constraint constraint;
constraint.First = 10;
constraint.FirstPos = Sketcher::PointPos::start;
constraint.Second = 20;
constraint.SecondPos = Sketcher::PointPos::end;
// Act & Assert
EXPECT_TRUE(constraint.involvesGeoId(10));
EXPECT_TRUE(constraint.involvesGeoIdAndPosId(20, Sketcher::PointPos::end));
// Substitute the legacy-indexed element
constraint.substituteIndex(10, 99);
// Should now reflect the substituted value
EXPECT_TRUE(constraint.involvesGeoId(99));
EXPECT_FALSE(constraint.involvesGeoId(10));
}
TEST_F(ConstraintPointsAccess, testSubstituteUpdatesLegacyFieldsToo) // NOLINT
{
// Arrange
Sketcher::Constraint constraint;
constraint.setElement(0, Sketcher::GeoElementId(10, Sketcher::PointPos::start));
// Act
constraint.substituteIndex(10, 42);
// Assert
EXPECT_EQ(constraint.getElement(0), Sketcher::GeoElementId(42, Sketcher::PointPos::start));
EXPECT_EQ(constraint.First, 42);
EXPECT_EQ(constraint.FirstPos, Sketcher::PointPos::start);
}
#endif
|