Formatting: Apply pre-commit to tests/src
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "App/Branding.h"
|
||||
|
||||
TEST(Branding, one){
|
||||
TEST(Branding, one)
|
||||
{
|
||||
QString ss {};
|
||||
}
|
||||
|
||||
@@ -6,12 +6,13 @@
|
||||
|
||||
#include <sstream>
|
||||
|
||||
class ElementMapTest : public ::testing::Test {
|
||||
class ElementMapTest: public ::testing::Test
|
||||
{
|
||||
};
|
||||
|
||||
TEST_F(ElementMapTest, defaultConstruction)
|
||||
{
|
||||
// Act
|
||||
// Act
|
||||
|
||||
// Assert
|
||||
// Assert
|
||||
}
|
||||
|
||||
@@ -8,40 +8,34 @@
|
||||
|
||||
// NOLINTBEGIN(readability-magic-numbers)
|
||||
|
||||
class IndexedNameTest : public ::testing::Test {
|
||||
class IndexedNameTest: public ::testing::Test
|
||||
{
|
||||
protected:
|
||||
// void SetUp() override {}
|
||||
|
||||
// void TearDown() override {}
|
||||
|
||||
// Create and return a list of invalid IndexedNames
|
||||
static std::vector<Data::IndexedName> givenInvalidIndexedNames() {
|
||||
return std::vector<Data::IndexedName> {
|
||||
Data::IndexedName(),
|
||||
Data::IndexedName("",1),
|
||||
Data::IndexedName("INVALID42NAME",1),
|
||||
Data::IndexedName(".EDGE",1)
|
||||
};
|
||||
static std::vector<Data::IndexedName> givenInvalidIndexedNames()
|
||||
{
|
||||
return std::vector<Data::IndexedName> {Data::IndexedName(),
|
||||
Data::IndexedName("", 1),
|
||||
Data::IndexedName("INVALID42NAME", 1),
|
||||
Data::IndexedName(".EDGE", 1)};
|
||||
}
|
||||
|
||||
// Create and return a list of valid IndexedNames
|
||||
static std::vector<Data::IndexedName> givenValidIndexedNames() {
|
||||
return std::vector<Data::IndexedName> {
|
||||
Data::IndexedName("NAME"),
|
||||
Data::IndexedName("NAME1"),
|
||||
Data::IndexedName("NAME",1),
|
||||
Data::IndexedName("NAME_WITH_UNDERSCORES12345")
|
||||
};
|
||||
static std::vector<Data::IndexedName> givenValidIndexedNames()
|
||||
{
|
||||
return std::vector<Data::IndexedName> {Data::IndexedName("NAME"),
|
||||
Data::IndexedName("NAME1"),
|
||||
Data::IndexedName("NAME", 1),
|
||||
Data::IndexedName("NAME_WITH_UNDERSCORES12345")};
|
||||
}
|
||||
|
||||
// An arbitrary list of C strings used for testing some types of construction
|
||||
// NOLINTNEXTLINE cppcoreguidelines-non-private-member-variables-in-classes
|
||||
std::vector<const char *> allowedTypes {
|
||||
"VERTEX",
|
||||
"EDGE",
|
||||
"FACE",
|
||||
"WIRE"
|
||||
};
|
||||
std::vector<const char*> allowedTypes {"VERTEX", "EDGE", "FACE", "WIRE"};
|
||||
};
|
||||
|
||||
TEST_F(IndexedNameTest, defaultConstruction)
|
||||
@@ -94,7 +88,7 @@ TEST_F(IndexedNameTest, nameAndIndexConstructionWithOverride)
|
||||
TEST_F(IndexedNameTest, constructionInvalidCharInName)
|
||||
{
|
||||
// Arrange
|
||||
constexpr int lastASCIICode{127};
|
||||
constexpr int lastASCIICode {127};
|
||||
std::vector<char> illegalCharacters = {};
|
||||
for (int code = 1; code <= lastASCIICode; ++code) {
|
||||
if ((std::isalnum(code) == 0) && code != '_') {
|
||||
@@ -175,7 +169,7 @@ TEST_F(IndexedNameTest, nameAndTypeListConstructionReusedMemoryCheck)
|
||||
TEST_F(IndexedNameTest, byteArrayConstruction)
|
||||
{
|
||||
// Arrange
|
||||
QByteArray qba{"EDGE42"};
|
||||
QByteArray qba {"EDGE42"};
|
||||
|
||||
// Act
|
||||
auto indexedName = Data::IndexedName(qba);
|
||||
@@ -207,7 +201,7 @@ TEST_F(IndexedNameTest, streamInsertionOperator)
|
||||
ss << indexedName;
|
||||
|
||||
// Assert
|
||||
EXPECT_EQ(ss.str(), std::string{"EDGE42"});
|
||||
EXPECT_EQ(ss.str(), std::string {"EDGE42"});
|
||||
}
|
||||
|
||||
TEST_F(IndexedNameTest, compoundAssignmentOperator)
|
||||
@@ -215,9 +209,9 @@ TEST_F(IndexedNameTest, compoundAssignmentOperator)
|
||||
// NOTE: Only += is defined for this class
|
||||
|
||||
// Arrange
|
||||
constexpr int base{42};
|
||||
constexpr int offset{10};
|
||||
auto indexedName = Data::IndexedName("EDGE",base);
|
||||
constexpr int base {42};
|
||||
constexpr int offset {10};
|
||||
auto indexedName = Data::IndexedName("EDGE", base);
|
||||
|
||||
// Act
|
||||
indexedName += offset;
|
||||
@@ -351,7 +345,7 @@ TEST_F(IndexedNameTest, isNullTrue)
|
||||
{
|
||||
// Arrange
|
||||
auto invalidNames = givenInvalidIndexedNames();
|
||||
for (const auto &name : invalidNames) {
|
||||
for (const auto& name : invalidNames) {
|
||||
|
||||
// Act & Assert
|
||||
EXPECT_TRUE(name.isNull());
|
||||
@@ -362,7 +356,7 @@ TEST_F(IndexedNameTest, isNullFalse)
|
||||
{
|
||||
// Arrange
|
||||
auto validNames = givenValidIndexedNames();
|
||||
for (const auto &name : validNames) {
|
||||
for (const auto& name : validNames) {
|
||||
|
||||
// Act & Assert
|
||||
EXPECT_FALSE(name.isNull());
|
||||
@@ -373,14 +367,14 @@ TEST_F(IndexedNameTest, booleanConversionFalse)
|
||||
{
|
||||
// Arrange
|
||||
auto invalidNames = givenInvalidIndexedNames();
|
||||
for (const auto &name : invalidNames) {
|
||||
for (const auto& name : invalidNames) {
|
||||
|
||||
// Act & Assert
|
||||
EXPECT_FALSE(static_cast<bool>(name));
|
||||
}
|
||||
|
||||
// Usage example:
|
||||
auto indexedName = Data::IndexedName(".EDGE",1); // Invalid name
|
||||
auto indexedName = Data::IndexedName(".EDGE", 1);// Invalid name
|
||||
if (indexedName) {
|
||||
FAIL() << "indexedName as a boolean should have been false for an invalid name";
|
||||
}
|
||||
@@ -480,7 +474,7 @@ TEST_F(IndexedNameTest, assignmentOperator)
|
||||
const int testIndex2 {24};
|
||||
auto indexedName1 = Data::IndexedName::fromConst("TestName", testIndex1);
|
||||
auto indexedName2 = Data::IndexedName::fromConst("TestName2", testIndex2);
|
||||
EXPECT_NE(indexedName1, indexedName2); // Ensure the test is set up correctly
|
||||
EXPECT_NE(indexedName1, indexedName2);// Ensure the test is set up correctly
|
||||
|
||||
// Act
|
||||
indexedName1 = indexedName2;
|
||||
@@ -490,7 +484,8 @@ TEST_F(IndexedNameTest, assignmentOperator)
|
||||
}
|
||||
|
||||
|
||||
class ByteArrayTest : public ::testing::Test {
|
||||
class ByteArrayTest: public ::testing::Test
|
||||
{
|
||||
protected:
|
||||
// void SetUp() override {}
|
||||
|
||||
@@ -503,7 +498,7 @@ TEST_F(ByteArrayTest, QByteArrayConstruction)
|
||||
QByteArray testQBA("Data in a QByteArray");
|
||||
|
||||
// Act
|
||||
Data::ByteArray testByteArray (testQBA);
|
||||
Data::ByteArray testByteArray(testQBA);
|
||||
|
||||
// Assert
|
||||
EXPECT_EQ(testQBA, testByteArray.bytes);
|
||||
@@ -513,11 +508,11 @@ TEST_F(ByteArrayTest, CopyConstruction)
|
||||
{
|
||||
// Arrange
|
||||
QByteArray testQBA("Data in a QByteArray");
|
||||
Data::ByteArray originalByteArray (testQBA);
|
||||
Data::ByteArray originalByteArray(testQBA);
|
||||
|
||||
// Act
|
||||
// NOLINTNEXTLINE performance-unnecessary-copy-initialization
|
||||
Data::ByteArray copiedByteArray (originalByteArray);
|
||||
Data::ByteArray copiedByteArray(originalByteArray);
|
||||
|
||||
// Assert
|
||||
EXPECT_EQ(originalByteArray, copiedByteArray);
|
||||
@@ -527,11 +522,11 @@ TEST_F(ByteArrayTest, MoveConstruction)
|
||||
{
|
||||
// Arrange
|
||||
QByteArray testQBA("Data in a QByteArray");
|
||||
Data::ByteArray originalByteArray (testQBA);
|
||||
const auto *originalDataLocation = originalByteArray.bytes.constData();
|
||||
Data::ByteArray originalByteArray(testQBA);
|
||||
const auto* originalDataLocation = originalByteArray.bytes.constData();
|
||||
|
||||
// Act
|
||||
Data::ByteArray copiedByteArray (std::move(originalByteArray));
|
||||
Data::ByteArray copiedByteArray(std::move(originalByteArray));
|
||||
|
||||
// Assert
|
||||
EXPECT_EQ(testQBA, copiedByteArray.bytes);
|
||||
@@ -542,9 +537,9 @@ TEST_F(ByteArrayTest, ensureUnshared)
|
||||
{
|
||||
// Arrange
|
||||
QByteArray testQBA("Data in a QByteArray");
|
||||
Data::ByteArray originalByteArray (testQBA);
|
||||
const auto *originalDataLocation = originalByteArray.bytes.constData();
|
||||
Data::ByteArray copiedByteArray (originalByteArray);
|
||||
Data::ByteArray originalByteArray(testQBA);
|
||||
const auto* originalDataLocation = originalByteArray.bytes.constData();
|
||||
Data::ByteArray copiedByteArray(originalByteArray);
|
||||
|
||||
// Act
|
||||
copiedByteArray.ensureUnshared();
|
||||
@@ -560,9 +555,9 @@ TEST_F(ByteArrayTest, equalityOperator)
|
||||
QByteArray testQBA1("Data in a QByteArray");
|
||||
QByteArray testQBA2("Data in a QByteArray");
|
||||
QByteArray testQBA3("Not the same data in a QByteArray");
|
||||
Data::ByteArray byteArray1 (testQBA1);
|
||||
Data::ByteArray byteArray2 (testQBA2);
|
||||
Data::ByteArray byteArray3 (testQBA3);
|
||||
Data::ByteArray byteArray1(testQBA1);
|
||||
Data::ByteArray byteArray2(testQBA2);
|
||||
Data::ByteArray byteArray3(testQBA3);
|
||||
|
||||
// Act & Assert
|
||||
EXPECT_TRUE(byteArray1 == byteArray2);
|
||||
@@ -574,8 +569,8 @@ TEST_F(ByteArrayTest, assignmentOperator)
|
||||
// Arrange
|
||||
QByteArray testQBA1("Data in a QByteArray");
|
||||
QByteArray testQBA2("Different data in a QByteArray");
|
||||
Data::ByteArray originalByteArray (testQBA1);
|
||||
Data::ByteArray newByteArray (testQBA2);
|
||||
Data::ByteArray originalByteArray(testQBA1);
|
||||
Data::ByteArray newByteArray(testQBA2);
|
||||
ASSERT_FALSE(originalByteArray == newByteArray);
|
||||
|
||||
// Act
|
||||
@@ -590,9 +585,9 @@ TEST_F(ByteArrayTest, moveAssignmentOperator)
|
||||
// Arrange
|
||||
QByteArray testQBA1("Data in a QByteArray");
|
||||
QByteArray testQBA2("Different data in a QByteArray");
|
||||
Data::ByteArray originalByteArray (testQBA1);
|
||||
const auto *originalByteArrayLocation = originalByteArray.bytes.constData();
|
||||
Data::ByteArray newByteArray (testQBA2);
|
||||
Data::ByteArray originalByteArray(testQBA1);
|
||||
const auto* originalByteArrayLocation = originalByteArray.bytes.constData();
|
||||
Data::ByteArray newByteArray(testQBA2);
|
||||
ASSERT_FALSE(originalByteArray == newByteArray);
|
||||
|
||||
// Act
|
||||
|
||||
@@ -16,8 +16,9 @@ TEST(License, UnknownIdentifier)
|
||||
TEST(License, direct)
|
||||
{
|
||||
int posn {App::findLicense("CC_BY_40")};
|
||||
App::TLicenseArr tt {
|
||||
"CC_BY_40", "Creative Commons Attribution 4.0", "https://creativecommons.org/licenses/by/4.0/"};
|
||||
App::TLicenseArr tt {"CC_BY_40",
|
||||
"Creative Commons Attribution 4.0",
|
||||
"https://creativecommons.org/licenses/by/4.0/"};
|
||||
EXPECT_EQ(App::licenseItems.at(posn), tt);
|
||||
}
|
||||
|
||||
@@ -29,5 +30,3 @@ TEST(License, findLicenseByIdent)
|
||||
EXPECT_STREQ(arr.at(App::posnOfFullName), "Creative Commons Attribution 4.0");
|
||||
EXPECT_STREQ(arr.at(App::posnOfUrl), "https://creativecommons.org/licenses/by/4.0/");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include "App/MappedName.h"
|
||||
#include "App/ComplexGeoData.h"
|
||||
#include "App/MappedName.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
@@ -102,7 +102,7 @@ TEST(MappedName, constructFromIndexedNameNoIndex)
|
||||
Data::MappedName mappedName {indexedName};
|
||||
|
||||
// Assert
|
||||
EXPECT_EQ(mappedName.dataBytes().constData(), indexedName.getType()); // shared memory
|
||||
EXPECT_EQ(mappedName.dataBytes().constData(), indexedName.getType());// shared memory
|
||||
EXPECT_EQ(mappedName.isRaw(), true);
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ TEST(MappedName, constructFromIndexedNameWithIndex)
|
||||
Data::MappedName mappedName {indexedName};
|
||||
|
||||
// Assert
|
||||
EXPECT_NE(mappedName.dataBytes().constData(), indexedName.getType()); // NOT shared memory
|
||||
EXPECT_NE(mappedName.dataBytes().constData(), indexedName.getType());// NOT shared memory
|
||||
EXPECT_EQ(mappedName.isRaw(), false);
|
||||
EXPECT_EQ(mappedName.toString(), indexedName.toString());
|
||||
}
|
||||
@@ -241,7 +241,7 @@ TEST(MappedName, fromRawDataCopy)
|
||||
// Arrange
|
||||
Data::MappedName temp = Data::MappedName::fromRawData(QByteArray("TESTTEST", 10));
|
||||
temp.append("TESTPOSTFIX");
|
||||
temp.compact(); //Always call compact before accessing data!
|
||||
temp.compact();// Always call compact before accessing data!
|
||||
|
||||
// Act
|
||||
Data::MappedName mappedName = Data::MappedName::fromRawData(temp, 0);
|
||||
@@ -258,8 +258,8 @@ TEST(MappedName, fromRawDataCopyStartposAndSize)
|
||||
{
|
||||
// Arrange
|
||||
Data::MappedName temp = Data::MappedName::fromRawData(QByteArray("TESTTEST", 8));
|
||||
temp.append("ABCDEFGHIJKLM"); //postfix
|
||||
temp.compact(); //Always call compact before accessing data!
|
||||
temp.append("ABCDEFGHIJKLM");// postfix
|
||||
temp.compact(); // Always call compact before accessing data!
|
||||
|
||||
// Act
|
||||
Data::MappedName mappedName = Data::MappedName::fromRawData(temp, 2, 13);
|
||||
@@ -483,17 +483,17 @@ TEST(MappedName, toConstString)
|
||||
{
|
||||
// Arrange
|
||||
Data::MappedName mappedName(Data::MappedName("TEST"), "POSTFIXTEST");
|
||||
int size{0};
|
||||
int size {0};
|
||||
|
||||
// Act
|
||||
const char *temp = mappedName.toConstString(0, size);
|
||||
const char* temp = mappedName.toConstString(0, size);
|
||||
|
||||
// Assert
|
||||
EXPECT_EQ(QByteArray(temp, size), QByteArray("TEST"));
|
||||
EXPECT_EQ(size, 4);
|
||||
|
||||
// Act
|
||||
const char *temp2 = mappedName.toConstString(7, size);
|
||||
const char* temp2 = mappedName.toConstString(7, size);
|
||||
|
||||
// Assert
|
||||
EXPECT_EQ(QByteArray(temp2, size), QByteArray("TFIXTEST"));
|
||||
@@ -569,13 +569,16 @@ TEST(MappedName, appendToBufferWithPrefix)
|
||||
EXPECT_EQ(buffer, std::string("STUFF") + elemMapPrefix + std::string("TESTPOSTFIXTEST"));
|
||||
|
||||
// Arrange
|
||||
Data::MappedName mappedName2("TEST"); //If mappedName does not have a postfix and is a valid indexedName: prefix is not added
|
||||
Data::MappedName mappedName2("TEST");// If mappedName does not have a postfix and is a valid
|
||||
// indexedName: prefix is not added
|
||||
|
||||
// Act
|
||||
mappedName2.appendToBufferWithPrefix(buffer);
|
||||
|
||||
// Assert
|
||||
EXPECT_EQ(buffer, std::string("STUFF") + elemMapPrefix + std::string("TESTPOSTFIXTEST") + /*missing prefix*/ std::string("TEST"));
|
||||
EXPECT_EQ(buffer,
|
||||
std::string("STUFF") + elemMapPrefix + std::string("TESTPOSTFIXTEST")
|
||||
+ /*missing prefix*/ std::string("TEST"));
|
||||
}
|
||||
|
||||
TEST(MappedName, toPrefixedString)
|
||||
@@ -592,13 +595,16 @@ TEST(MappedName, toPrefixedString)
|
||||
EXPECT_EQ(buffer, std::string("STUFF") + elemMapPrefix + std::string("TESTPOSTFIXTEST"));
|
||||
|
||||
// Arrange
|
||||
Data::MappedName mappedName2("TEST"); //If mappedName does not have a postfix and is a valid indexedName: prefix is not added
|
||||
Data::MappedName mappedName2("TEST");// If mappedName does not have a postfix and is a valid
|
||||
// indexedName: prefix is not added
|
||||
|
||||
// Act
|
||||
buffer += mappedName2.toPrefixedString();
|
||||
|
||||
// Assert
|
||||
EXPECT_EQ(buffer, std::string("STUFF") + elemMapPrefix + std::string("TESTPOSTFIXTEST") + /*missing prefix*/ std::string("TEST"));
|
||||
EXPECT_EQ(buffer,
|
||||
std::string("STUFF") + elemMapPrefix + std::string("TESTPOSTFIXTEST")
|
||||
+ /*missing prefix*/ std::string("TEST"));
|
||||
}
|
||||
|
||||
TEST(MappedName, toBytes)
|
||||
@@ -719,7 +725,7 @@ TEST(MappedName, find)
|
||||
EXPECT_EQ(mappedName.find(""), 0);
|
||||
EXPECT_EQ(mappedName.find(std::string("")), 0);
|
||||
EXPECT_EQ(mappedName.find("TEST"), 0);
|
||||
EXPECT_EQ(mappedName.find("STPO"), -1); //sentence must be fully contained in data or postfix
|
||||
EXPECT_EQ(mappedName.find("STPO"), -1);// sentence must be fully contained in data or postfix
|
||||
EXPECT_EQ(mappedName.find("POST"), 4);
|
||||
EXPECT_EQ(mappedName.find("POST", 4), 4);
|
||||
EXPECT_EQ(mappedName.find("POST", 5), -1);
|
||||
@@ -753,7 +759,7 @@ TEST(MappedName, rfind)
|
||||
EXPECT_EQ(mappedName.rfind(""), mappedName.size());
|
||||
EXPECT_EQ(mappedName.rfind(std::string("")), mappedName.size());
|
||||
EXPECT_EQ(mappedName.rfind("TEST"), 11);
|
||||
EXPECT_EQ(mappedName.rfind("STPO"), -1); //sentence must be fully contained in data or postfix
|
||||
EXPECT_EQ(mappedName.rfind("STPO"), -1);// sentence must be fully contained in data or postfix
|
||||
EXPECT_EQ(mappedName.rfind("POST"), 4);
|
||||
EXPECT_EQ(mappedName.rfind("POST", 4), 4);
|
||||
EXPECT_EQ(mappedName.rfind("POST", 3), -1);
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
/**************************************************************************
|
||||
* *
|
||||
* Copyright (c) 2021-2023 FreeCAD Project Association *
|
||||
* *
|
||||
* This file is part of FreeCAD. *
|
||||
* *
|
||||
* FreeCAD is free software: you can redistribute it and/or modify it *
|
||||
* under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 2.1 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* FreeCAD is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with FreeCAD. If not, see *
|
||||
* <https://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
* *
|
||||
* Copyright (c) 2021-2023 FreeCAD Project Association *
|
||||
* *
|
||||
* This file is part of FreeCAD. *
|
||||
* *
|
||||
* FreeCAD is free software: you can redistribute it and/or modify it *
|
||||
* under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 2.1 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* FreeCAD is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with FreeCAD. If not, see *
|
||||
* <https://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
// NOLINTNEXTLINE
|
||||
#include "gtest/gtest.h"
|
||||
@@ -27,90 +27,103 @@
|
||||
|
||||
// NOLINTBEGIN(readability-named-parameter)
|
||||
|
||||
TEST(ContactTest, ContactDefaultConstruction){
|
||||
TEST(ContactTest, ContactDefaultConstruction)
|
||||
{
|
||||
auto contact = App::Meta::Contact();
|
||||
ASSERT_EQ(contact.name,"");
|
||||
ASSERT_EQ(contact.email,"");
|
||||
ASSERT_EQ(contact.name, "");
|
||||
ASSERT_EQ(contact.email, "");
|
||||
}
|
||||
|
||||
TEST(ContactTest, ContactParameterConstruction){
|
||||
auto contact = App::Meta::Contact("Name","email@some.com");
|
||||
ASSERT_EQ(contact.name,"Name");
|
||||
ASSERT_EQ(contact.email,"email@some.com");
|
||||
TEST(ContactTest, ContactParameterConstruction)
|
||||
{
|
||||
auto contact = App::Meta::Contact("Name", "email@some.com");
|
||||
ASSERT_EQ(contact.name, "Name");
|
||||
ASSERT_EQ(contact.email, "email@some.com");
|
||||
}
|
||||
|
||||
TEST(ContactTest, ContactNullDomNodeConstruction){
|
||||
TEST(ContactTest, ContactNullDomNodeConstruction)
|
||||
{
|
||||
auto contact = App::Meta::Contact(nullptr);
|
||||
ASSERT_EQ(contact.name,"");
|
||||
ASSERT_EQ(contact.email,"");
|
||||
ASSERT_EQ(contact.name, "");
|
||||
ASSERT_EQ(contact.email, "");
|
||||
}
|
||||
|
||||
TEST(ContactTest, ContactOperatorEquality){
|
||||
auto contact1 = App::Meta::Contact("Name","Email");
|
||||
auto contact2 = App::Meta::Contact("Name","Email");
|
||||
auto contact3 = App::Meta::Contact("NotName","Email");
|
||||
auto contact4 = App::Meta::Contact("Name","NotEmail");
|
||||
TEST(ContactTest, ContactOperatorEquality)
|
||||
{
|
||||
auto contact1 = App::Meta::Contact("Name", "Email");
|
||||
auto contact2 = App::Meta::Contact("Name", "Email");
|
||||
auto contact3 = App::Meta::Contact("NotName", "Email");
|
||||
auto contact4 = App::Meta::Contact("Name", "NotEmail");
|
||||
ASSERT_TRUE(contact1 == contact2);
|
||||
ASSERT_FALSE(contact1 == contact3);
|
||||
ASSERT_FALSE(contact1 == contact4);
|
||||
}
|
||||
|
||||
TEST(LicenseTest, LicenseDefaultConstruction){
|
||||
TEST(LicenseTest, LicenseDefaultConstruction)
|
||||
{
|
||||
auto contact = App::Meta::License();
|
||||
ASSERT_EQ(contact.name,"");
|
||||
ASSERT_EQ(contact.file,"");
|
||||
ASSERT_EQ(contact.name, "");
|
||||
ASSERT_EQ(contact.file, "");
|
||||
}
|
||||
|
||||
TEST(LicenseTest, LicenseParameterConstruction){
|
||||
auto contact = App::Meta::License("Name","path/to/file");
|
||||
ASSERT_EQ(contact.name,"Name");
|
||||
ASSERT_EQ(contact.file,"path/to/file");
|
||||
TEST(LicenseTest, LicenseParameterConstruction)
|
||||
{
|
||||
auto contact = App::Meta::License("Name", "path/to/file");
|
||||
ASSERT_EQ(contact.name, "Name");
|
||||
ASSERT_EQ(contact.file, "path/to/file");
|
||||
}
|
||||
|
||||
TEST(LicenseTest, LicenseNullDomNodeConstruction){
|
||||
TEST(LicenseTest, LicenseNullDomNodeConstruction)
|
||||
{
|
||||
auto contact = App::Meta::License(nullptr);
|
||||
ASSERT_EQ(contact.name,"");
|
||||
ASSERT_EQ(contact.file,"");
|
||||
ASSERT_EQ(contact.name, "");
|
||||
ASSERT_EQ(contact.file, "");
|
||||
}
|
||||
|
||||
TEST(LicenseTest, LicenseOperatorEquality){
|
||||
auto license1 = App::Meta::License("Name","path/to/file");
|
||||
auto license2 = App::Meta::License("Name","path/to/file");
|
||||
auto license3 = App::Meta::License("NotName","path/to/file");
|
||||
auto license4 = App::Meta::License("Name","not/path/to/file");
|
||||
TEST(LicenseTest, LicenseOperatorEquality)
|
||||
{
|
||||
auto license1 = App::Meta::License("Name", "path/to/file");
|
||||
auto license2 = App::Meta::License("Name", "path/to/file");
|
||||
auto license3 = App::Meta::License("NotName", "path/to/file");
|
||||
auto license4 = App::Meta::License("Name", "not/path/to/file");
|
||||
ASSERT_TRUE(license1 == license2);
|
||||
ASSERT_FALSE(license1 == license3);
|
||||
ASSERT_FALSE(license1 == license4);
|
||||
}
|
||||
|
||||
TEST(UrlTest, UrlDefaultConstruction){
|
||||
TEST(UrlTest, UrlDefaultConstruction)
|
||||
{
|
||||
auto url = App::Meta::Url();
|
||||
ASSERT_EQ(url.location,"");
|
||||
ASSERT_EQ(url.type,App::Meta::UrlType::website);
|
||||
ASSERT_EQ(url.location, "");
|
||||
ASSERT_EQ(url.type, App::Meta::UrlType::website);
|
||||
}
|
||||
|
||||
TEST(UrlTest, UrlParameterConstruction){
|
||||
auto url = App::Meta::Url("https://some.url",App::Meta::UrlType::documentation);
|
||||
ASSERT_EQ(url.location,"https://some.url");
|
||||
ASSERT_EQ(url.type,App::Meta::UrlType::documentation);
|
||||
TEST(UrlTest, UrlParameterConstruction)
|
||||
{
|
||||
auto url = App::Meta::Url("https://some.url", App::Meta::UrlType::documentation);
|
||||
ASSERT_EQ(url.location, "https://some.url");
|
||||
ASSERT_EQ(url.type, App::Meta::UrlType::documentation);
|
||||
}
|
||||
|
||||
TEST(UrlTest, UrlNullDomNodeConstruction){
|
||||
TEST(UrlTest, UrlNullDomNodeConstruction)
|
||||
{
|
||||
auto url = App::Meta::Url(nullptr);
|
||||
ASSERT_EQ(url.location,"");
|
||||
ASSERT_EQ(url.location, "");
|
||||
}
|
||||
|
||||
TEST(UrlTest, UrlOperatorEquality){
|
||||
auto url1 = App::Meta::Url("https://some.url",App::Meta::UrlType::documentation);
|
||||
auto url2 = App::Meta::Url("https://some.url",App::Meta::UrlType::documentation);
|
||||
auto url3 = App::Meta::Url("https://not.some.url",App::Meta::UrlType::documentation);
|
||||
auto url4 = App::Meta::Url("https://some.url",App::Meta::UrlType::website);
|
||||
TEST(UrlTest, UrlOperatorEquality)
|
||||
{
|
||||
auto url1 = App::Meta::Url("https://some.url", App::Meta::UrlType::documentation);
|
||||
auto url2 = App::Meta::Url("https://some.url", App::Meta::UrlType::documentation);
|
||||
auto url3 = App::Meta::Url("https://not.some.url", App::Meta::UrlType::documentation);
|
||||
auto url4 = App::Meta::Url("https://some.url", App::Meta::UrlType::website);
|
||||
ASSERT_TRUE(url1 == url2);
|
||||
ASSERT_FALSE(url1 == url3);
|
||||
ASSERT_FALSE(url1 == url4);
|
||||
}
|
||||
|
||||
TEST(VersionTest, VersionDefaultConstruction){
|
||||
TEST(VersionTest, VersionDefaultConstruction)
|
||||
{
|
||||
auto version = App::Meta::Version();
|
||||
ASSERT_EQ(version.major, 0);
|
||||
ASSERT_EQ(version.minor, 0);
|
||||
@@ -118,15 +131,17 @@ TEST(VersionTest, VersionDefaultConstruction){
|
||||
ASSERT_EQ(version.suffix, "");
|
||||
}
|
||||
|
||||
TEST(VersionTest, VersionParameterConstruction){
|
||||
auto version = App::Meta::Version(1,2,3,"delta");
|
||||
TEST(VersionTest, VersionParameterConstruction)
|
||||
{
|
||||
auto version = App::Meta::Version(1, 2, 3, "delta");
|
||||
ASSERT_EQ(version.major, 1);
|
||||
ASSERT_EQ(version.minor, 2);
|
||||
ASSERT_EQ(version.patch, 3);
|
||||
ASSERT_EQ(version.suffix, "delta");
|
||||
}
|
||||
|
||||
TEST(VersionTest, VersionStringConstruction){
|
||||
TEST(VersionTest, VersionStringConstruction)
|
||||
{
|
||||
auto version = App::Meta::Version("1.2.3delta");
|
||||
ASSERT_EQ(version.major, 1);
|
||||
ASSERT_EQ(version.minor, 2);
|
||||
@@ -134,29 +149,31 @@ TEST(VersionTest, VersionStringConstruction){
|
||||
ASSERT_EQ(version.suffix, "delta");
|
||||
}
|
||||
|
||||
TEST(VersionTest, VersionOperatorEqual){
|
||||
auto version1 = App::Meta::Version(1,2,3,"delta");
|
||||
auto version2 = App::Meta::Version(1,2,3,"delta");
|
||||
auto version3 = App::Meta::Version(1,3,3,"delta");
|
||||
auto version4 = App::Meta::Version(1,2,4,"delta");
|
||||
auto version5 = App::Meta::Version(1,2,3,"gamma");
|
||||
TEST(VersionTest, VersionOperatorEqual)
|
||||
{
|
||||
auto version1 = App::Meta::Version(1, 2, 3, "delta");
|
||||
auto version2 = App::Meta::Version(1, 2, 3, "delta");
|
||||
auto version3 = App::Meta::Version(1, 3, 3, "delta");
|
||||
auto version4 = App::Meta::Version(1, 2, 4, "delta");
|
||||
auto version5 = App::Meta::Version(1, 2, 3, "gamma");
|
||||
ASSERT_EQ(version1, version2);
|
||||
ASSERT_NE(version1, version3);
|
||||
ASSERT_NE(version1, version4);
|
||||
ASSERT_NE(version1, version5);
|
||||
}
|
||||
|
||||
TEST(VersionTest, VersionOperatorComparison){
|
||||
auto version_2_3_4_delta = App::Meta::Version(2,3,4,"delta");
|
||||
auto version_1_3_4_delta = App::Meta::Version(1,3,4,"delta");
|
||||
auto version_3_3_4_delta = App::Meta::Version(3,3,4,"delta");
|
||||
auto version_2_2_4_delta = App::Meta::Version(2,2,4,"delta");
|
||||
auto version_2_4_4_delta = App::Meta::Version(2,4,4,"delta");
|
||||
auto version_2_3_3_delta = App::Meta::Version(2,3,3,"delta");
|
||||
TEST(VersionTest, VersionOperatorComparison)
|
||||
{
|
||||
auto version_2_3_4_delta = App::Meta::Version(2, 3, 4, "delta");
|
||||
auto version_1_3_4_delta = App::Meta::Version(1, 3, 4, "delta");
|
||||
auto version_3_3_4_delta = App::Meta::Version(3, 3, 4, "delta");
|
||||
auto version_2_2_4_delta = App::Meta::Version(2, 2, 4, "delta");
|
||||
auto version_2_4_4_delta = App::Meta::Version(2, 4, 4, "delta");
|
||||
auto version_2_3_3_delta = App::Meta::Version(2, 3, 3, "delta");
|
||||
// NOLINTNEXTLINE Five is not really a "magic number" in this test
|
||||
auto version_2_3_5_delta = App::Meta::Version(2,3,5,"delta");
|
||||
auto version_2_3_4_epsilon = App::Meta::Version(2,3,4,"epsilon");
|
||||
auto version_2_3_4_beta = App::Meta::Version(2,3,4,"beta");
|
||||
auto version_2_3_5_delta = App::Meta::Version(2, 3, 5, "delta");
|
||||
auto version_2_3_4_epsilon = App::Meta::Version(2, 3, 4, "epsilon");
|
||||
auto version_2_3_4_beta = App::Meta::Version(2, 3, 4, "beta");
|
||||
ASSERT_GT(version_2_3_4_delta, version_1_3_4_delta);
|
||||
ASSERT_LT(version_2_3_4_delta, version_3_3_4_delta);
|
||||
ASSERT_GT(version_2_3_4_delta, version_2_2_4_delta);
|
||||
@@ -170,42 +187,49 @@ TEST(VersionTest, VersionOperatorComparison){
|
||||
// TODO: Test Dependency
|
||||
// TODO: Test GenericMetadata
|
||||
|
||||
class MetadataTest : public ::testing::Test {
|
||||
class MetadataTest: public ::testing::Test
|
||||
{
|
||||
protected:
|
||||
void SetUp() override {
|
||||
void SetUp() override
|
||||
{
|
||||
xercesc_3_2::XMLPlatformUtils::Initialize();
|
||||
}
|
||||
void TearDown() override {
|
||||
void TearDown() override
|
||||
{
|
||||
xercesc_3_2::XMLPlatformUtils::Terminate();
|
||||
}
|
||||
std::string GivenSimpleMetadataXMLString()
|
||||
{
|
||||
std::ostringstream stream;
|
||||
stream << "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\" ?>\n"
|
||||
<< "<package format=\"1\" xmlns=\"https://wiki.freecad.org/Package_Metadata\">\n"
|
||||
<< " <name>" << _name << "</name>\n"
|
||||
<< " <description>" << _description << "</description>\n"
|
||||
<< " <version>" << _version << "</version>\n"
|
||||
<< " <date>2022-01-07</date>\n"
|
||||
<< " <url type=\"repository\" branch=\"main\">https://github.com/FreeCAD/FreeCAD</url>\n"
|
||||
<< "</package>";
|
||||
<< "<package format=\"1\" xmlns=\"https://wiki.freecad.org/Package_Metadata\">\n"
|
||||
<< " <name>" << _name << "</name>\n"
|
||||
<< " <description>" << _description << "</description>\n"
|
||||
<< " <version>" << _version << "</version>\n"
|
||||
<< " <date>2022-01-07</date>\n"
|
||||
<< " <url type=\"repository\" "
|
||||
"branch=\"main\">https://github.com/FreeCAD/FreeCAD</url>\n"
|
||||
<< "</package>";
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
void AssertMetadataMatches(App::Metadata &testObject) {
|
||||
void AssertMetadataMatches(App::Metadata& testObject)
|
||||
{
|
||||
ASSERT_EQ(testObject.name(), _name);
|
||||
ASSERT_EQ(testObject.description(), _description);
|
||||
ASSERT_EQ(testObject.version(), App::Meta::Version(_version));
|
||||
}
|
||||
|
||||
private:
|
||||
std::string _name = "TestAddon";
|
||||
std::string _description = "A package.xml file for unit testing.";
|
||||
std::string _version = "1.2.3beta";
|
||||
};
|
||||
|
||||
TEST_F(MetadataTest, MetadataInMemoryConstruction) {
|
||||
TEST_F(MetadataTest, MetadataInMemoryConstruction)
|
||||
{
|
||||
auto xml = GivenSimpleMetadataXMLString();
|
||||
auto testObject = App::Metadata(std::string{xml});
|
||||
auto testObject = App::Metadata(std::string {xml});
|
||||
AssertMetadataMatches(testObject);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include <QString>
|
||||
#include "Base/Builder3D.h"
|
||||
#include <QString>
|
||||
|
||||
TEST(Builder, one){
|
||||
QString ss{};
|
||||
TEST(Builder, one)
|
||||
{
|
||||
QString ss {};
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
#include "gtest/gtest.h"
|
||||
#include <boost/core/ignore_unused.hpp>
|
||||
#include <QLocale>
|
||||
#include <Base/Exception.h>
|
||||
#include <Base/Quantity.h>
|
||||
#include <Base/UnitsApi.h>
|
||||
#include <Base/UnitsSchemaImperial1.h>
|
||||
#include <QLocale>
|
||||
#include <boost/core/ignore_unused.hpp>
|
||||
|
||||
// NOLINTBEGIN
|
||||
TEST(BaseQuantity, TestValid)
|
||||
{
|
||||
Base::Quantity q1{1.0, Base::Unit::Length};
|
||||
Base::Quantity q2{1.0, Base::Unit::Area};
|
||||
Base::Quantity q1 {1.0, Base::Unit::Length};
|
||||
Base::Quantity q2 {1.0, Base::Unit::Area};
|
||||
q2.setInvalid();
|
||||
|
||||
EXPECT_EQ(q1.isValid(), true);
|
||||
@@ -22,74 +22,76 @@ TEST(BaseQuantity, TestParse)
|
||||
Base::Quantity q1 = Base::Quantity::parse(QString::fromLatin1("1,234 kg"));
|
||||
|
||||
EXPECT_EQ(q1, Base::Quantity(1.2340, Base::Unit::Mass));
|
||||
EXPECT_THROW(boost::ignore_unused(Base::Quantity::parse(QString::fromLatin1("1,234,500.12 kg"))), Base::ParserError);
|
||||
EXPECT_THROW(
|
||||
boost::ignore_unused(Base::Quantity::parse(QString::fromLatin1("1,234,500.12 kg"))),
|
||||
Base::ParserError);
|
||||
}
|
||||
|
||||
TEST(BaseQuantity, TestDim)
|
||||
{
|
||||
Base::Quantity q1{0, Base::Unit::Area};
|
||||
Base::Quantity q1 {0, Base::Unit::Area};
|
||||
|
||||
EXPECT_EQ(q1.isQuantity(), true);
|
||||
}
|
||||
|
||||
TEST(BaseQuantity, TestNoDim)
|
||||
{
|
||||
Base::Quantity q1{};
|
||||
Base::Quantity q1 {};
|
||||
|
||||
EXPECT_EQ(q1.pow(2), Base::Quantity{0});
|
||||
EXPECT_EQ(q1.pow(2), Base::Quantity {0});
|
||||
EXPECT_EQ(q1.isDimensionless(), true);
|
||||
}
|
||||
|
||||
TEST(BaseQuantity, TestPowEQ1)
|
||||
{
|
||||
Base::Quantity q1{2, Base::Unit::Area};
|
||||
Base::Quantity q1 {2, Base::Unit::Area};
|
||||
EXPECT_EQ(q1.pow(1), Base::Quantity(2, Base::Unit::Area));
|
||||
}
|
||||
|
||||
TEST(BaseQuantity, TestPowEQ0)
|
||||
{
|
||||
Base::Quantity q1{2, Base::Unit::Area};
|
||||
EXPECT_EQ(q1.pow(0), Base::Quantity{1});
|
||||
Base::Quantity q1 {2, Base::Unit::Area};
|
||||
EXPECT_EQ(q1.pow(0), Base::Quantity {1});
|
||||
}
|
||||
|
||||
TEST(BaseQuantity, TestPowGT1)
|
||||
{
|
||||
Base::Quantity q1{2, Base::Unit::Length};
|
||||
Base::Quantity q1 {2, Base::Unit::Length};
|
||||
EXPECT_EQ(q1.pow(2), Base::Quantity(4, Base::Unit::Area));
|
||||
}
|
||||
|
||||
TEST(BaseQuantity, TestPowLT1)
|
||||
{
|
||||
Base::Quantity q1{8, Base::Unit::Volume};
|
||||
EXPECT_EQ(q1.pow(1.0/3.0), Base::Quantity(2, Base::Unit::Length));
|
||||
Base::Quantity q1 {8, Base::Unit::Volume};
|
||||
EXPECT_EQ(q1.pow(1.0 / 3.0), Base::Quantity(2, Base::Unit::Length));
|
||||
}
|
||||
|
||||
TEST(BaseQuantity, TestPow3DIV2)
|
||||
{
|
||||
Base::Quantity unit{8, Base::Unit::Volume};
|
||||
EXPECT_THROW(unit.pow(3.0/2.0), Base::UnitsMismatchError);
|
||||
Base::Quantity unit {8, Base::Unit::Volume};
|
||||
EXPECT_THROW(unit.pow(3.0 / 2.0), Base::UnitsMismatchError);
|
||||
}
|
||||
|
||||
TEST(BaseQuantity, TestString)
|
||||
{
|
||||
Base::Quantity q1{2, QString::fromLatin1("kg*m/s^2")};
|
||||
Base::Quantity q1 {2, QString::fromLatin1("kg*m/s^2")};
|
||||
EXPECT_EQ(q1.getUnit(), Base::Unit::Force);
|
||||
|
||||
Base::Quantity q2{2, QString::fromLatin1("kg*m^2/s^2")};
|
||||
Base::Quantity q2 {2, QString::fromLatin1("kg*m^2/s^2")};
|
||||
EXPECT_EQ(q2.getUnit(), Base::Unit::Work);
|
||||
}
|
||||
|
||||
TEST(BaseQuantity, TestCopy)
|
||||
{
|
||||
Base::Quantity q1{1.0, Base::Unit::Length};
|
||||
Base::Quantity q1 {1.0, Base::Unit::Length};
|
||||
|
||||
EXPECT_EQ(Base::Quantity{q1}, q1);
|
||||
EXPECT_EQ(Base::Quantity {q1}, q1);
|
||||
}
|
||||
|
||||
TEST(BaseQuantity, TestEqual)
|
||||
{
|
||||
Base::Quantity q1{1.0, Base::Unit::Force};
|
||||
Base::Quantity q2{1.0, QString::fromLatin1("kg*mm/s^2")};
|
||||
Base::Quantity q1 {1.0, Base::Unit::Force};
|
||||
Base::Quantity q2 {1.0, QString::fromLatin1("kg*mm/s^2")};
|
||||
|
||||
EXPECT_EQ(q1 == q1, true);
|
||||
EXPECT_EQ(q1 == q2, true);
|
||||
@@ -97,9 +99,9 @@ TEST(BaseQuantity, TestEqual)
|
||||
|
||||
TEST(BaseQuantity, TestNotEqual)
|
||||
{
|
||||
Base::Quantity q1{1.0, Base::Unit::Force};
|
||||
Base::Quantity q2{2.0, QString::fromLatin1("kg*m/s^2")};
|
||||
Base::Quantity q3{1.0, Base::Unit::Work};
|
||||
Base::Quantity q1 {1.0, Base::Unit::Force};
|
||||
Base::Quantity q2 {2.0, QString::fromLatin1("kg*m/s^2")};
|
||||
Base::Quantity q3 {1.0, Base::Unit::Work};
|
||||
|
||||
EXPECT_EQ(q1 != q2, true);
|
||||
EXPECT_EQ(q1 != q3, true);
|
||||
@@ -107,9 +109,9 @@ TEST(BaseQuantity, TestNotEqual)
|
||||
|
||||
TEST(BaseQuantity, TestLessOrGreater)
|
||||
{
|
||||
Base::Quantity q1{1.0, Base::Unit::Force};
|
||||
Base::Quantity q2{2.0, QString::fromLatin1("kg*m/s^2")};
|
||||
Base::Quantity q3{2.0, Base::Unit::Work};
|
||||
Base::Quantity q1 {1.0, Base::Unit::Force};
|
||||
Base::Quantity q2 {2.0, QString::fromLatin1("kg*m/s^2")};
|
||||
Base::Quantity q3 {2.0, Base::Unit::Work};
|
||||
|
||||
EXPECT_EQ(q1 < q2, true);
|
||||
EXPECT_EQ(q1 > q2, false);
|
||||
@@ -123,8 +125,8 @@ TEST(BaseQuantity, TestLessOrGreater)
|
||||
|
||||
TEST(BaseQuantity, TestAdd)
|
||||
{
|
||||
Base::Quantity q1{1.0, Base::Unit::Length};
|
||||
Base::Quantity q2{1.0, Base::Unit::Area};
|
||||
Base::Quantity q1 {1.0, Base::Unit::Length};
|
||||
Base::Quantity q2 {1.0, Base::Unit::Area};
|
||||
EXPECT_THROW(q1 + q2, Base::UnitsMismatchError);
|
||||
EXPECT_THROW(q1 += q2, Base::UnitsMismatchError);
|
||||
EXPECT_EQ(q1 + q1, Base::Quantity(2, Base::Unit::Length));
|
||||
@@ -133,8 +135,8 @@ TEST(BaseQuantity, TestAdd)
|
||||
|
||||
TEST(BaseQuantity, TestSub)
|
||||
{
|
||||
Base::Quantity q1{1.0, Base::Unit::Length};
|
||||
Base::Quantity q2{1.0, Base::Unit::Area};
|
||||
Base::Quantity q1 {1.0, Base::Unit::Length};
|
||||
Base::Quantity q2 {1.0, Base::Unit::Area};
|
||||
EXPECT_THROW(q1 - q2, Base::UnitsMismatchError);
|
||||
EXPECT_THROW(q1 -= q2, Base::UnitsMismatchError);
|
||||
EXPECT_EQ(q1 - q1, Base::Quantity(0, Base::Unit::Length));
|
||||
@@ -143,51 +145,53 @@ TEST(BaseQuantity, TestSub)
|
||||
|
||||
TEST(BaseQuantity, TestNeg)
|
||||
{
|
||||
Base::Quantity q1{1.0, Base::Unit::Length};
|
||||
Base::Quantity q1 {1.0, Base::Unit::Length};
|
||||
EXPECT_EQ(-q1, Base::Quantity(-1.0, Base::Unit::Length));
|
||||
}
|
||||
|
||||
TEST(BaseQuantity, TestMult)
|
||||
{
|
||||
Base::Quantity q1{1.0, Base::Unit::Length};
|
||||
Base::Quantity q2{1.0, Base::Unit::Area};
|
||||
Base::Quantity q1 {1.0, Base::Unit::Length};
|
||||
Base::Quantity q2 {1.0, Base::Unit::Area};
|
||||
EXPECT_EQ(q1 * q2, Base::Quantity(1.0, Base::Unit::Volume));
|
||||
EXPECT_EQ(q1 * 2.0, Base::Quantity(2.0, Base::Unit::Length));
|
||||
}
|
||||
|
||||
TEST(BaseQuantity, TestDiv)
|
||||
{
|
||||
Base::Quantity q1{1.0, Base::Unit::Length};
|
||||
Base::Quantity q2{1.0, Base::Unit::Area};
|
||||
Base::Quantity q1 {1.0, Base::Unit::Length};
|
||||
Base::Quantity q2 {1.0, Base::Unit::Area};
|
||||
EXPECT_EQ(q1 / q2, Base::Quantity(1.0, Base::Unit::InverseLength));
|
||||
EXPECT_EQ(q1 / 2.0, Base::Quantity(0.5, Base::Unit::Length));
|
||||
}
|
||||
|
||||
TEST(BaseQuantity, TestPow)
|
||||
{
|
||||
Base::Quantity q1{2.0, Base::Unit::Length};
|
||||
Base::Quantity q2{2.0, Base::Unit::Area};
|
||||
Base::Quantity q3{0.0};
|
||||
EXPECT_EQ(q1.pow(q3), Base::Quantity{1});
|
||||
Base::Quantity q1 {2.0, Base::Unit::Length};
|
||||
Base::Quantity q2 {2.0, Base::Unit::Area};
|
||||
Base::Quantity q3 {0.0};
|
||||
EXPECT_EQ(q1.pow(q3), Base::Quantity {1});
|
||||
EXPECT_EQ(q1.pow(2.0), Base::Quantity(4, Base::Unit::Area));
|
||||
EXPECT_THROW(q1.pow(q2), Base::UnitsMismatchError);
|
||||
}
|
||||
|
||||
class Quantity : public ::testing::Test {
|
||||
class Quantity: public ::testing::Test
|
||||
{
|
||||
protected:
|
||||
void SetUp() override {
|
||||
void SetUp() override
|
||||
{
|
||||
QLocale loc(QLocale::C);
|
||||
QLocale::setDefault(loc);
|
||||
}
|
||||
void TearDown() override {
|
||||
}
|
||||
void TearDown() override
|
||||
{}
|
||||
};
|
||||
|
||||
TEST_F(Quantity, TestSchemeImperialTwo)
|
||||
{
|
||||
Base::Quantity quantity{1.0, Base::Unit::Length};
|
||||
Base::Quantity quantity {1.0, Base::Unit::Length};
|
||||
|
||||
double factor{};
|
||||
double factor {};
|
||||
QString unitString;
|
||||
auto scheme = Base::UnitsApi::createSchema(Base::UnitSystem::ImperialDecimal);
|
||||
QString result = scheme->schemaTranslate(quantity, factor, unitString);
|
||||
@@ -196,13 +200,13 @@ TEST_F(Quantity, TestSchemeImperialTwo)
|
||||
|
||||
TEST_F(Quantity, TestSchemeImperialOne)
|
||||
{
|
||||
Base::Quantity quantity{1.0, Base::Unit::Length};
|
||||
Base::Quantity quantity {1.0, Base::Unit::Length};
|
||||
|
||||
Base::QuantityFormat format = quantity.getFormat();
|
||||
format.precision = 1;
|
||||
quantity.setFormat(format);
|
||||
|
||||
double factor{};
|
||||
double factor {};
|
||||
QString unitString;
|
||||
auto scheme = Base::UnitsApi::createSchema(Base::UnitSystem::ImperialDecimal);
|
||||
QString result = scheme->schemaTranslate(quantity, factor, unitString);
|
||||
@@ -214,7 +218,7 @@ TEST_F(Quantity, TestSafeUserString)
|
||||
{
|
||||
Base::UnitsApi::setSchema(Base::UnitSystem::ImperialDecimal);
|
||||
|
||||
Base::Quantity quantity{1.0, Base::Unit::Length};
|
||||
Base::Quantity quantity {1.0, Base::Unit::Length};
|
||||
Base::QuantityFormat format = quantity.getFormat();
|
||||
format.precision = 1;
|
||||
quantity.setFormat(format);
|
||||
|
||||
@@ -69,10 +69,10 @@ TEST(Rotation, TestUniformScaleLT1)
|
||||
TEST(Rotation, TestRotationFailure)
|
||||
{
|
||||
Base::Matrix4D mat;
|
||||
mat.setCol(0, Base::Vector3d{1, 0, 0});
|
||||
mat.setCol(1, Base::Vector3d{1, 1, 0});
|
||||
mat.setCol(2, Base::Vector3d{0, 0, 1});
|
||||
mat.setCol(0, Base::Vector3d {1, 0, 0});
|
||||
mat.setCol(1, Base::Vector3d {1, 1, 0});
|
||||
mat.setCol(2, Base::Vector3d {0, 0, 1});
|
||||
|
||||
EXPECT_THROW(Base::Rotation{mat}, Base::ValueError);
|
||||
EXPECT_THROW(Base::Rotation {mat}, Base::ValueError);
|
||||
}
|
||||
// NOLINTEND(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "gtest/gtest.h"
|
||||
#include "Base/Unit.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include <Base/Exception.h>
|
||||
|
||||
// NOLINTBEGIN
|
||||
@@ -8,17 +8,17 @@ TEST(Unit, TestString)
|
||||
auto toString = [](const Base::Unit& unit) {
|
||||
return unit.getString().toStdString();
|
||||
};
|
||||
EXPECT_EQ(toString(Base::Unit(0,0,0,0,0,0,0,0)), "");
|
||||
EXPECT_EQ(toString(Base::Unit(1,0,0,0,0,0,0,0)), "mm");
|
||||
EXPECT_EQ(toString(Base::Unit(0,1,0,0,0,0,0,0)), "kg");
|
||||
EXPECT_EQ(toString(Base::Unit(0,0,1,0,0,0,0,0)), "s");
|
||||
EXPECT_EQ(toString(Base::Unit(0,0,0,1,0,0,0,0)), "A");
|
||||
EXPECT_EQ(toString(Base::Unit(0,0,0,0,1,0,0,0)), "K");
|
||||
EXPECT_EQ(toString(Base::Unit(0,0,0,0,0,1,0,0)), "mol");
|
||||
EXPECT_EQ(toString(Base::Unit(0,0,0,0,0,0,1,0)), "cd");
|
||||
EXPECT_EQ(toString(Base::Unit(0,0,0,0,0,0,0,1)), "deg");
|
||||
EXPECT_EQ(toString(Base::Unit(2,0,0,0,0,0,0,0)), "mm^2");
|
||||
EXPECT_EQ(toString(Base::Unit(1,1,-2,0,0,0,0,0)), "mm*kg/s^2");
|
||||
EXPECT_EQ(toString(Base::Unit(0, 0, 0, 0, 0, 0, 0, 0)), "");
|
||||
EXPECT_EQ(toString(Base::Unit(1, 0, 0, 0, 0, 0, 0, 0)), "mm");
|
||||
EXPECT_EQ(toString(Base::Unit(0, 1, 0, 0, 0, 0, 0, 0)), "kg");
|
||||
EXPECT_EQ(toString(Base::Unit(0, 0, 1, 0, 0, 0, 0, 0)), "s");
|
||||
EXPECT_EQ(toString(Base::Unit(0, 0, 0, 1, 0, 0, 0, 0)), "A");
|
||||
EXPECT_EQ(toString(Base::Unit(0, 0, 0, 0, 1, 0, 0, 0)), "K");
|
||||
EXPECT_EQ(toString(Base::Unit(0, 0, 0, 0, 0, 1, 0, 0)), "mol");
|
||||
EXPECT_EQ(toString(Base::Unit(0, 0, 0, 0, 0, 0, 1, 0)), "cd");
|
||||
EXPECT_EQ(toString(Base::Unit(0, 0, 0, 0, 0, 0, 0, 1)), "deg");
|
||||
EXPECT_EQ(toString(Base::Unit(2, 0, 0, 0, 0, 0, 0, 0)), "mm^2");
|
||||
EXPECT_EQ(toString(Base::Unit(1, 1, -2, 0, 0, 0, 0, 0)), "mm*kg/s^2");
|
||||
}
|
||||
|
||||
TEST(Unit, TestTypeString)
|
||||
@@ -29,7 +29,7 @@ TEST(Unit, TestTypeString)
|
||||
EXPECT_EQ(toString(Base::Unit::Acceleration), "Acceleration");
|
||||
EXPECT_EQ(toString(Base::Unit::AmountOfSubstance), "AmountOfSubstance");
|
||||
EXPECT_EQ(toString(Base::Unit::Angle), "Angle");
|
||||
EXPECT_EQ(toString(Base::Unit::AngleOfFriction), "Angle"); // same unit as Angle
|
||||
EXPECT_EQ(toString(Base::Unit::AngleOfFriction), "Angle");// same unit as Angle
|
||||
EXPECT_EQ(toString(Base::Unit::Area), "Area");
|
||||
EXPECT_EQ(toString(Base::Unit::CurrentDensity), "CurrentDensity");
|
||||
EXPECT_EQ(toString(Base::Unit::Density), "Density");
|
||||
@@ -55,136 +55,139 @@ TEST(Unit, TestTypeString)
|
||||
EXPECT_EQ(toString(Base::Unit::MagneticFieldStrength), "MagneticFieldStrength");
|
||||
EXPECT_EQ(toString(Base::Unit::MagneticFlux), "MagneticFlux");
|
||||
EXPECT_EQ(toString(Base::Unit::MagneticFluxDensity), "MagneticFluxDensity");
|
||||
EXPECT_EQ(toString(Base::Unit::Magnetization), "MagneticFieldStrength"); // same as MagneticFieldStrength
|
||||
EXPECT_EQ(toString(Base::Unit::Magnetization),
|
||||
"MagneticFieldStrength");// same as MagneticFieldStrength
|
||||
EXPECT_EQ(toString(Base::Unit::Mass), "Mass");
|
||||
EXPECT_EQ(toString(Base::Unit::Pressure), "Pressure");
|
||||
EXPECT_EQ(toString(Base::Unit::Power), "Power");
|
||||
EXPECT_EQ(toString(Base::Unit::ShearModulus), "Pressure"); // same as Pressure
|
||||
EXPECT_EQ(toString(Base::Unit::ShearModulus), "Pressure");// same as Pressure
|
||||
EXPECT_EQ(toString(Base::Unit::SpecificEnergy), "SpecificEnergy");
|
||||
EXPECT_EQ(toString(Base::Unit::SpecificHeat), "SpecificHeat");
|
||||
EXPECT_EQ(toString(Base::Unit::Stiffness), "Stiffness");
|
||||
EXPECT_EQ(toString(Base::Unit::Stress), "Pressure"); // same as Pressure
|
||||
EXPECT_EQ(toString(Base::Unit::Stress), "Pressure");// same as Pressure
|
||||
EXPECT_EQ(toString(Base::Unit::Temperature), "Temperature");
|
||||
EXPECT_EQ(toString(Base::Unit::ThermalConductivity), "ThermalConductivity");
|
||||
EXPECT_EQ(toString(Base::Unit::ThermalExpansionCoefficient), "ThermalExpansionCoefficient");
|
||||
EXPECT_EQ(toString(Base::Unit::ThermalTransferCoefficient), "ThermalTransferCoefficient");
|
||||
EXPECT_EQ(toString(Base::Unit::TimeSpan), "TimeSpan");
|
||||
EXPECT_EQ(toString(Base::Unit::UltimateTensileStrength), "Pressure"); // same as Pressure
|
||||
EXPECT_EQ(toString(Base::Unit::UltimateTensileStrength), "Pressure");// same as Pressure
|
||||
EXPECT_EQ(toString(Base::Unit::VacuumPermittivity), "VacuumPermittivity");
|
||||
EXPECT_EQ(toString(Base::Unit::Velocity), "Velocity");
|
||||
EXPECT_EQ(toString(Base::Unit::Volume), "Volume");
|
||||
EXPECT_EQ(toString(Base::Unit::VolumeFlowRate), "VolumeFlowRate");
|
||||
EXPECT_EQ(toString(Base::Unit::VolumetricThermalExpansionCoefficient), "ThermalExpansionCoefficient");
|
||||
EXPECT_EQ(toString(Base::Unit::VolumetricThermalExpansionCoefficient),
|
||||
"ThermalExpansionCoefficient");
|
||||
EXPECT_EQ(toString(Base::Unit::Work), "Work");
|
||||
EXPECT_EQ(toString(Base::Unit::YieldStrength), "Pressure"); // same as Pressure
|
||||
EXPECT_EQ(toString(Base::Unit::YoungsModulus), "Pressure"); // same unit as Pressure
|
||||
EXPECT_EQ(toString(Base::Unit::YieldStrength), "Pressure");// same as Pressure
|
||||
EXPECT_EQ(toString(Base::Unit::YoungsModulus), "Pressure");// same unit as Pressure
|
||||
}
|
||||
TEST(Unit, strings){
|
||||
EXPECT_STREQ(Base::Unit::Acceleration.getString().toStdString().c_str() , "mm/s^2");
|
||||
EXPECT_STREQ(Base::Unit::AmountOfSubstance.getString().toStdString().c_str() , "mol");
|
||||
EXPECT_STREQ(Base::Unit::Angle.getString().toStdString().c_str() , "deg");
|
||||
EXPECT_STREQ(Base::Unit::AngleOfFriction.getString().toStdString().c_str() , "deg");
|
||||
EXPECT_STREQ(Base::Unit::Area.getString().toStdString().c_str() , "mm^2");
|
||||
EXPECT_STREQ(Base::Unit::CurrentDensity.getString().toStdString().c_str() , "A/mm^2");
|
||||
EXPECT_STREQ(Base::Unit::Density.getString().toStdString().c_str() , "kg/mm^3");
|
||||
EXPECT_STREQ(Base::Unit::DissipationRate.getString().toStdString().c_str() , "mm^2/s^3");
|
||||
TEST(Unit, strings)
|
||||
{
|
||||
EXPECT_STREQ(Base::Unit::Acceleration.getString().toStdString().c_str(), "mm/s^2");
|
||||
EXPECT_STREQ(Base::Unit::AmountOfSubstance.getString().toStdString().c_str(), "mol");
|
||||
EXPECT_STREQ(Base::Unit::Angle.getString().toStdString().c_str(), "deg");
|
||||
EXPECT_STREQ(Base::Unit::AngleOfFriction.getString().toStdString().c_str(), "deg");
|
||||
EXPECT_STREQ(Base::Unit::Area.getString().toStdString().c_str(), "mm^2");
|
||||
EXPECT_STREQ(Base::Unit::CurrentDensity.getString().toStdString().c_str(), "A/mm^2");
|
||||
EXPECT_STREQ(Base::Unit::Density.getString().toStdString().c_str(), "kg/mm^3");
|
||||
EXPECT_STREQ(Base::Unit::DissipationRate.getString().toStdString().c_str(), "mm^2/s^3");
|
||||
}
|
||||
|
||||
TEST(Unit, TestEqual)
|
||||
{
|
||||
Base::Unit unit{1};
|
||||
EXPECT_EQ(unit.pow(2) == Base::Unit{2}, true);
|
||||
Base::Unit unit {1};
|
||||
EXPECT_EQ(unit.pow(2) == Base::Unit {2}, true);
|
||||
}
|
||||
|
||||
TEST(Unit, TestNotEqual)
|
||||
{
|
||||
Base::Unit unit{1};
|
||||
EXPECT_EQ(unit.pow(2) != Base::Unit{1}, true);
|
||||
Base::Unit unit {1};
|
||||
EXPECT_EQ(unit.pow(2) != Base::Unit {1}, true);
|
||||
}
|
||||
|
||||
TEST(Unit, TestMult)
|
||||
{
|
||||
EXPECT_EQ(Base::Unit{} * Base::Unit{}, Base::Unit{});
|
||||
EXPECT_EQ(Base::Unit {} * Base::Unit {}, Base::Unit {});
|
||||
EXPECT_EQ(Base::Unit(0, 1) * Base::Unit(1, 0), Base::Unit(1, 1));
|
||||
}
|
||||
|
||||
TEST(Unit, TestDiv)
|
||||
{
|
||||
EXPECT_EQ(Base::Unit{} * Base::Unit{}, Base::Unit{});
|
||||
EXPECT_EQ(Base::Unit {} * Base::Unit {}, Base::Unit {});
|
||||
EXPECT_EQ(Base::Unit(0, 1) / Base::Unit(1, 0), Base::Unit(-1, 1));
|
||||
}
|
||||
|
||||
TEST(Unit, TestPowNoDim)
|
||||
{
|
||||
Base::Unit unit{};
|
||||
EXPECT_EQ(unit.pow(2), Base::Unit{0});
|
||||
Base::Unit unit {};
|
||||
EXPECT_EQ(unit.pow(2), Base::Unit {0});
|
||||
EXPECT_EQ(unit.isEmpty(), true);
|
||||
}
|
||||
|
||||
TEST(Unit, TestPowEQ1)
|
||||
{
|
||||
Base::Unit unit{2};
|
||||
EXPECT_EQ(unit.pow(1), Base::Unit{2});
|
||||
Base::Unit unit {2};
|
||||
EXPECT_EQ(unit.pow(1), Base::Unit {2});
|
||||
}
|
||||
|
||||
TEST(Unit, TestPowEQ0)
|
||||
{
|
||||
Base::Unit unit{2};
|
||||
EXPECT_EQ(unit.pow(0), Base::Unit{0});
|
||||
Base::Unit unit {2};
|
||||
EXPECT_EQ(unit.pow(0), Base::Unit {0});
|
||||
}
|
||||
|
||||
TEST(Unit, TestPowGT1)
|
||||
{
|
||||
Base::Unit unit{2};
|
||||
EXPECT_EQ(unit.pow(2), Base::Unit{4});
|
||||
Base::Unit unit {2};
|
||||
EXPECT_EQ(unit.pow(2), Base::Unit {4});
|
||||
}
|
||||
|
||||
TEST(Unit, TestPowLT1)
|
||||
{
|
||||
Base::Unit unit{3};
|
||||
EXPECT_EQ(unit.pow(1.0/3.0), Base::Unit{1});
|
||||
Base::Unit unit {3};
|
||||
EXPECT_EQ(unit.pow(1.0 / 3.0), Base::Unit {1});
|
||||
}
|
||||
|
||||
TEST(Unit, TestPow3DIV2)
|
||||
{
|
||||
Base::Unit unit{3};
|
||||
EXPECT_THROW(unit.pow(3.0/2.0), Base::UnitsMismatchError);
|
||||
Base::Unit unit {3};
|
||||
EXPECT_THROW(unit.pow(3.0 / 2.0), Base::UnitsMismatchError);
|
||||
}
|
||||
|
||||
TEST(Unit, TestOverflow)
|
||||
{
|
||||
// this tests _that_ the expected exception is thrown
|
||||
EXPECT_THROW({
|
||||
try
|
||||
EXPECT_THROW(
|
||||
{
|
||||
Base::Unit unit{3};
|
||||
unit.pow(10000);
|
||||
}
|
||||
catch (const Base::OverflowError& e)
|
||||
{
|
||||
// and this tests that it has the correct message
|
||||
EXPECT_STREQ( "Unit overflow in pow()", e.what());
|
||||
throw;
|
||||
}
|
||||
}, Base::OverflowError);
|
||||
try {
|
||||
Base::Unit unit {3};
|
||||
unit.pow(10000);
|
||||
}
|
||||
catch (const Base::OverflowError& e) {
|
||||
// and this tests that it has the correct message
|
||||
EXPECT_STREQ("Unit overflow in pow()", e.what());
|
||||
throw;
|
||||
}
|
||||
},
|
||||
Base::OverflowError);
|
||||
}
|
||||
|
||||
TEST(Unit, TestUnderflow)
|
||||
{
|
||||
// this tests _that_ the expected exception is thrown
|
||||
EXPECT_THROW({
|
||||
try
|
||||
EXPECT_THROW(
|
||||
{
|
||||
Base::Unit unit{3};
|
||||
unit.pow(-10000);
|
||||
}
|
||||
catch (const Base::UnderflowError& e)
|
||||
{
|
||||
// and this tests that it has the correct message
|
||||
EXPECT_STREQ( "Unit underflow in pow()", e.what());
|
||||
throw;
|
||||
}
|
||||
}, Base::UnderflowError);
|
||||
try {
|
||||
Base::Unit unit {3};
|
||||
unit.pow(-10000);
|
||||
}
|
||||
catch (const Base::UnderflowError& e) {
|
||||
// and this tests that it has the correct message
|
||||
EXPECT_STREQ("Unit underflow in pow()", e.what());
|
||||
throw;
|
||||
}
|
||||
},
|
||||
Base::UnderflowError);
|
||||
}
|
||||
|
||||
// NOLINTEND
|
||||
|
||||
@@ -2,6 +2,5 @@
|
||||
|
||||
#include "Gui/Assistant.h"
|
||||
|
||||
TEST(Assistant, first){
|
||||
|
||||
}
|
||||
TEST(Assistant, first)
|
||||
{}
|
||||
|
||||
@@ -1,22 +1,26 @@
|
||||
#include "gtest/gtest.h"
|
||||
#include "fmt/format.h"
|
||||
#include "fmt/printf.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include <stdexcept>
|
||||
|
||||
TEST(fmt, fail){
|
||||
EXPECT_NE("abc", fmt::format("{}{}","a","b"));
|
||||
TEST(fmt, fail)
|
||||
{
|
||||
EXPECT_NE("abc", fmt::format("{}{}", "a", "b"));
|
||||
}
|
||||
|
||||
TEST(fmt, pass){
|
||||
EXPECT_EQ("ab", fmt::format("{}{}","a","b"));
|
||||
TEST(fmt, pass)
|
||||
{
|
||||
EXPECT_EQ("ab", fmt::format("{}{}", "a", "b"));
|
||||
}
|
||||
|
||||
TEST(fmt, print_pass){
|
||||
EXPECT_EQ("12", fmt::sprintf("%s%d","1",2));
|
||||
TEST(fmt, print_pass)
|
||||
{
|
||||
EXPECT_EQ("12", fmt::sprintf("%s%d", "1", 2));
|
||||
EXPECT_EQ("x", fmt::sprintf("%c", 'x'));
|
||||
EXPECT_EQ("1.23 2", fmt::sprintf("%.2f %d",1.23456,2));
|
||||
EXPECT_EQ("1.23 2", fmt::sprintf("%.2f %d", 1.23456, 2));
|
||||
}
|
||||
|
||||
TEST(fmt, print_fail){
|
||||
EXPECT_THROW(fmt::printf("%s%d",1,2), std::exception);
|
||||
TEST(fmt, print_fail)
|
||||
{
|
||||
EXPECT_THROW(fmt::printf("%s%d", 1, 2), std::exception);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#include <QTest>
|
||||
#include <QDebug>
|
||||
#include <sstream>
|
||||
#include <Base/Builder3D.h>
|
||||
#include <Inventor/SoDB.h>
|
||||
#include <Inventor/SoInput.h>
|
||||
#include <Inventor/nodes/SoSeparator.h>
|
||||
#include <QDebug>
|
||||
#include <QTest>
|
||||
#include <sstream>
|
||||
|
||||
Q_DECLARE_METATYPE(Base::Vector3f)
|
||||
Q_DECLARE_METATYPE(Base::ColorRGB)
|
||||
@@ -15,23 +15,21 @@ Q_DECLARE_METATYPE(Base::DrawStyle::Style)
|
||||
Q_DECLARE_METATYPE(Base::PolygonOffset)
|
||||
Q_DECLARE_METATYPE(Base::PolygonOffset::Style)
|
||||
|
||||
class testInventorBuilder : public QObject
|
||||
class testInventorBuilder: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
testInventorBuilder()
|
||||
: builder(output)
|
||||
{
|
||||
}
|
||||
{}
|
||||
~testInventorBuilder()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
SoNode* loadBuffer(const std::string& buffer)
|
||||
{
|
||||
SoInput in;
|
||||
in.setBuffer((void *)buffer.c_str(), buffer.size());
|
||||
in.setBuffer((void*)buffer.c_str(), buffer.size());
|
||||
return SoDB::readAll(&in);
|
||||
}
|
||||
|
||||
@@ -41,17 +39,14 @@ private Q_SLOTS:
|
||||
SoDB::init();
|
||||
}
|
||||
void initTestCase_data()
|
||||
{
|
||||
|
||||
}
|
||||
{}
|
||||
void cleanupTestCase()
|
||||
{
|
||||
SoDB::finish();
|
||||
}
|
||||
|
||||
void init()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void cleanup()
|
||||
{
|
||||
@@ -76,24 +71,24 @@ private Q_SLOTS:
|
||||
{
|
||||
QTest::addColumn<Base::BindingElement::Binding>("input");
|
||||
QTest::addColumn<QString>("result");
|
||||
QTest::newRow("MaterialBinding") << Base::BindingElement::Binding::Overall
|
||||
<< "MaterialBinding { value OVERALL } \n";
|
||||
QTest::newRow("MaterialBinding") << Base::BindingElement::Binding::PerPart
|
||||
<< "MaterialBinding { value PER_PART } \n";
|
||||
QTest::newRow("MaterialBinding")
|
||||
<< Base::BindingElement::Binding::Overall << "MaterialBinding { value OVERALL } \n";
|
||||
QTest::newRow("MaterialBinding")
|
||||
<< Base::BindingElement::Binding::PerPart << "MaterialBinding { value PER_PART } \n";
|
||||
QTest::newRow("MaterialBinding") << Base::BindingElement::Binding::PerPartIndexed
|
||||
<< "MaterialBinding { value PER_PART_INDEXED } \n";
|
||||
QTest::newRow("MaterialBinding") << Base::BindingElement::Binding::PerFace
|
||||
<< "MaterialBinding { value PER_FACE } \n";
|
||||
QTest::newRow("MaterialBinding")
|
||||
<< Base::BindingElement::Binding::PerFace << "MaterialBinding { value PER_FACE } \n";
|
||||
QTest::newRow("MaterialBinding") << Base::BindingElement::Binding::PerFaceIndexed
|
||||
<< "MaterialBinding { value PER_FACE_INDEXED } \n";
|
||||
QTest::newRow("MaterialBinding") << Base::BindingElement::Binding::PerVertex
|
||||
<< "MaterialBinding { value PER_VERTEX } \n";
|
||||
QTest::newRow("MaterialBinding") << Base::BindingElement::Binding::PerVertexIndexed
|
||||
<< "MaterialBinding { value PER_VERTEX_INDEXED } \n";
|
||||
QTest::newRow("MaterialBinding") << Base::BindingElement::Binding::Default
|
||||
<< "MaterialBinding { value OVERALL } \n";
|
||||
QTest::newRow("MaterialBinding") << Base::BindingElement::Binding::None
|
||||
<< "MaterialBinding { value OVERALL } \n";
|
||||
QTest::newRow("MaterialBinding")
|
||||
<< Base::BindingElement::Binding::Default << "MaterialBinding { value OVERALL } \n";
|
||||
QTest::newRow("MaterialBinding")
|
||||
<< Base::BindingElement::Binding::None << "MaterialBinding { value OVERALL } \n";
|
||||
}
|
||||
|
||||
void test_MaterialBinding()
|
||||
@@ -112,7 +107,7 @@ private Q_SLOTS:
|
||||
void test_Label_data()
|
||||
{
|
||||
auto result =
|
||||
R"(Label {
|
||||
R"(Label {
|
||||
label "FreeCAD"
|
||||
}
|
||||
)";
|
||||
@@ -126,7 +121,7 @@ R"(Label {
|
||||
QFETCH(QString, input);
|
||||
QFETCH(QString, result);
|
||||
|
||||
Base::LabelItem item{input.toStdString()};
|
||||
Base::LabelItem item {input.toStdString()};
|
||||
builder.addNode(item);
|
||||
|
||||
QString string = QString::fromStdString(output.str());
|
||||
@@ -136,7 +131,7 @@ R"(Label {
|
||||
void test_Info_data()
|
||||
{
|
||||
auto result =
|
||||
R"(Info {
|
||||
R"(Info {
|
||||
string "FreeCAD"
|
||||
}
|
||||
)";
|
||||
@@ -150,7 +145,7 @@ R"(Info {
|
||||
QFETCH(QString, input);
|
||||
QFETCH(QString, result);
|
||||
|
||||
Base::InfoItem item{input.toStdString()};
|
||||
Base::InfoItem item {input.toStdString()};
|
||||
builder.addNode(item);
|
||||
|
||||
QString string = QString::fromStdString(output.str());
|
||||
@@ -170,7 +165,7 @@ R"(Info {
|
||||
QFETCH(QString, input);
|
||||
QFETCH(QString, result);
|
||||
|
||||
Base::Text2Item item{input.toStdString()};
|
||||
Base::Text2Item item {input.toStdString()};
|
||||
builder.addNode(item);
|
||||
|
||||
QString string = QString::fromStdString(output.str());
|
||||
@@ -180,13 +175,13 @@ R"(Info {
|
||||
void test_BaseColor_data()
|
||||
{
|
||||
auto result =
|
||||
R"(BaseColor {
|
||||
R"(BaseColor {
|
||||
rgb 0.21 0.3 0.4
|
||||
}
|
||||
)";
|
||||
QTest::addColumn<Base::ColorRGB>("input");
|
||||
QTest::addColumn<QString>("result");
|
||||
QTest::newRow("BaseColor") << Base::ColorRGB{0.21F, 0.3F, 0.4F} << result;
|
||||
QTest::newRow("BaseColor") << Base::ColorRGB {0.21F, 0.3F, 0.4F} << result;
|
||||
}
|
||||
|
||||
void test_BaseColor()
|
||||
@@ -194,7 +189,7 @@ R"(BaseColor {
|
||||
QFETCH(Base::ColorRGB, input);
|
||||
QFETCH(QString, result);
|
||||
|
||||
Base::BaseColorItem item{input};
|
||||
Base::BaseColorItem item {input};
|
||||
builder.addNode(item);
|
||||
|
||||
QString string = QString::fromStdString(output.str());
|
||||
@@ -204,13 +199,13 @@ R"(BaseColor {
|
||||
void test_Material_data()
|
||||
{
|
||||
auto result =
|
||||
R"(Material {
|
||||
R"(Material {
|
||||
diffuseColor 1 0 0
|
||||
}
|
||||
)";
|
||||
QTest::addColumn<Base::ColorRGB>("input");
|
||||
QTest::addColumn<QString>("result");
|
||||
QTest::newRow("Material") << Base::ColorRGB{1,0,0} << result;
|
||||
QTest::newRow("Material") << Base::ColorRGB {1, 0, 0} << result;
|
||||
}
|
||||
|
||||
void test_Material()
|
||||
@@ -229,7 +224,7 @@ R"(Material {
|
||||
void test_Materials_data()
|
||||
{
|
||||
auto result =
|
||||
R"(Material {
|
||||
R"(Material {
|
||||
diffuseColor [
|
||||
1 0 0
|
||||
0 1 0
|
||||
@@ -241,7 +236,8 @@ R"(Material {
|
||||
QTest::addColumn<Base::ColorRGB>("input2");
|
||||
QTest::addColumn<Base::ColorRGB>("input3");
|
||||
QTest::addColumn<QString>("result");
|
||||
QTest::newRow("Material") << Base::ColorRGB{1,0,0} << Base::ColorRGB{0,1,0} << Base::ColorRGB{0,0,1} << result;
|
||||
QTest::newRow("Material") << Base::ColorRGB {1, 0, 0} << Base::ColorRGB {0, 1, 0}
|
||||
<< Base::ColorRGB {0, 0, 1} << result;
|
||||
}
|
||||
|
||||
void test_Materials()
|
||||
@@ -266,7 +262,7 @@ R"(Material {
|
||||
void test_DrawStyle_data()
|
||||
{
|
||||
auto result =
|
||||
R"(DrawStyle {
|
||||
R"(DrawStyle {
|
||||
style FILLED
|
||||
pointSize 3
|
||||
lineWidth 3
|
||||
@@ -278,7 +274,8 @@ R"(DrawStyle {
|
||||
QTest::addColumn<ushort>("lineWidth");
|
||||
QTest::addColumn<ushort>("linePattern");
|
||||
QTest::addColumn<QString>("result");
|
||||
QTest::newRow("DrawStyle") << Base::DrawStyle::Style::Filled << ushort(3) << ushort(3) << ushort(0xf0f0) << result;
|
||||
QTest::newRow("DrawStyle")
|
||||
<< Base::DrawStyle::Style::Filled << ushort(3) << ushort(3) << ushort(0xf0f0) << result;
|
||||
}
|
||||
|
||||
void test_DrawStyle()
|
||||
@@ -305,7 +302,7 @@ R"(DrawStyle {
|
||||
void test_ShapeHints_data()
|
||||
{
|
||||
auto result =
|
||||
R"(ShapeHints {
|
||||
R"(ShapeHints {
|
||||
creaseAngle 0.5
|
||||
}
|
||||
)";
|
||||
@@ -319,7 +316,7 @@ R"(ShapeHints {
|
||||
QFETCH(float, input);
|
||||
QFETCH(QString, result);
|
||||
|
||||
Base::ShapeHintsItem item{input};
|
||||
Base::ShapeHintsItem item {input};
|
||||
builder.addNode(item);
|
||||
|
||||
QString string = QString::fromStdString(output.str());
|
||||
@@ -329,7 +326,7 @@ R"(ShapeHints {
|
||||
void test_PolygonOffset_data()
|
||||
{
|
||||
auto result =
|
||||
R"(PolygonOffset {
|
||||
R"(PolygonOffset {
|
||||
factor 2
|
||||
units 1
|
||||
styles FILLED
|
||||
@@ -341,7 +338,8 @@ R"(PolygonOffset {
|
||||
QTest::addColumn<float>("units");
|
||||
QTest::addColumn<bool>("on");
|
||||
QTest::addColumn<QString>("result");
|
||||
QTest::newRow("PolygonOffset") << Base::PolygonOffset::Style::Filled << 2.0F << 1.0F << false << result;
|
||||
QTest::newRow("PolygonOffset")
|
||||
<< Base::PolygonOffset::Style::Filled << 2.0F << 1.0F << false << result;
|
||||
}
|
||||
|
||||
void test_PolygonOffset()
|
||||
@@ -411,7 +409,7 @@ R"(PolygonOffset {
|
||||
{
|
||||
QFETCH(int, num);
|
||||
|
||||
Base::FaceSetItem item{{num}};
|
||||
Base::FaceSetItem item {{num}};
|
||||
builder.addNode(item);
|
||||
|
||||
SoNode* node = loadBuffer(output.str());
|
||||
@@ -432,7 +430,7 @@ R"(PolygonOffset {
|
||||
QFETCH(int, c2);
|
||||
QFETCH(int, c3);
|
||||
|
||||
Base::IndexedLineSetItem item{{c1, c2, c3}};
|
||||
Base::IndexedLineSetItem item {{c1, c2, c3}};
|
||||
builder.addNode(item);
|
||||
|
||||
SoNode* node = loadBuffer(output.str());
|
||||
@@ -455,7 +453,7 @@ R"(PolygonOffset {
|
||||
QFETCH(int, c3);
|
||||
QFETCH(int, c4);
|
||||
|
||||
Base::IndexedFaceSetItem item{{c1, c2, c3, c4}};
|
||||
Base::IndexedFaceSetItem item {{c1, c2, c3, c4}};
|
||||
builder.addNode(item);
|
||||
|
||||
SoNode* node = loadBuffer(output.str());
|
||||
@@ -465,7 +463,7 @@ R"(PolygonOffset {
|
||||
void test_Transform()
|
||||
{
|
||||
Base::Placement plm;
|
||||
Base::TransformItem item{plm};
|
||||
Base::TransformItem item {plm};
|
||||
builder.addNode(item);
|
||||
|
||||
SoNode* node = loadBuffer(output.str());
|
||||
@@ -475,13 +473,13 @@ R"(PolygonOffset {
|
||||
void test_Normal_data()
|
||||
{
|
||||
auto result =
|
||||
R"(Normal {
|
||||
R"(Normal {
|
||||
vector 1 0 0.5
|
||||
}
|
||||
)";
|
||||
QTest::addColumn<Base::Vector3f>("input");
|
||||
QTest::addColumn<QString>("result");
|
||||
QTest::newRow("Normal") << Base::Vector3f{1,0,0.5} << result;
|
||||
QTest::newRow("Normal") << Base::Vector3f {1, 0, 0.5} << result;
|
||||
}
|
||||
|
||||
void test_Normal()
|
||||
@@ -489,7 +487,7 @@ R"(Normal {
|
||||
QFETCH(Base::Vector3f, input);
|
||||
QFETCH(QString, result);
|
||||
|
||||
builder.addNode(Base::NormalItem{{input}});
|
||||
builder.addNode(Base::NormalItem {{input}});
|
||||
|
||||
QString string = QString::fromStdString(output.str());
|
||||
QCOMPARE(string, result);
|
||||
@@ -499,14 +497,14 @@ R"(Normal {
|
||||
{
|
||||
QTest::addColumn<Base::Line3f>("line");
|
||||
QTest::addColumn<Base::DrawStyle>("style");
|
||||
QTest::newRow("LineItem") << Base::Line3f{} << Base::DrawStyle{};
|
||||
QTest::newRow("LineItem") << Base::Line3f {} << Base::DrawStyle {};
|
||||
}
|
||||
|
||||
void test_LineItem()
|
||||
{
|
||||
QFETCH(Base::Line3f, line);
|
||||
QFETCH(Base::DrawStyle, style);
|
||||
Base::LineItem item{line, style};
|
||||
Base::LineItem item {line, style};
|
||||
builder.addNode(item);
|
||||
|
||||
SoNode* node = loadBuffer(output.str());
|
||||
@@ -519,7 +517,8 @@ R"(Normal {
|
||||
QTest::addColumn<Base::Vector3f>("p2");
|
||||
QTest::addColumn<Base::Vector3f>("p3");
|
||||
QTest::addColumn<Base::DrawStyle>("style");
|
||||
QTest::newRow("MultiLineItem") << Base::Vector3f{0,0,0} << Base::Vector3f{1,0,0} << Base::Vector3f{1,1,0} << Base::DrawStyle{};
|
||||
QTest::newRow("MultiLineItem") << Base::Vector3f {0, 0, 0} << Base::Vector3f {1, 0, 0}
|
||||
<< Base::Vector3f {1, 1, 0} << Base::DrawStyle {};
|
||||
}
|
||||
|
||||
void test_MultiLineItem()
|
||||
@@ -528,7 +527,7 @@ R"(Normal {
|
||||
QFETCH(Base::Vector3f, p2);
|
||||
QFETCH(Base::Vector3f, p3);
|
||||
QFETCH(Base::DrawStyle, style);
|
||||
Base::MultiLineItem item{{p1, p2, p3}, style};
|
||||
Base::MultiLineItem item {{p1, p2, p3}, style};
|
||||
builder.addNode(item);
|
||||
|
||||
SoNode* node = loadBuffer(output.str());
|
||||
@@ -539,14 +538,15 @@ R"(Normal {
|
||||
{
|
||||
QTest::addColumn<Base::Line3f>("line");
|
||||
QTest::addColumn<Base::DrawStyle>("style");
|
||||
QTest::newRow("Arrow") << Base::Line3f{Base::Vector3f{0,0,10}, Base::Vector3f{}} << Base::DrawStyle{};
|
||||
QTest::newRow("Arrow") << Base::Line3f {Base::Vector3f {0, 0, 10}, Base::Vector3f {}}
|
||||
<< Base::DrawStyle {};
|
||||
}
|
||||
|
||||
void test_ArrowItem()
|
||||
{
|
||||
QFETCH(Base::Line3f, line);
|
||||
QFETCH(Base::DrawStyle, style);
|
||||
Base::ArrowItem item{line, style};
|
||||
Base::ArrowItem item {line, style};
|
||||
builder.addNode(item);
|
||||
|
||||
SoNode* node = loadBuffer(output.str());
|
||||
@@ -558,7 +558,8 @@ R"(Normal {
|
||||
QTest::addColumn<Base::Vector3f>("p1");
|
||||
QTest::addColumn<Base::Vector3f>("p2");
|
||||
QTest::addColumn<Base::DrawStyle>("style");
|
||||
QTest::newRow("BoundingBoxItem") << Base::Vector3f{0,0,0} << Base::Vector3f{1,1,1} << Base::DrawStyle{};
|
||||
QTest::newRow("BoundingBoxItem")
|
||||
<< Base::Vector3f {0, 0, 0} << Base::Vector3f {1, 1, 1} << Base::DrawStyle {};
|
||||
}
|
||||
|
||||
void test_BoundingBoxItem()
|
||||
@@ -566,7 +567,7 @@ R"(Normal {
|
||||
QFETCH(Base::Vector3f, p1);
|
||||
QFETCH(Base::Vector3f, p2);
|
||||
QFETCH(Base::DrawStyle, style);
|
||||
Base::BoundingBoxItem item{p1, p2, style};
|
||||
Base::BoundingBoxItem item {p1, p2, style};
|
||||
builder.addNode(item);
|
||||
|
||||
SoNode* node = loadBuffer(output.str());
|
||||
@@ -578,7 +579,8 @@ R"(Normal {
|
||||
QTest::addColumn<Base::Vector3f>("p1");
|
||||
QTest::addColumn<Base::Vector3f>("p2");
|
||||
QTest::addColumn<Base::Vector3f>("p3");
|
||||
QTest::newRow("Coordinate3Item") << Base::Vector3f{0,0,0} << Base::Vector3f{1,0,0} << Base::Vector3f{1,1,0};
|
||||
QTest::newRow("Coordinate3Item")
|
||||
<< Base::Vector3f {0, 0, 0} << Base::Vector3f {1, 0, 0} << Base::Vector3f {1, 1, 0};
|
||||
}
|
||||
|
||||
void test_Coordinate3Item()
|
||||
@@ -586,7 +588,7 @@ R"(Normal {
|
||||
QFETCH(Base::Vector3f, p1);
|
||||
QFETCH(Base::Vector3f, p2);
|
||||
QFETCH(Base::Vector3f, p3);
|
||||
Base::Coordinate3Item item{{p1, p2, p3}};
|
||||
Base::Coordinate3Item item {{p1, p2, p3}};
|
||||
builder.addNode(item);
|
||||
|
||||
SoNode* node = loadBuffer(output.str());
|
||||
@@ -597,14 +599,14 @@ R"(Normal {
|
||||
{
|
||||
QTest::addColumn<Base::Vector3f>("point");
|
||||
QTest::addColumn<Base::DrawStyle>("style");
|
||||
QTest::newRow("PointItem") << Base::Vector3f{} << Base::DrawStyle{};
|
||||
QTest::newRow("PointItem") << Base::Vector3f {} << Base::DrawStyle {};
|
||||
}
|
||||
|
||||
void test_PointItem()
|
||||
{
|
||||
QFETCH(Base::Vector3f, point);
|
||||
QFETCH(Base::DrawStyle, style);
|
||||
Base::PointItem item{point, style};
|
||||
Base::PointItem item {point, style};
|
||||
builder.addNode(item);
|
||||
|
||||
SoNode* node = loadBuffer(output.str());
|
||||
@@ -615,24 +617,24 @@ R"(Normal {
|
||||
{
|
||||
QTest::addColumn<Base::BindingElement::Binding>("input");
|
||||
QTest::addColumn<QString>("result");
|
||||
QTest::newRow("NormalBinding") << Base::BindingElement::Binding::Overall
|
||||
<< "NormalBinding { value OVERALL }\n";
|
||||
QTest::newRow("NormalBinding") << Base::BindingElement::Binding::PerPart
|
||||
<< "NormalBinding { value PER_PART }\n";
|
||||
QTest::newRow("NormalBinding")
|
||||
<< Base::BindingElement::Binding::Overall << "NormalBinding { value OVERALL }\n";
|
||||
QTest::newRow("NormalBinding")
|
||||
<< Base::BindingElement::Binding::PerPart << "NormalBinding { value PER_PART }\n";
|
||||
QTest::newRow("NormalBinding") << Base::BindingElement::Binding::PerPartIndexed
|
||||
<< "NormalBinding { value PER_PART_INDEXED }\n";
|
||||
QTest::newRow("NormalBinding") << Base::BindingElement::Binding::PerFace
|
||||
<< "NormalBinding { value PER_FACE }\n";
|
||||
QTest::newRow("NormalBinding")
|
||||
<< Base::BindingElement::Binding::PerFace << "NormalBinding { value PER_FACE }\n";
|
||||
QTest::newRow("NormalBinding") << Base::BindingElement::Binding::PerFaceIndexed
|
||||
<< "NormalBinding { value PER_FACE_INDEXED }\n";
|
||||
QTest::newRow("NormalBinding") << Base::BindingElement::Binding::PerVertex
|
||||
<< "NormalBinding { value PER_VERTEX }\n";
|
||||
QTest::newRow("NormalBinding")
|
||||
<< Base::BindingElement::Binding::PerVertex << "NormalBinding { value PER_VERTEX }\n";
|
||||
QTest::newRow("NormalBinding") << Base::BindingElement::Binding::PerVertexIndexed
|
||||
<< "NormalBinding { value PER_VERTEX_INDEXED }\n";
|
||||
QTest::newRow("NormalBinding") << Base::BindingElement::Binding::Default
|
||||
<< "NormalBinding { value OVERALL }\n";
|
||||
QTest::newRow("NormalBinding") << Base::BindingElement::Binding::None
|
||||
<< "NormalBinding { value OVERALL }\n";
|
||||
QTest::newRow("NormalBinding")
|
||||
<< Base::BindingElement::Binding::Default << "NormalBinding { value OVERALL }\n";
|
||||
QTest::newRow("NormalBinding")
|
||||
<< Base::BindingElement::Binding::None << "NormalBinding { value OVERALL }\n";
|
||||
}
|
||||
|
||||
void test_NormalBinding()
|
||||
@@ -651,7 +653,7 @@ R"(Normal {
|
||||
void test_Cylinder_data()
|
||||
{
|
||||
auto result =
|
||||
R"(Cylinder {
|
||||
R"(Cylinder {
|
||||
radius 3
|
||||
height 7
|
||||
parts (SIDES | TOP | BOTTOM)
|
||||
|
||||
@@ -12,7 +12,7 @@ TEST(Collection, TestValidity)
|
||||
EXPECT_EQ(cc.getEntry("inexistant", zipios::FileCollection::MatchPath::IGNORE), nullptr);
|
||||
EXPECT_EQ(cc.getInputStream("inexistant", zipios::FileCollection::MatchPath::MATCH), nullptr);
|
||||
EXPECT_EQ(cc.getInputStream("inexistant", zipios::FileCollection::MatchPath::IGNORE), nullptr);
|
||||
EXPECT_EQ(cc.getName(), "-"); // default name is "-"
|
||||
EXPECT_EQ(cc.getName(), "-");// default name is "-"
|
||||
EXPECT_EQ(cc.size(), 0);
|
||||
cc.close();
|
||||
EXPECT_EQ(cc.isValid(), false);
|
||||
@@ -27,8 +27,9 @@ TEST(Collection, TestCopy)
|
||||
EXPECT_EQ(copy.getEntry("inexistant", zipios::FileCollection::MatchPath::MATCH), nullptr);
|
||||
EXPECT_EQ(copy.getEntry("inexistant", zipios::FileCollection::MatchPath::IGNORE), nullptr);
|
||||
EXPECT_EQ(copy.getInputStream("inexistant", zipios::FileCollection::MatchPath::MATCH), nullptr);
|
||||
EXPECT_EQ(copy.getInputStream("inexistant", zipios::FileCollection::MatchPath::IGNORE), nullptr);
|
||||
EXPECT_EQ(copy.getName(), "-"); // default name is "-"
|
||||
EXPECT_EQ(copy.getInputStream("inexistant", zipios::FileCollection::MatchPath::IGNORE),
|
||||
nullptr);
|
||||
EXPECT_EQ(copy.getName(), "-");// default name is "-"
|
||||
EXPECT_EQ(copy.size(), 0);
|
||||
}
|
||||
|
||||
@@ -42,8 +43,9 @@ TEST(Collection, TestCopyAssign)
|
||||
EXPECT_EQ(copy.getEntry("inexistant", zipios::FileCollection::MatchPath::MATCH), nullptr);
|
||||
EXPECT_EQ(copy.getEntry("inexistant", zipios::FileCollection::MatchPath::IGNORE), nullptr);
|
||||
EXPECT_EQ(copy.getInputStream("inexistant", zipios::FileCollection::MatchPath::MATCH), nullptr);
|
||||
EXPECT_EQ(copy.getInputStream("inexistant", zipios::FileCollection::MatchPath::IGNORE), nullptr);
|
||||
EXPECT_EQ(copy.getName(), "-"); // default name is "-"
|
||||
EXPECT_EQ(copy.getInputStream("inexistant", zipios::FileCollection::MatchPath::IGNORE),
|
||||
nullptr);
|
||||
EXPECT_EQ(copy.getName(), "-");// default name is "-"
|
||||
EXPECT_EQ(copy.size(), 0);
|
||||
}
|
||||
|
||||
@@ -55,9 +57,11 @@ TEST(Collection, TestClone)
|
||||
EXPECT_EQ(pointer->entries().empty(), true);
|
||||
EXPECT_EQ(pointer->getEntry("inexistant", zipios::FileCollection::MatchPath::MATCH), nullptr);
|
||||
EXPECT_EQ(pointer->getEntry("inexistant", zipios::FileCollection::MatchPath::IGNORE), nullptr);
|
||||
EXPECT_EQ(pointer->getInputStream("inexistant", zipios::FileCollection::MatchPath::MATCH), nullptr);
|
||||
EXPECT_EQ(pointer->getInputStream("inexistant", zipios::FileCollection::MatchPath::IGNORE), nullptr);
|
||||
EXPECT_EQ(pointer->getName(), "-"); // default name is "-"
|
||||
EXPECT_EQ(pointer->getInputStream("inexistant", zipios::FileCollection::MatchPath::MATCH),
|
||||
nullptr);
|
||||
EXPECT_EQ(pointer->getInputStream("inexistant", zipios::FileCollection::MatchPath::IGNORE),
|
||||
nullptr);
|
||||
EXPECT_EQ(pointer->getName(), "-");// default name is "-"
|
||||
EXPECT_EQ(pointer->size(), 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "gtest/gtest.h"
|
||||
#include <memory>
|
||||
#include <cstdio>
|
||||
#include <memory>
|
||||
#include <zipios++/zipfile.h>
|
||||
|
||||
// NOLINTBEGIN(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)
|
||||
@@ -9,10 +9,14 @@ TEST(ZipFile, TestValidity)
|
||||
zipios::ZipFile zf;
|
||||
EXPECT_EQ(zf.isValid(), false);
|
||||
EXPECT_THROW(zf.entries(), zipios::InvalidStateException);
|
||||
EXPECT_THROW(zf.getEntry("inexistant", zipios::FileCollection::MatchPath::MATCH), zipios::InvalidStateException);
|
||||
EXPECT_THROW(zf.getEntry("inexistant", zipios::FileCollection::MatchPath::IGNORE), zipios::InvalidStateException);
|
||||
EXPECT_THROW(zf.getInputStream("inexistant", zipios::FileCollection::MatchPath::MATCH), zipios::InvalidStateException);
|
||||
EXPECT_THROW(zf.getInputStream("inexistant", zipios::FileCollection::MatchPath::IGNORE), zipios::InvalidStateException);
|
||||
EXPECT_THROW(zf.getEntry("inexistant", zipios::FileCollection::MatchPath::MATCH),
|
||||
zipios::InvalidStateException);
|
||||
EXPECT_THROW(zf.getEntry("inexistant", zipios::FileCollection::MatchPath::IGNORE),
|
||||
zipios::InvalidStateException);
|
||||
EXPECT_THROW(zf.getInputStream("inexistant", zipios::FileCollection::MatchPath::MATCH),
|
||||
zipios::InvalidStateException);
|
||||
EXPECT_THROW(zf.getInputStream("inexistant", zipios::FileCollection::MatchPath::IGNORE),
|
||||
zipios::InvalidStateException);
|
||||
EXPECT_THROW(zf.getName(), zipios::InvalidStateException);
|
||||
EXPECT_THROW(zf.size(), zipios::InvalidStateException);
|
||||
zf.close();
|
||||
@@ -25,9 +29,11 @@ TEST(ZipFile, TestNonExisting)
|
||||
EXPECT_EQ(zf.isValid(), false);
|
||||
}
|
||||
|
||||
class ZipFileTest : public ::testing::Test {
|
||||
class ZipFileTest: public ::testing::Test
|
||||
{
|
||||
protected:
|
||||
void SetUp() override {
|
||||
void SetUp() override
|
||||
{
|
||||
std::ofstream os("empty.zip", std::ios::out | std::ios::binary);
|
||||
os << static_cast<char>(0x50);
|
||||
os << static_cast<char>(0x4B);
|
||||
@@ -52,7 +58,8 @@ protected:
|
||||
os << static_cast<char>(0x00);
|
||||
os << static_cast<char>(0x00);
|
||||
}
|
||||
void TearDown() override {
|
||||
void TearDown() override
|
||||
{
|
||||
// delete empty.zip
|
||||
std::remove("empty.zip");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user