From e186920ad2a52e5ec67ef45650436dfc395e5d6a Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Mon, 25 Nov 2024 23:29:21 -0600 Subject: [PATCH] Spreadsheet: Add tests for validAddressName and validAliases --- .../src/Mod/Spreadsheet/App/PropertySheet.cpp | 45 ++++++++++++++++++- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/tests/src/Mod/Spreadsheet/App/PropertySheet.cpp b/tests/src/Mod/Spreadsheet/App/PropertySheet.cpp index 24a2c77b49..4e63b35d03 100644 --- a/tests/src/Mod/Spreadsheet/App/PropertySheet.cpp +++ b/tests/src/Mod/Spreadsheet/App/PropertySheet.cpp @@ -37,7 +37,48 @@ private: std::unique_ptr _propertySheet; }; -TEST_F(PropertySheetTest, isValidCellAddressName) // NOLINT +TEST_F(PropertySheetTest, isValidCellAddressNameValidNames) // NOLINT { - // Test some things + std::vector 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) // NOLINT +{ + std::vector invalidAddressNames { + "Bork", + "Bork_de_bork", + "A", + "42", + "AAA1", // Too many characters to start, AAA is not a valid column + "ZZ123456" // Too large a number to end, 123456 is not a valid row + }; + 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) // NOLINT +{ + std::vector 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) // NOLINT +{ + std::vector invalidAliases {"A1", "ZZ1234", "mm"}; + for (const auto& name : invalidAliases) { + EXPECT_FALSE(propertySheet()->isValidAlias(name)) + << "\"" << name << "\" was accepted as an alias name, and should not be"; + } }