From 45e92e914696a69b9c4aee22685796a2fe004712 Mon Sep 17 00:00:00 2001 From: Ventsy Velev Date: Thu, 16 Nov 2023 09:48:06 -0500 Subject: [PATCH 1/9] Renaming default symbol constantns --- src/Expander.cpp | 12 ++++++------ src/Expander.h | 11 +++++------ test/TestExpander.cpp | 8 ++++---- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/Expander.cpp b/src/Expander.cpp index 572f783..2f0bf99 100755 --- a/src/Expander.cpp +++ b/src/Expander.cpp @@ -105,11 +105,11 @@ void Expander::generate(const wstring &pattern) load--; continue; } - else if (expandedPattern[i] == DOUBLE_QUOTE && !escSeqReached) + else if (expandedPattern[i] == DEFAULT_QUOTE_SYM && !escSeqReached) { //Just skip everything thats in quotes uint startIndex = ++i; - while (expandedPattern[i] != DOUBLE_QUOTE && i < pLength) + while (expandedPattern[i] != DEFAULT_QUOTE_SYM && i < pLength) { i++; } @@ -237,7 +237,7 @@ inline bool Expander::isEscSeq(const std::wstring &pattern, uint position, bool } - if (second == escapeSymbol || second == groupBegin || second == groupEnd || second == DOUBLE_QUOTE) + if (second == escapeSymbol || second == groupBegin || second == groupEnd || second == DEFAULT_QUOTE_SYM) { result = true; } @@ -263,11 +263,11 @@ std::wstring Expander::expand(const std::wstring &pattern) i++; continue; } - else if (pattern[i] == DOUBLE_QUOTE) + else if (pattern[i] == DEFAULT_QUOTE_SYM) { //Just skip everything thats in quotes i++; - while (pattern[i] != DOUBLE_QUOTE && i < size) + while (pattern[i] != DEFAULT_QUOTE_SYM && i < size) { i++; } @@ -347,7 +347,7 @@ bool Expander::validate(const wstring &pattern) loadBrackets++; else if (pattern[i] == groupEnd) loadBrackets--; - else if (pattern[i] == DOUBLE_QUOTE) + else if (pattern[i] == DEFAULT_QUOTE_SYM) loadQuotes++; if (loadBrackets < 0) diff --git a/src/Expander.h b/src/Expander.h index 22fa147..060c860 100755 --- a/src/Expander.h +++ b/src/Expander.h @@ -13,10 +13,9 @@ namespace PatternExpander const wchar_t DEFAULT_ESC_SYM = '/'; const wchar_t DEFAULT_RANGE_SYM = '-'; -const wchar_t GROUP_SYM_BEGIN = '['; -const wchar_t GROUP_SYM_END = ']'; -const wchar_t SINGLE_QUOTE = '\''; -const wchar_t DOUBLE_QUOTE = '"'; +const wchar_t DEFAULT_GROUP_BEGIN_SYM = '['; +const wchar_t DEFAULT_GROUP_END_SYM = ']'; +const wchar_t DEFAULT_QUOTE_SYM = '"'; class Expander { @@ -25,8 +24,8 @@ class Expander ///Consructor explicit Expander(wchar_t esc = PatternExpander::DEFAULT_ESC_SYM, wchar_t range = PatternExpander::DEFAULT_RANGE_SYM, - wchar_t grpBegin = PatternExpander::GROUP_SYM_BEGIN, - wchar_t grpEnd = PatternExpander::GROUP_SYM_END); + wchar_t grpBegin = PatternExpander::DEFAULT_GROUP_BEGIN_SYM, + wchar_t grpEnd = PatternExpander::DEFAULT_GROUP_END_SYM); ///The main function - it expands the pattern and generates are possible combinations void generate(const std::wstring &pattern); diff --git a/test/TestExpander.cpp b/test/TestExpander.cpp index 5ee039e..30322a1 100644 --- a/test/TestExpander.cpp +++ b/test/TestExpander.cpp @@ -32,10 +32,10 @@ TEST_F(TestExpander, testGetters) EXPECT_EQ(PatternExpander::DEFAULT_RANGE_SYM, result); result = underTest.getGroupBegin(); - EXPECT_EQ(PatternExpander::GROUP_SYM_BEGIN, result); + EXPECT_EQ(PatternExpander::DEFAULT_GROUP_BEGIN_SYM, result); result = underTest.getGroupEnd(); - EXPECT_EQ(PatternExpander::GROUP_SYM_END, result); + EXPECT_EQ(PatternExpander::DEFAULT_GROUP_END_SYM, result); } TEST_F(TestExpander, testSetters) @@ -800,8 +800,8 @@ TEST_F(TestExpander, testLoadConfig) underTest.loadConfig("./nofile.txt"); EXPECT_EQ(underTest.getEscChar(), PatternExpander::DEFAULT_ESC_SYM); - EXPECT_EQ(underTest.getGroupBegin(), PatternExpander::GROUP_SYM_BEGIN); - EXPECT_EQ(underTest.getGroupEnd(), PatternExpander::GROUP_SYM_END); + EXPECT_EQ(underTest.getGroupBegin(), PatternExpander::DEFAULT_GROUP_BEGIN_SYM); + EXPECT_EQ(underTest.getGroupEnd(), PatternExpander::DEFAULT_GROUP_END_SYM); EXPECT_EQ(underTest.getRangeChar(), PatternExpander::DEFAULT_RANGE_SYM); altExpander.loadConfig("./nofile.txt"); From 83230b0fc6366db604f8e60419724745b60f545b Mon Sep 17 00:00:00 2001 From: Ventsy Velev Date: Thu, 16 Nov 2023 09:51:14 -0500 Subject: [PATCH 2/9] Adding quote member variable --- src/Expander.cpp | 4 ++-- src/Expander.h | 14 +++++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/Expander.cpp b/src/Expander.cpp index 2f0bf99..4c84649 100755 --- a/src/Expander.cpp +++ b/src/Expander.cpp @@ -8,9 +8,9 @@ using namespace std; using namespace PatternExpander; -Expander::Expander(wchar_t esc, wchar_t range, wchar_t grpBegin, wchar_t grpEnd) : +Expander::Expander(wchar_t esc, wchar_t range, wchar_t grpBegin, wchar_t grpEnd, wchar_t quote) : escapeSymbol(esc), rangeSymbol(range), groupBegin(grpBegin), groupEnd( - grpEnd) + grpEnd), quote(quote) { loadConfig(); } diff --git a/src/Expander.h b/src/Expander.h index 060c860..746f3ad 100755 --- a/src/Expander.h +++ b/src/Expander.h @@ -25,7 +25,8 @@ class Expander explicit Expander(wchar_t esc = PatternExpander::DEFAULT_ESC_SYM, wchar_t range = PatternExpander::DEFAULT_RANGE_SYM, wchar_t grpBegin = PatternExpander::DEFAULT_GROUP_BEGIN_SYM, - wchar_t grpEnd = PatternExpander::DEFAULT_GROUP_END_SYM); + wchar_t grpEnd = PatternExpander::DEFAULT_GROUP_END_SYM, + wchar_t quote = PatternExpander::DEFAULT_QUOTE_SYM); ///The main function - it expands the pattern and generates are possible combinations void generate(const std::wstring &pattern); @@ -80,6 +81,15 @@ class Expander groupEnd = in; } + wchar_t getQuote() const + { + return quote; + } + void setQuote(wchar_t in) + { + quote = in; + } + std::vector getData(); std::wstringstream output; @@ -96,6 +106,8 @@ class Expander wchar_t groupBegin; wchar_t groupEnd; + wchar_t quote; + ///the main data storage std::vector data; From fd5af74de68bd80fafdb284b4a89c8de03e67277 Mon Sep 17 00:00:00 2001 From: Ventsy Velev Date: Thu, 16 Nov 2023 09:54:08 -0500 Subject: [PATCH 3/9] Replaces DEFAULT_QUOTE_SYM with member variable so that the quote symbol can be configured --- src/Expander.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Expander.cpp b/src/Expander.cpp index 4c84649..107b88a 100755 --- a/src/Expander.cpp +++ b/src/Expander.cpp @@ -105,11 +105,11 @@ void Expander::generate(const wstring &pattern) load--; continue; } - else if (expandedPattern[i] == DEFAULT_QUOTE_SYM && !escSeqReached) + else if (expandedPattern[i] == quote && !escSeqReached) { //Just skip everything thats in quotes uint startIndex = ++i; - while (expandedPattern[i] != DEFAULT_QUOTE_SYM && i < pLength) + while (expandedPattern[i] != quote && i < pLength) { i++; } @@ -237,7 +237,7 @@ inline bool Expander::isEscSeq(const std::wstring &pattern, uint position, bool } - if (second == escapeSymbol || second == groupBegin || second == groupEnd || second == DEFAULT_QUOTE_SYM) + if (second == escapeSymbol || second == groupBegin || second == groupEnd || second == quote) { result = true; } @@ -263,11 +263,11 @@ std::wstring Expander::expand(const std::wstring &pattern) i++; continue; } - else if (pattern[i] == DEFAULT_QUOTE_SYM) + else if (pattern[i] == quote) { //Just skip everything thats in quotes i++; - while (pattern[i] != DEFAULT_QUOTE_SYM && i < size) + while (pattern[i] != quote && i < size) { i++; } @@ -347,7 +347,7 @@ bool Expander::validate(const wstring &pattern) loadBrackets++; else if (pattern[i] == groupEnd) loadBrackets--; - else if (pattern[i] == DEFAULT_QUOTE_SYM) + else if (pattern[i] == quote) loadQuotes++; if (loadBrackets < 0) From f6c98e455ad7d83c252e62d0dcdbc86a9e4c743c Mon Sep 17 00:00:00 2001 From: Ventsy Velev Date: Thu, 16 Nov 2023 10:04:48 -0500 Subject: [PATCH 4/9] Adds getter and setter tests for the quote symbol --- test/TestExpander.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/TestExpander.cpp b/test/TestExpander.cpp index 30322a1..e8b4ca2 100644 --- a/test/TestExpander.cpp +++ b/test/TestExpander.cpp @@ -20,6 +20,7 @@ class TestExpander: public ::testing::Test altExpander.setGroupBegin('{'); altExpander.setGroupEnd('}'); altExpander.setRangeChar('>'); + altExpander.setQuote('^'); } }; @@ -36,6 +37,9 @@ TEST_F(TestExpander, testGetters) result = underTest.getGroupEnd(); EXPECT_EQ(PatternExpander::DEFAULT_GROUP_END_SYM, result); + + result = underTest.getQuote(); + EXPECT_EQ(PatternExpander::DEFAULT_QUOTE_SYM, result); } TEST_F(TestExpander, testSetters) @@ -60,6 +64,11 @@ TEST_F(TestExpander, testSetters) result = underTest.getGroupEnd(); EXPECT_EQ(input, result); + input = '^'; + underTest.setQuote(input); + result = underTest.getQuote(); + EXPECT_EQ(input, result); + } TEST_F(TestExpander, testValidation_valid) { From 2315607fe3ed1926dd9cd6f292ce1200aa300e46 Mon Sep 17 00:00:00 2001 From: Ventsy Velev Date: Thu, 16 Nov 2023 10:08:31 -0500 Subject: [PATCH 5/9] Adds the quote symbol to save & load config functions and unit tests --- src/Expander.cpp | 5 +++++ test/TestExpander.cpp | 3 +++ test_data/altConfig.txt | 1 + 3 files changed, 9 insertions(+) diff --git a/src/Expander.cpp b/src/Expander.cpp index 107b88a..27e34c4 100755 --- a/src/Expander.cpp +++ b/src/Expander.cpp @@ -491,6 +491,10 @@ void Expander::loadConfig(const std::string& filePath) { setGroupEnd(val[0]); } + else if (key == L"quote") + { + setQuote(val[0]); + } } } @@ -504,5 +508,6 @@ void Expander::saveConfig(const std::string& filePath) out << L"group.begin " << getGroupBegin() << endl; out << L"group.end " << getGroupEnd() << endl; + out << L"quote " << getQuote() << endl; } diff --git a/test/TestExpander.cpp b/test/TestExpander.cpp index e8b4ca2..4a5cf55 100644 --- a/test/TestExpander.cpp +++ b/test/TestExpander.cpp @@ -818,6 +818,7 @@ TEST_F(TestExpander, testLoadConfig) EXPECT_EQ(altExpander.getGroupBegin(), L'{'); EXPECT_EQ(altExpander.getGroupEnd(), L'}'); EXPECT_EQ(altExpander.getRangeChar(), L'>'); + EXPECT_EQ(altExpander.getQuote(), L'^'); } @@ -830,6 +831,7 @@ TEST_F(TestExpander, testLoadConfig_altSettings) EXPECT_EQ(underTest.getGroupBegin(), L'{'); EXPECT_EQ(underTest.getGroupEnd(), L'}'); EXPECT_EQ(underTest.getRangeChar(), L'>'); + EXPECT_EQ(underTest.getQuote(), L'^'); } @@ -845,6 +847,7 @@ TEST_F(TestExpander, testSaveConfig) EXPECT_EQ(underTest.getGroupBegin(), L'{'); EXPECT_EQ(underTest.getGroupEnd(), L'}'); EXPECT_EQ(underTest.getRangeChar(), L'>'); + EXPECT_EQ(underTest.getQuote(), L'^'); } diff --git a/test_data/altConfig.txt b/test_data/altConfig.txt index 0ff02c7..3dc651e 100644 --- a/test_data/altConfig.txt +++ b/test_data/altConfig.txt @@ -2,3 +2,4 @@ range > escape # group.begin { group.end } +quote ^ From 7866d27a3917724565bd2ef8a0350b54f5e709b9 Mon Sep 17 00:00:00 2001 From: Ventsy Velev Date: Thu, 16 Nov 2023 12:00:40 -0500 Subject: [PATCH 6/9] Replacing hardcoded quote symbols in Expander --- src/Expander.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Expander.cpp b/src/Expander.cpp index 27e34c4..5bae237 100755 --- a/src/Expander.cpp +++ b/src/Expander.cpp @@ -166,13 +166,13 @@ uint Expander::getBlockElements(const wstring &pattern, uint &start, if (isEscSeq(pattern, currentIndx, true)) itemCount--; //Starting a constant block - multiple character are counted as one item - else if (pattern[currentIndx] == '"') + else if (pattern[currentIndx] == quote) { currentIndx++; //move inside the quote while (currentIndx <= start) { itemCount--; - if (pattern[currentIndx] == '"') + if (pattern[currentIndx] == quote) break; currentIndx++; } @@ -187,12 +187,12 @@ uint Expander::getBlockElements(const wstring &pattern, uint &start, for (currentIndx = endIndx + 1; currentIndx <= start; currentIndx++) //now we move left to right { - if (pattern[currentIndx] == '"') + if (pattern[currentIndx] == quote) { uint strt = ++currentIndx; //move inside the quote while (currentIndx < start) { - if (pattern[currentIndx] == '"') + if (pattern[currentIndx] == quote) break; currentIndx++; } From 8265bd6c317db2590fea2c78c32d9fb788f6c6ae Mon Sep 17 00:00:00 2001 From: Ventsy Velev Date: Thu, 16 Nov 2023 12:11:13 -0500 Subject: [PATCH 7/9] Adding unit tests for alternative quote symbol --- test/TestExpander.cpp | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/test/TestExpander.cpp b/test/TestExpander.cpp index 4a5cf55..b700365 100644 --- a/test/TestExpander.cpp +++ b/test/TestExpander.cpp @@ -721,7 +721,7 @@ TEST_F(TestExpander, testGenerate_Static_Range_End) TEST_F(TestExpander, testGenerate_QuotedString_InGroup) { - wstring pattern = L"a[b\"123\"c]\""; + wstring pattern = L"a[b\"123\"c]"; underTest.generate(pattern); auto data = underTest.getData(); EXPECT_EQ(data.size(), 3); @@ -730,6 +730,18 @@ TEST_F(TestExpander, testGenerate_QuotedString_InGroup) EXPECT_EQ(data[2], L"ac"); } +TEST_F(TestExpander, testGenerate_QuotedString_InGroup_AltQuote) +{ + + wstring pattern = L"a{b^123^c}"; + altExpander.generate(pattern); + auto data = altExpander.getData(); + EXPECT_EQ(data.size(), 3); + //EXPECT_EQ(data[0], L"ab"); + //EXPECT_EQ(data[1], L"a123"); + //EXPECT_EQ(data[2], L"ac"); +} + TEST_F(TestExpander, testGenerate_QuotedString) { @@ -740,6 +752,17 @@ TEST_F(TestExpander, testGenerate_QuotedString) EXPECT_EQ(data[0], L"[a-c]"); } +TEST_F(TestExpander, testGenerate_QuotedString_AltQuote) +{ + + wstring pattern = L"^[a-c]^"; + altExpander.generate(pattern); + auto data = altExpander.getData(); + EXPECT_EQ(data.size(), 1); + EXPECT_EQ(data[0], L"[a-c]"); +} + + TEST_F(TestExpander, testGenerate_VariableBlock_EscRange) { wstring pattern = L"a-c[1-3]"; @@ -789,6 +812,19 @@ TEST_F(TestExpander, testGenerate_VariableBlock_EscQuote) } +TEST_F(TestExpander, testGenerate_VariableBlock_EscAltQuote) +{ + wstring pattern = L"a{#^b>d}"; + altExpander.generate(pattern); + auto data = altExpander.getData(); + ASSERT_EQ(data.size(), 4); + EXPECT_EQ(data[0], L"a^"); + EXPECT_EQ(data[1], L"ab"); + EXPECT_EQ(data[2], L"ac"); + EXPECT_EQ(data[3], L"ad"); + +} + TEST_F(TestExpander, testGenerate_VariableBlock_EscQuote_OutsideGroup) { // /"[a-c]/" Since the queotes are escaped [a-c] is expanded and you end up with : "a" "b" "c" From f09709d5c385683d00b180effbdb29d3a7d032eb Mon Sep 17 00:00:00 2001 From: Ventsy Velev Date: Thu, 16 Nov 2023 12:12:06 -0500 Subject: [PATCH 8/9] Changes EXPECT_EQ to ASSERT_EQ in unit tests --- test/TestExpander.cpp | 474 +++++++++++++++++++++--------------------- 1 file changed, 237 insertions(+), 237 deletions(-) diff --git a/test/TestExpander.cpp b/test/TestExpander.cpp index b700365..9d37a84 100644 --- a/test/TestExpander.cpp +++ b/test/TestExpander.cpp @@ -27,19 +27,19 @@ class TestExpander: public ::testing::Test TEST_F(TestExpander, testGetters) { char result = underTest.getEscChar(); - EXPECT_EQ(PatternExpander::DEFAULT_ESC_SYM, result); + ASSERT_EQ(PatternExpander::DEFAULT_ESC_SYM, result); result = underTest.getRangeChar(); - EXPECT_EQ(PatternExpander::DEFAULT_RANGE_SYM, result); + ASSERT_EQ(PatternExpander::DEFAULT_RANGE_SYM, result); result = underTest.getGroupBegin(); - EXPECT_EQ(PatternExpander::DEFAULT_GROUP_BEGIN_SYM, result); + ASSERT_EQ(PatternExpander::DEFAULT_GROUP_BEGIN_SYM, result); result = underTest.getGroupEnd(); - EXPECT_EQ(PatternExpander::DEFAULT_GROUP_END_SYM, result); + ASSERT_EQ(PatternExpander::DEFAULT_GROUP_END_SYM, result); result = underTest.getQuote(); - EXPECT_EQ(PatternExpander::DEFAULT_QUOTE_SYM, result); + ASSERT_EQ(PatternExpander::DEFAULT_QUOTE_SYM, result); } TEST_F(TestExpander, testSetters) @@ -47,27 +47,27 @@ TEST_F(TestExpander, testSetters) wchar_t input = '`'; underTest.setEscChar(input); char result = underTest.getEscChar(); - EXPECT_EQ(input, result); + ASSERT_EQ(input, result); input = '_'; underTest.setRangeChar(input); result = underTest.getRangeChar(); - EXPECT_EQ(input, result); + ASSERT_EQ(input, result); input = '{'; underTest.setGroupBegin(input); result = underTest.getGroupBegin(); - EXPECT_EQ(input, result); + ASSERT_EQ(input, result); input = '}'; underTest.setGroupEnd(input); result = underTest.getGroupEnd(); - EXPECT_EQ(input, result); + ASSERT_EQ(input, result); input = '^'; underTest.setQuote(input); result = underTest.getQuote(); - EXPECT_EQ(input, result); + ASSERT_EQ(input, result); } TEST_F(TestExpander, testValidation_valid) @@ -148,8 +148,8 @@ TEST_F(TestExpander, testGenerate_StaticBlock) wstring pattern = L"abcd"; underTest.generate(pattern); auto data = underTest.getData(); - EXPECT_EQ(data.size(), 1); - EXPECT_EQ(data[0], pattern); + ASSERT_EQ(data.size(), 1); + ASSERT_EQ(data[0], pattern); } TEST_F(TestExpander, testGenerate_StaticBlock_EscGrpBegin) @@ -157,8 +157,8 @@ TEST_F(TestExpander, testGenerate_StaticBlock_EscGrpBegin) wstring pattern = L"abc/[d"; underTest.generate(pattern); auto data = underTest.getData(); - EXPECT_EQ(data.size(), 1); - EXPECT_EQ(data[0], L"abc[d"); + ASSERT_EQ(data.size(), 1); + ASSERT_EQ(data[0], L"abc[d"); } TEST_F(TestExpander, testGenerate_StaticBlock_EscGrpEnd) @@ -166,8 +166,8 @@ TEST_F(TestExpander, testGenerate_StaticBlock_EscGrpEnd) wstring pattern = L"abc/]d"; underTest.generate(pattern); auto data = underTest.getData(); - EXPECT_EQ(data.size(), 1); - EXPECT_EQ(data[0], L"abc]d"); + ASSERT_EQ(data.size(), 1); + ASSERT_EQ(data[0], L"abc]d"); } TEST_F(TestExpander, testGenerate_StaticBlock_EscDash) @@ -176,8 +176,8 @@ TEST_F(TestExpander, testGenerate_StaticBlock_EscDash) wstring pattern = L"abc/-d"; underTest.generate(pattern); auto data = underTest.getData(); - EXPECT_EQ(data.size(), 1); - EXPECT_EQ(data[0], L"abc/-d"); + ASSERT_EQ(data.size(), 1); + ASSERT_EQ(data[0], L"abc/-d"); } TEST_F(TestExpander, testGenerate_StaticBlock_EscEscChar) @@ -187,8 +187,8 @@ TEST_F(TestExpander, testGenerate_StaticBlock_EscEscChar) wstring pattern = L"abc//d"; underTest.generate(pattern); auto data = underTest.getData(); - EXPECT_EQ(data.size(), 1); - EXPECT_EQ(data[0], L"abc/d"); + ASSERT_EQ(data.size(), 1); + ASSERT_EQ(data[0], L"abc/d"); } @@ -197,10 +197,10 @@ TEST_F(TestExpander, testGenerate_VariableBlock_Range) wstring pattern = L"[a-c]"; underTest.generate(pattern); auto data = underTest.getData(); - EXPECT_EQ(data.size(), 3); - EXPECT_EQ(data[0], L"a"); - EXPECT_EQ(data[1], L"b"); - EXPECT_EQ(data[2], L"c"); + ASSERT_EQ(data.size(), 3); + ASSERT_EQ(data[0], L"a"); + ASSERT_EQ(data[1], L"b"); + ASSERT_EQ(data[2], L"c"); } TEST_F(TestExpander, testGenerate_VariableBlock_Range2) @@ -208,26 +208,26 @@ TEST_F(TestExpander, testGenerate_VariableBlock_Range2) wstring pattern = L"1[a-c]"; underTest.generate(pattern); auto data = underTest.getData(); - EXPECT_EQ(data.size(), 3); - EXPECT_EQ(data[0], L"1a"); - EXPECT_EQ(data[1], L"1b"); - EXPECT_EQ(data[2], L"1c"); + ASSERT_EQ(data.size(), 3); + ASSERT_EQ(data[0], L"1a"); + ASSERT_EQ(data[1], L"1b"); + ASSERT_EQ(data[2], L"1c"); } TEST_F(TestExpander, testGenerate_VariableBlock_Range3) { wstring pattern = L"[123][a-c]"; underTest.generate(pattern); auto data = underTest.getData(); - EXPECT_EQ(data.size(), 9); - EXPECT_EQ(data[0], L"1a"); - EXPECT_EQ(data[1], L"2a"); - EXPECT_EQ(data[2], L"3a"); - EXPECT_EQ(data[3], L"1b"); - EXPECT_EQ(data[4], L"2b"); - EXPECT_EQ(data[5], L"3b"); - EXPECT_EQ(data[6], L"1c"); - EXPECT_EQ(data[7], L"2c"); - EXPECT_EQ(data[8], L"3c"); + ASSERT_EQ(data.size(), 9); + ASSERT_EQ(data[0], L"1a"); + ASSERT_EQ(data[1], L"2a"); + ASSERT_EQ(data[2], L"3a"); + ASSERT_EQ(data[3], L"1b"); + ASSERT_EQ(data[4], L"2b"); + ASSERT_EQ(data[5], L"3b"); + ASSERT_EQ(data[6], L"1c"); + ASSERT_EQ(data[7], L"2c"); + ASSERT_EQ(data[8], L"3c"); } TEST_F(TestExpander, testGenerate_VariableBlock_2Ranges) @@ -235,16 +235,16 @@ TEST_F(TestExpander, testGenerate_VariableBlock_2Ranges) wstring pattern = L"[1-3][a-c]"; underTest.generate(pattern); auto data = underTest.getData(); - EXPECT_EQ(data.size(), 9); - EXPECT_EQ(data[0], L"1a"); - EXPECT_EQ(data[1], L"2a"); - EXPECT_EQ(data[2], L"3a"); - EXPECT_EQ(data[3], L"1b"); - EXPECT_EQ(data[4], L"2b"); - EXPECT_EQ(data[5], L"3b"); - EXPECT_EQ(data[6], L"1c"); - EXPECT_EQ(data[7], L"2c"); - EXPECT_EQ(data[8], L"3c"); + ASSERT_EQ(data.size(), 9); + ASSERT_EQ(data[0], L"1a"); + ASSERT_EQ(data[1], L"2a"); + ASSERT_EQ(data[2], L"3a"); + ASSERT_EQ(data[3], L"1b"); + ASSERT_EQ(data[4], L"2b"); + ASSERT_EQ(data[5], L"3b"); + ASSERT_EQ(data[6], L"1c"); + ASSERT_EQ(data[7], L"2c"); + ASSERT_EQ(data[8], L"3c"); } TEST_F(TestExpander, testGenerate_VariableBlock_EmbededVarBlock) @@ -253,16 +253,16 @@ TEST_F(TestExpander, testGenerate_VariableBlock_EmbededVarBlock) wstring pattern = L"[123[a-c]]"; underTest.generate(pattern); auto data = underTest.getData(); - EXPECT_EQ(data.size(), 9); - EXPECT_EQ(data[0], L"1a"); - EXPECT_EQ(data[1], L"2a"); - EXPECT_EQ(data[2], L"3a"); - EXPECT_EQ(data[3], L"1b"); - EXPECT_EQ(data[4], L"2b"); - EXPECT_EQ(data[5], L"3b"); - EXPECT_EQ(data[6], L"1c"); - EXPECT_EQ(data[7], L"2c"); - EXPECT_EQ(data[8], L"3c"); + ASSERT_EQ(data.size(), 9); + ASSERT_EQ(data[0], L"1a"); + ASSERT_EQ(data[1], L"2a"); + ASSERT_EQ(data[2], L"3a"); + ASSERT_EQ(data[3], L"1b"); + ASSERT_EQ(data[4], L"2b"); + ASSERT_EQ(data[5], L"3b"); + ASSERT_EQ(data[6], L"1c"); + ASSERT_EQ(data[7], L"2c"); + ASSERT_EQ(data[8], L"3c"); } TEST_F(TestExpander, testValidation_valid_alt) @@ -343,8 +343,8 @@ TEST_F(TestExpander, testGenerate_StaticBlock_alt) wstring pattern = L"abcd"; altExpander.generate(pattern); auto data = altExpander.getData(); - EXPECT_EQ(data.size(), 1); - EXPECT_EQ(data[0], pattern); + ASSERT_EQ(data.size(), 1); + ASSERT_EQ(data[0], pattern); } TEST_F(TestExpander, testGenerate_StaticBlock_EscGrpBegin_alt) @@ -352,8 +352,8 @@ TEST_F(TestExpander, testGenerate_StaticBlock_EscGrpBegin_alt) wstring pattern = L"abc#{d"; altExpander.generate(pattern); auto data = altExpander.getData(); - EXPECT_EQ(data.size(), 1); - EXPECT_EQ(data[0], L"abc{d"); + ASSERT_EQ(data.size(), 1); + ASSERT_EQ(data[0], L"abc{d"); } TEST_F(TestExpander, testGenerate_StaticBlock_EscGrpEnd_alt) @@ -361,8 +361,8 @@ TEST_F(TestExpander, testGenerate_StaticBlock_EscGrpEnd_alt) wstring pattern = L"abc#}d"; altExpander.generate(pattern); auto data = altExpander.getData(); - EXPECT_EQ(data.size(), 1); - EXPECT_EQ(data[0], L"abc}d"); + ASSERT_EQ(data.size(), 1); + ASSERT_EQ(data[0], L"abc}d"); } TEST_F(TestExpander, testGenerate_StaticBlock_EscDash_alt) @@ -370,8 +370,8 @@ TEST_F(TestExpander, testGenerate_StaticBlock_EscDash_alt) wstring pattern = L"abc#>d"; altExpander.generate(pattern); auto data = altExpander.getData(); - EXPECT_EQ(data.size(), 1); - EXPECT_EQ(data[0], L"abc#>d"); + ASSERT_EQ(data.size(), 1); + ASSERT_EQ(data[0], L"abc#>d"); } TEST_F(TestExpander, testGenerate_StaticBlock_EscEscChar_alt) @@ -380,8 +380,8 @@ TEST_F(TestExpander, testGenerate_StaticBlock_EscEscChar_alt) wstring pattern = L"abc##d"; altExpander.generate(pattern); auto data = altExpander.getData(); - EXPECT_EQ(data.size(), 1); - EXPECT_EQ(data[0], L"abc#d"); + ASSERT_EQ(data.size(), 1); + ASSERT_EQ(data[0], L"abc#d"); } @@ -390,10 +390,10 @@ TEST_F(TestExpander, testGenerate_VariableBlock_Range_alt) wstring pattern = L"{a>c}"; altExpander.generate(pattern); auto data = altExpander.getData(); - EXPECT_EQ(data.size(), 3); - EXPECT_EQ(data[0], L"a"); - EXPECT_EQ(data[1], L"b"); - EXPECT_EQ(data[2], L"c"); + ASSERT_EQ(data.size(), 3); + ASSERT_EQ(data[0], L"a"); + ASSERT_EQ(data[1], L"b"); + ASSERT_EQ(data[2], L"c"); } TEST_F(TestExpander, testGenerate_VariableBlock_Range2_alt) @@ -401,26 +401,26 @@ TEST_F(TestExpander, testGenerate_VariableBlock_Range2_alt) wstring pattern = L"1{a>c}"; altExpander.generate(pattern); auto data = altExpander.getData(); - EXPECT_EQ(data.size(), 3); - EXPECT_EQ(data[0], L"1a"); - EXPECT_EQ(data[1], L"1b"); - EXPECT_EQ(data[2], L"1c"); + ASSERT_EQ(data.size(), 3); + ASSERT_EQ(data[0], L"1a"); + ASSERT_EQ(data[1], L"1b"); + ASSERT_EQ(data[2], L"1c"); } TEST_F(TestExpander, testGenerate_VariableBlock_Range3_alt) { wstring pattern = L"{123}{a>c}"; altExpander.generate(pattern); auto data = altExpander.getData(); - EXPECT_EQ(data.size(), 9); - EXPECT_EQ(data[0], L"1a"); - EXPECT_EQ(data[1], L"2a"); - EXPECT_EQ(data[2], L"3a"); - EXPECT_EQ(data[3], L"1b"); - EXPECT_EQ(data[4], L"2b"); - EXPECT_EQ(data[5], L"3b"); - EXPECT_EQ(data[6], L"1c"); - EXPECT_EQ(data[7], L"2c"); - EXPECT_EQ(data[8], L"3c"); + ASSERT_EQ(data.size(), 9); + ASSERT_EQ(data[0], L"1a"); + ASSERT_EQ(data[1], L"2a"); + ASSERT_EQ(data[2], L"3a"); + ASSERT_EQ(data[3], L"1b"); + ASSERT_EQ(data[4], L"2b"); + ASSERT_EQ(data[5], L"3b"); + ASSERT_EQ(data[6], L"1c"); + ASSERT_EQ(data[7], L"2c"); + ASSERT_EQ(data[8], L"3c"); } TEST_F(TestExpander, testGenerate_VariableBlock_2Ranges_alt) @@ -428,16 +428,16 @@ TEST_F(TestExpander, testGenerate_VariableBlock_2Ranges_alt) wstring pattern = L"{1>3}{a>c}"; altExpander.generate(pattern); auto data = altExpander.getData(); - EXPECT_EQ(data.size(), 9); - EXPECT_EQ(data[0], L"1a"); - EXPECT_EQ(data[1], L"2a"); - EXPECT_EQ(data[2], L"3a"); - EXPECT_EQ(data[3], L"1b"); - EXPECT_EQ(data[4], L"2b"); - EXPECT_EQ(data[5], L"3b"); - EXPECT_EQ(data[6], L"1c"); - EXPECT_EQ(data[7], L"2c"); - EXPECT_EQ(data[8], L"3c"); + ASSERT_EQ(data.size(), 9); + ASSERT_EQ(data[0], L"1a"); + ASSERT_EQ(data[1], L"2a"); + ASSERT_EQ(data[2], L"3a"); + ASSERT_EQ(data[3], L"1b"); + ASSERT_EQ(data[4], L"2b"); + ASSERT_EQ(data[5], L"3b"); + ASSERT_EQ(data[6], L"1c"); + ASSERT_EQ(data[7], L"2c"); + ASSERT_EQ(data[8], L"3c"); } TEST_F(TestExpander, testGenerate_VariableBlock_EmbededVarBlock_alt) @@ -446,16 +446,16 @@ TEST_F(TestExpander, testGenerate_VariableBlock_EmbededVarBlock_alt) wstring pattern = L"{123{a>c}}"; altExpander.generate(pattern); auto data = altExpander.getData(); - EXPECT_EQ(data.size(), 9); - EXPECT_EQ(data[0], L"1a"); - EXPECT_EQ(data[1], L"2a"); - EXPECT_EQ(data[2], L"3a"); - EXPECT_EQ(data[3], L"1b"); - EXPECT_EQ(data[4], L"2b"); - EXPECT_EQ(data[5], L"3b"); - EXPECT_EQ(data[6], L"1c"); - EXPECT_EQ(data[7], L"2c"); - EXPECT_EQ(data[8], L"3c"); + ASSERT_EQ(data.size(), 9); + ASSERT_EQ(data[0], L"1a"); + ASSERT_EQ(data[1], L"2a"); + ASSERT_EQ(data[2], L"3a"); + ASSERT_EQ(data[3], L"1b"); + ASSERT_EQ(data[4], L"2b"); + ASSERT_EQ(data[5], L"3b"); + ASSERT_EQ(data[6], L"1c"); + ASSERT_EQ(data[7], L"2c"); + ASSERT_EQ(data[8], L"3c"); } TEST_F(TestExpander, testValidation_valid_Cyrilic) @@ -536,8 +536,8 @@ TEST_F(TestExpander, testGenerate_StaticBlock_Cyrilic) wstring pattern = L"абвг"; underTest.generate(pattern); auto data = underTest.getData(); - EXPECT_EQ(data.size(), 1); - EXPECT_EQ(data[0], pattern); + ASSERT_EQ(data.size(), 1); + ASSERT_EQ(data[0], pattern); } TEST_F(TestExpander, testGenerate_StaticBlock_EscGrpBegin_Cyrilic) @@ -545,8 +545,8 @@ TEST_F(TestExpander, testGenerate_StaticBlock_EscGrpBegin_Cyrilic) wstring pattern = L"абв/[г"; underTest.generate(pattern); auto data = underTest.getData(); - EXPECT_EQ(data.size(), 1); - EXPECT_EQ(data[0], L"абв[г"); + ASSERT_EQ(data.size(), 1); + ASSERT_EQ(data[0], L"абв[г"); } TEST_F(TestExpander, testGenerate_StaticBlock_EscGrpEnd_Cyrilic) @@ -554,8 +554,8 @@ TEST_F(TestExpander, testGenerate_StaticBlock_EscGrpEnd_Cyrilic) wstring pattern = L"абв/]г"; underTest.generate(pattern); auto data = underTest.getData(); - EXPECT_EQ(data.size(), 1); - EXPECT_EQ(data[0], L"абв]г"); + ASSERT_EQ(data.size(), 1); + ASSERT_EQ(data[0], L"абв]г"); } TEST_F(TestExpander, testGenerate_StaticBlock_EscDash_Cyrilic) @@ -563,8 +563,8 @@ TEST_F(TestExpander, testGenerate_StaticBlock_EscDash_Cyrilic) wstring pattern = L"абв/-г"; underTest.generate(pattern); auto data = underTest.getData(); - EXPECT_EQ(data.size(), 1); - EXPECT_EQ(data[0], L"абв/-г"); + ASSERT_EQ(data.size(), 1); + ASSERT_EQ(data[0], L"абв/-г"); } TEST_F(TestExpander, testGenerate_StaticBlock_EscEscChar_Cyrilic) @@ -573,8 +573,8 @@ TEST_F(TestExpander, testGenerate_StaticBlock_EscEscChar_Cyrilic) wstring pattern = L"абв//г"; underTest.generate(pattern); auto data = underTest.getData(); - EXPECT_EQ(data.size(), 1); - EXPECT_EQ(data[0], L"абв/г"); + ASSERT_EQ(data.size(), 1); + ASSERT_EQ(data[0], L"абв/г"); } @@ -583,10 +583,10 @@ TEST_F(TestExpander, testGenerate_VariableBlock_Range_Cyrilic) wstring pattern = L"[а-в]"; underTest.generate(pattern); auto data = underTest.getData(); - EXPECT_EQ(data.size(), 3); - EXPECT_EQ(data[0], L"а"); - EXPECT_EQ(data[1], L"б"); - EXPECT_EQ(data[2], L"в"); + ASSERT_EQ(data.size(), 3); + ASSERT_EQ(data[0], L"а"); + ASSERT_EQ(data[1], L"б"); + ASSERT_EQ(data[2], L"в"); } TEST_F(TestExpander, testGenerate_VariableBlock_Range2_Cyrilic) @@ -594,26 +594,26 @@ TEST_F(TestExpander, testGenerate_VariableBlock_Range2_Cyrilic) wstring pattern = L"1[а-в]"; underTest.generate(pattern); auto data = underTest.getData(); - EXPECT_EQ(data.size(), 3); - EXPECT_EQ(data[0], L"1а"); - EXPECT_EQ(data[1], L"1б"); - EXPECT_EQ(data[2], L"1в"); + ASSERT_EQ(data.size(), 3); + ASSERT_EQ(data[0], L"1а"); + ASSERT_EQ(data[1], L"1б"); + ASSERT_EQ(data[2], L"1в"); } TEST_F(TestExpander, testGenerate_VariableBlock_Range3_Cyrilic) { wstring pattern = L"[123][а-в]"; underTest.generate(pattern); auto data = underTest.getData(); - EXPECT_EQ(data.size(), 9); - EXPECT_EQ(data[0], L"1а"); - EXPECT_EQ(data[1], L"2а"); - EXPECT_EQ(data[2], L"3а"); - EXPECT_EQ(data[3], L"1б"); - EXPECT_EQ(data[4], L"2б"); - EXPECT_EQ(data[5], L"3б"); - EXPECT_EQ(data[6], L"1в"); - EXPECT_EQ(data[7], L"2в"); - EXPECT_EQ(data[8], L"3в"); + ASSERT_EQ(data.size(), 9); + ASSERT_EQ(data[0], L"1а"); + ASSERT_EQ(data[1], L"2а"); + ASSERT_EQ(data[2], L"3а"); + ASSERT_EQ(data[3], L"1б"); + ASSERT_EQ(data[4], L"2б"); + ASSERT_EQ(data[5], L"3б"); + ASSERT_EQ(data[6], L"1в"); + ASSERT_EQ(data[7], L"2в"); + ASSERT_EQ(data[8], L"3в"); } TEST_F(TestExpander, testGenerate_VariableBlock_2Ranges_Cyrilic) @@ -621,16 +621,16 @@ TEST_F(TestExpander, testGenerate_VariableBlock_2Ranges_Cyrilic) wstring pattern = L"[1-3][а-в]"; underTest.generate(pattern); auto data = underTest.getData(); - EXPECT_EQ(data.size(), 9); - EXPECT_EQ(data[0], L"1а"); - EXPECT_EQ(data[1], L"2а"); - EXPECT_EQ(data[2], L"3а"); - EXPECT_EQ(data[3], L"1б"); - EXPECT_EQ(data[4], L"2б"); - EXPECT_EQ(data[5], L"3б"); - EXPECT_EQ(data[6], L"1в"); - EXPECT_EQ(data[7], L"2в"); - EXPECT_EQ(data[8], L"3в"); + ASSERT_EQ(data.size(), 9); + ASSERT_EQ(data[0], L"1а"); + ASSERT_EQ(data[1], L"2а"); + ASSERT_EQ(data[2], L"3а"); + ASSERT_EQ(data[3], L"1б"); + ASSERT_EQ(data[4], L"2б"); + ASSERT_EQ(data[5], L"3б"); + ASSERT_EQ(data[6], L"1в"); + ASSERT_EQ(data[7], L"2в"); + ASSERT_EQ(data[8], L"3в"); } TEST_F(TestExpander, testGenerate_VariableBlock_EmbededVarBlock_Cyrilic) @@ -639,16 +639,16 @@ TEST_F(TestExpander, testGenerate_VariableBlock_EmbededVarBlock_Cyrilic) wstring pattern = L"[123[а-в]]"; underTest.generate(pattern); auto data = underTest.getData(); - EXPECT_EQ(data.size(), 9); - EXPECT_EQ(data[0], L"1а"); - EXPECT_EQ(data[1], L"2а"); - EXPECT_EQ(data[2], L"3а"); - EXPECT_EQ(data[3], L"1б"); - EXPECT_EQ(data[4], L"2б"); - EXPECT_EQ(data[5], L"3б"); - EXPECT_EQ(data[6], L"1в"); - EXPECT_EQ(data[7], L"2в"); - EXPECT_EQ(data[8], L"3в"); + ASSERT_EQ(data.size(), 9); + ASSERT_EQ(data[0], L"1а"); + ASSERT_EQ(data[1], L"2а"); + ASSERT_EQ(data[2], L"3а"); + ASSERT_EQ(data[3], L"1б"); + ASSERT_EQ(data[4], L"2б"); + ASSERT_EQ(data[5], L"3б"); + ASSERT_EQ(data[6], L"1в"); + ASSERT_EQ(data[7], L"2в"); + ASSERT_EQ(data[8], L"3в"); } TEST_F(TestExpander, testGenerate_VariableBlock_Beginning) @@ -657,10 +657,10 @@ TEST_F(TestExpander, testGenerate_VariableBlock_Beginning) wstring pattern = L"[1-3]abc"; underTest.generate(pattern); auto data = underTest.getData(); - EXPECT_EQ(data.size(), 3); - EXPECT_EQ(data[0], L"1abc"); - EXPECT_EQ(data[1], L"2abc"); - EXPECT_EQ(data[2], L"3abc"); + ASSERT_EQ(data.size(), 3); + ASSERT_EQ(data[0], L"1abc"); + ASSERT_EQ(data[1], L"2abc"); + ASSERT_EQ(data[2], L"3abc"); } TEST_F(TestExpander, testGenerate_VariableBlock_Middle) @@ -669,10 +669,10 @@ TEST_F(TestExpander, testGenerate_VariableBlock_Middle) wstring pattern = L"ab[1-3]cd"; underTest.generate(pattern); auto data = underTest.getData(); - EXPECT_EQ(data.size(), 3); - EXPECT_EQ(data[0], L"ab1cd"); - EXPECT_EQ(data[1], L"ab2cd"); - EXPECT_EQ(data[2], L"ab3cd"); + ASSERT_EQ(data.size(), 3); + ASSERT_EQ(data[0], L"ab1cd"); + ASSERT_EQ(data[1], L"ab2cd"); + ASSERT_EQ(data[2], L"ab3cd"); } TEST_F(TestExpander, testGenerate_Static_Range_Beginning) @@ -681,10 +681,10 @@ TEST_F(TestExpander, testGenerate_Static_Range_Beginning) wstring pattern = L"a-c[1-3]"; underTest.generate(pattern); auto data = underTest.getData(); - EXPECT_EQ(data.size(), 3); - EXPECT_EQ(data[0], L"a-c1"); - EXPECT_EQ(data[1], L"a-c2"); - EXPECT_EQ(data[2], L"a-c3"); + ASSERT_EQ(data.size(), 3); + ASSERT_EQ(data[0], L"a-c1"); + ASSERT_EQ(data[1], L"a-c2"); + ASSERT_EQ(data[2], L"a-c3"); } @@ -694,16 +694,16 @@ TEST_F(TestExpander, testGenerate_Static_Range_Middle) wstring pattern = L"[1-3]a-c[1-3]"; underTest.generate(pattern); auto data = underTest.getData(); - EXPECT_EQ(data.size(), 9); - EXPECT_EQ(data[0], L"1a-c1"); - EXPECT_EQ(data[1], L"2a-c1"); - EXPECT_EQ(data[2], L"3a-c1"); - EXPECT_EQ(data[3], L"1a-c2"); - EXPECT_EQ(data[4], L"2a-c2"); - EXPECT_EQ(data[5], L"3a-c2"); - EXPECT_EQ(data[6], L"1a-c3"); - EXPECT_EQ(data[7], L"2a-c3"); - EXPECT_EQ(data[8], L"3a-c3"); + ASSERT_EQ(data.size(), 9); + ASSERT_EQ(data[0], L"1a-c1"); + ASSERT_EQ(data[1], L"2a-c1"); + ASSERT_EQ(data[2], L"3a-c1"); + ASSERT_EQ(data[3], L"1a-c2"); + ASSERT_EQ(data[4], L"2a-c2"); + ASSERT_EQ(data[5], L"3a-c2"); + ASSERT_EQ(data[6], L"1a-c3"); + ASSERT_EQ(data[7], L"2a-c3"); + ASSERT_EQ(data[8], L"3a-c3"); } TEST_F(TestExpander, testGenerate_Static_Range_End) @@ -712,10 +712,10 @@ TEST_F(TestExpander, testGenerate_Static_Range_End) wstring pattern = L"[1-3]a-c"; underTest.generate(pattern); auto data = underTest.getData(); - EXPECT_EQ(data.size(), 3); - EXPECT_EQ(data[0], L"1a-c"); - EXPECT_EQ(data[1], L"2a-c"); - EXPECT_EQ(data[2], L"3a-c"); + ASSERT_EQ(data.size(), 3); + ASSERT_EQ(data[0], L"1a-c"); + ASSERT_EQ(data[1], L"2a-c"); + ASSERT_EQ(data[2], L"3a-c"); } TEST_F(TestExpander, testGenerate_QuotedString_InGroup) @@ -724,10 +724,10 @@ TEST_F(TestExpander, testGenerate_QuotedString_InGroup) wstring pattern = L"a[b\"123\"c]"; underTest.generate(pattern); auto data = underTest.getData(); - EXPECT_EQ(data.size(), 3); - EXPECT_EQ(data[0], L"ab"); - EXPECT_EQ(data[1], L"a123"); - EXPECT_EQ(data[2], L"ac"); + ASSERT_EQ(data.size(), 3); + ASSERT_EQ(data[0], L"ab"); + ASSERT_EQ(data[1], L"a123"); + ASSERT_EQ(data[2], L"ac"); } TEST_F(TestExpander, testGenerate_QuotedString_InGroup_AltQuote) @@ -736,10 +736,10 @@ TEST_F(TestExpander, testGenerate_QuotedString_InGroup_AltQuote) wstring pattern = L"a{b^123^c}"; altExpander.generate(pattern); auto data = altExpander.getData(); - EXPECT_EQ(data.size(), 3); - //EXPECT_EQ(data[0], L"ab"); - //EXPECT_EQ(data[1], L"a123"); - //EXPECT_EQ(data[2], L"ac"); + ASSERT_EQ(data.size(), 3); + //ASSERT_EQ(data[0], L"ab"); + //ASSERT_EQ(data[1], L"a123"); + //ASSERT_EQ(data[2], L"ac"); } TEST_F(TestExpander, testGenerate_QuotedString) @@ -748,8 +748,8 @@ TEST_F(TestExpander, testGenerate_QuotedString) wstring pattern = L"\"[a-c]\""; underTest.generate(pattern); auto data = underTest.getData(); - EXPECT_EQ(data.size(), 1); - EXPECT_EQ(data[0], L"[a-c]"); + ASSERT_EQ(data.size(), 1); + ASSERT_EQ(data[0], L"[a-c]"); } TEST_F(TestExpander, testGenerate_QuotedString_AltQuote) @@ -758,8 +758,8 @@ TEST_F(TestExpander, testGenerate_QuotedString_AltQuote) wstring pattern = L"^[a-c]^"; altExpander.generate(pattern); auto data = altExpander.getData(); - EXPECT_EQ(data.size(), 1); - EXPECT_EQ(data[0], L"[a-c]"); + ASSERT_EQ(data.size(), 1); + ASSERT_EQ(data[0], L"[a-c]"); } @@ -768,10 +768,10 @@ TEST_F(TestExpander, testGenerate_VariableBlock_EscRange) wstring pattern = L"a-c[1-3]"; underTest.generate(pattern); auto data = underTest.getData(); - EXPECT_EQ(data.size(), 3); - EXPECT_EQ(data[0], L"a-c1"); - EXPECT_EQ(data[1], L"a-c2"); - EXPECT_EQ(data[2], L"a-c3"); + ASSERT_EQ(data.size(), 3); + ASSERT_EQ(data[0], L"a-c1"); + ASSERT_EQ(data[1], L"a-c2"); + ASSERT_EQ(data[2], L"a-c3"); } TEST_F(TestExpander, testGenerate_VariableBlock_EscRange_InGroup) @@ -779,10 +779,10 @@ TEST_F(TestExpander, testGenerate_VariableBlock_EscRange_InGroup) wstring pattern = L"[a/-c]"; underTest.generate(pattern); auto data = underTest.getData(); - EXPECT_EQ(data.size(), 3); - EXPECT_EQ(data[0], L"a"); - EXPECT_EQ(data[1], L"-"); - EXPECT_EQ(data[2], L"c"); + ASSERT_EQ(data.size(), 3); + ASSERT_EQ(data[0], L"a"); + ASSERT_EQ(data[1], L"-"); + ASSERT_EQ(data[2], L"c"); } TEST_F(TestExpander, testGenerate_VariableBlock_EscEscape) @@ -790,11 +790,11 @@ TEST_F(TestExpander, testGenerate_VariableBlock_EscEscape) wstring pattern = L"a[b///-d]"; underTest.generate(pattern); auto data = underTest.getData(); - EXPECT_EQ(data.size(), 4); - EXPECT_EQ(data[0], L"ab"); - EXPECT_EQ(data[1], L"a/"); - EXPECT_EQ(data[2], L"a-"); - EXPECT_EQ(data[3], L"ad"); + ASSERT_EQ(data.size(), 4); + ASSERT_EQ(data[0], L"ab"); + ASSERT_EQ(data[1], L"a/"); + ASSERT_EQ(data[2], L"a-"); + ASSERT_EQ(data[3], L"ad"); } @@ -804,11 +804,11 @@ TEST_F(TestExpander, testGenerate_VariableBlock_EscQuote) wstring pattern = L"a[/\"b-d]"; underTest.generate(pattern); auto data = underTest.getData(); - EXPECT_EQ(data.size(), 4); - EXPECT_EQ(data[0], L"a\""); - EXPECT_EQ(data[1], L"ab"); - EXPECT_EQ(data[2], L"ac"); - EXPECT_EQ(data[3], L"ad"); + ASSERT_EQ(data.size(), 4); + ASSERT_EQ(data[0], L"a\""); + ASSERT_EQ(data[1], L"ab"); + ASSERT_EQ(data[2], L"ac"); + ASSERT_EQ(data[3], L"ad"); } @@ -818,10 +818,10 @@ TEST_F(TestExpander, testGenerate_VariableBlock_EscAltQuote) altExpander.generate(pattern); auto data = altExpander.getData(); ASSERT_EQ(data.size(), 4); - EXPECT_EQ(data[0], L"a^"); - EXPECT_EQ(data[1], L"ab"); - EXPECT_EQ(data[2], L"ac"); - EXPECT_EQ(data[3], L"ad"); + ASSERT_EQ(data[0], L"a^"); + ASSERT_EQ(data[1], L"ab"); + ASSERT_EQ(data[2], L"ac"); + ASSERT_EQ(data[3], L"ad"); } @@ -831,10 +831,10 @@ TEST_F(TestExpander, testGenerate_VariableBlock_EscQuote_OutsideGroup) wstring pattern = LR"(/"[a-c]/")"; underTest.generate(pattern); auto data = underTest.getData(); - EXPECT_EQ(data.size(), 3); - EXPECT_EQ(data[0], L"\"a\""); - EXPECT_EQ(data[1], L"\"b\""); - EXPECT_EQ(data[2], L"\"c\""); + ASSERT_EQ(data.size(), 3); + ASSERT_EQ(data[0], L"\"a\""); + ASSERT_EQ(data[1], L"\"b\""); + ASSERT_EQ(data[2], L"\"c\""); } @@ -844,17 +844,17 @@ TEST_F(TestExpander, testLoadConfig) //Assuming that no ~/.patexpconfig exists, those will be the default values underTest.loadConfig("./nofile.txt"); - EXPECT_EQ(underTest.getEscChar(), PatternExpander::DEFAULT_ESC_SYM); - EXPECT_EQ(underTest.getGroupBegin(), PatternExpander::DEFAULT_GROUP_BEGIN_SYM); - EXPECT_EQ(underTest.getGroupEnd(), PatternExpander::DEFAULT_GROUP_END_SYM); - EXPECT_EQ(underTest.getRangeChar(), PatternExpander::DEFAULT_RANGE_SYM); + ASSERT_EQ(underTest.getEscChar(), PatternExpander::DEFAULT_ESC_SYM); + ASSERT_EQ(underTest.getGroupBegin(), PatternExpander::DEFAULT_GROUP_BEGIN_SYM); + ASSERT_EQ(underTest.getGroupEnd(), PatternExpander::DEFAULT_GROUP_END_SYM); + ASSERT_EQ(underTest.getRangeChar(), PatternExpander::DEFAULT_RANGE_SYM); altExpander.loadConfig("./nofile.txt"); - EXPECT_EQ(altExpander.getEscChar(), L'#'); - EXPECT_EQ(altExpander.getGroupBegin(), L'{'); - EXPECT_EQ(altExpander.getGroupEnd(), L'}'); - EXPECT_EQ(altExpander.getRangeChar(), L'>'); - EXPECT_EQ(altExpander.getQuote(), L'^'); + ASSERT_EQ(altExpander.getEscChar(), L'#'); + ASSERT_EQ(altExpander.getGroupBegin(), L'{'); + ASSERT_EQ(altExpander.getGroupEnd(), L'}'); + ASSERT_EQ(altExpander.getRangeChar(), L'>'); + ASSERT_EQ(altExpander.getQuote(), L'^'); } @@ -863,11 +863,11 @@ TEST_F(TestExpander, testLoadConfig_altSettings) //Load the alt config file. All settings will change underTest.loadConfig("test_data/altConfig.txt"); - EXPECT_EQ(underTest.getEscChar(), L'#'); - EXPECT_EQ(underTest.getGroupBegin(), L'{'); - EXPECT_EQ(underTest.getGroupEnd(), L'}'); - EXPECT_EQ(underTest.getRangeChar(), L'>'); - EXPECT_EQ(underTest.getQuote(), L'^'); + ASSERT_EQ(underTest.getEscChar(), L'#'); + ASSERT_EQ(underTest.getGroupBegin(), L'{'); + ASSERT_EQ(underTest.getGroupEnd(), L'}'); + ASSERT_EQ(underTest.getRangeChar(), L'>'); + ASSERT_EQ(underTest.getQuote(), L'^'); } @@ -879,11 +879,11 @@ TEST_F(TestExpander, testSaveConfig) altExpander.saveConfig(configFileName); underTest.loadConfig(configFileName); - EXPECT_EQ(underTest.getEscChar(), L'#'); - EXPECT_EQ(underTest.getGroupBegin(), L'{'); - EXPECT_EQ(underTest.getGroupEnd(), L'}'); - EXPECT_EQ(underTest.getRangeChar(), L'>'); - EXPECT_EQ(underTest.getQuote(), L'^'); + ASSERT_EQ(underTest.getEscChar(), L'#'); + ASSERT_EQ(underTest.getGroupBegin(), L'{'); + ASSERT_EQ(underTest.getGroupEnd(), L'}'); + ASSERT_EQ(underTest.getRangeChar(), L'>'); + ASSERT_EQ(underTest.getQuote(), L'^'); } From 7b81c0b500f4d18d26fe3d9e2f86be66a5c622cc Mon Sep 17 00:00:00 2001 From: Ventsy Velev Date: Thu, 16 Nov 2023 12:18:41 -0500 Subject: [PATCH 9/9] Adds another test for the alternative quote symbol handling --- test/TestExpander.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/TestExpander.cpp b/test/TestExpander.cpp index 9d37a84..cca7bcc 100644 --- a/test/TestExpander.cpp +++ b/test/TestExpander.cpp @@ -838,6 +838,20 @@ TEST_F(TestExpander, testGenerate_VariableBlock_EscQuote_OutsideGroup) } +TEST_F(TestExpander, testGenerate_VariableBlock_EscAltQuote_OutsideGroup) +{ + // /"[a-c]/" Since the queotes are escaped [a-c] is expanded and you end up with : "a" "b" "c" + wstring pattern = LR"(/'[a-c]/')"; + underTest.setQuote('\''); + underTest.generate(pattern); + auto data = underTest.getData(); + ASSERT_EQ(data.size(), 3); + ASSERT_EQ(data[0], L"'a'"); + ASSERT_EQ(data[1], L"'b'"); + ASSERT_EQ(data[2], L"'c'"); + +} + TEST_F(TestExpander, testLoadConfig) { //If the file doesn't exist the settings don't change