| | |
| |
|
| | #include <gtest/gtest.h> |
| | #include "src/App/InitApplication.h" |
| |
|
| | #include <memory> |
| |
|
| | #include <Mod/Spreadsheet/App/Sheet.h> |
| | #include <Mod/Spreadsheet/App/PropertySheet.h> |
| |
|
| | class PropertySheetTest: public ::testing::Test |
| | { |
| | protected: |
| | static void SetUpTestSuite() |
| | { |
| | tests::initApplication(); |
| | } |
| | void SetUp() override |
| | { |
| | _sheet = std::make_unique<Spreadsheet::Sheet>(); |
| | _propertySheet = std::make_unique<Spreadsheet::PropertySheet>(_sheet.get()); |
| | } |
| | void TearDown() override |
| | { |
| | _sheet.reset(); |
| | _propertySheet.reset(); |
| | } |
| |
|
| | |
| | Spreadsheet::PropertySheet* propertySheet() |
| | { |
| | return _propertySheet.get(); |
| | } |
| |
|
| | private: |
| | std::unique_ptr<Spreadsheet::Sheet> _sheet; |
| | std::unique_ptr<Spreadsheet::PropertySheet> _propertySheet; |
| | }; |
| |
|
| | TEST_F(PropertySheetTest, isValidCellAddressNameValidNames) |
| | { |
| | std::vector<std::string> validAddressNames {"A1", "Z1024", "AA42", "ZZ4096"}; |
| | for (const auto& name : validAddressNames) { |
| | EXPECT_TRUE(propertySheet()->isValidCellAddressName(name)) |
| | << "\"" << name << "\" was not accepted as a cell name, and should be"; |
| | } |
| | } |
| |
|
| | TEST_F(PropertySheetTest, isValidCellAddressNameInvalidNames) |
| | { |
| | std::vector<std::string> invalidAddressNames { |
| | "Bork", |
| | "Bork_de_bork", |
| | "A", |
| | "42", |
| | "AAA1", |
| | "ZZ123456" |
| | }; |
| | for (const auto& name : invalidAddressNames) { |
| | EXPECT_FALSE(propertySheet()->isValidCellAddressName(name)) |
| | << "\"" << name << "\" was accepted as a cell name, and should not be"; |
| | } |
| | } |
| |
|
| | TEST_F(PropertySheetTest, validAliases) |
| | { |
| | std::vector<std::string> validAliases { |
| | "Bork", |
| | "Bork_de_bork" |
| | "A", |
| | "AA123456" |
| | }; |
| | for (const auto& name : validAliases) { |
| | EXPECT_TRUE(propertySheet()->isValidAlias(name)) |
| | << "\"" << name << "\" was not accepted as an alias name, and should be"; |
| | } |
| | } |
| |
|
| | TEST_F(PropertySheetTest, invalidAliases) |
| | { |
| | std::vector<std::string> |
| | invalidAliases {"A1", "ZZ1234", "mm", "no spaces allowed", "\'NoLeadingQuotes"}; |
| |
|
| | for (const auto& name : invalidAliases) { |
| | EXPECT_FALSE(propertySheet()->isValidAlias(name)) |
| | << "\"" << name << "\" was accepted as an alias name, and should not be"; |
| | } |
| | } |
| |
|