diff --git a/estyle/Generator.cpp b/estyle/Generator.cpp index ee56fc8..333107b 100644 --- a/estyle/Generator.cpp +++ b/estyle/Generator.cpp @@ -904,16 +904,33 @@ int32_t estyle::Generator::process(int32_t _startId, typePop(); continue; } - if (elem == estyle::lexer::RESERVED_NAMESPACE) { + if ( elem == estyle::lexer::RESERVED_NAMESPACE + || elem == estyle::lexer::RESERVED_CLASS + || elem == estyle::lexer::RESERVED_STRUCT) { addNewLineIfSemiColon(); - typePush("namespace"); addSpaceIfNeeded(); - m_output += "namespace"; + if (elem == estyle::lexer::RESERVED_NAMESPACE) { + typePush("namespace"); + m_output += "namespace"; + } else if (elem == estyle::lexer::RESERVED_CLASS) { + typePush("class"); + m_output += "class"; + } else if (elem == estyle::lexer::RESERVED_STRUCT) { + typePush("struct"); + m_output += "struct"; + } else { + if (startWithText(m_lexer.getData(iii)) == true) { + addSpaceIfNeeded(); + } + m_output += m_lexer.getData(iii); + continue; + } + // special case ==> nothing special to do for the else element... if (nextIs(iii+1, estyle::lexer::BRACE_IN) == false) { if (nextIs(iii+1, estyle::lexer::ID) == true) { - // normal case ==> empty namespace - addSpace(); + // normal case ==> empty namespace / struct / class + addSpaceIfNeeded(); iii++; m_output += m_lexer.getData(iii); } else { @@ -935,7 +952,7 @@ int32_t estyle::Generator::process(int32_t _startId, subGenerationStart = iii+2; subGenerationStop = endOfSection(iii+1); } else { - ESTYLE_ERROR("Missing { in namespace"); + ESTYLE_ERROR("Missing { in " << elem); typePop(); continue; } diff --git a/test/testClass.cpp b/test/testClass.cpp index e69de29..b98bc14 100644 --- a/test/testClass.cpp +++ b/test/testClass.cpp @@ -0,0 +1,257 @@ +/** + * @author Edouard DUPIN + * @copyright 2017, Edouard DUPIN, all right reserved + * @license MPL-2 (see license file) + */ +#include +#include +#include +#include +#include +#include + +static etk::String source = "action_A;class MyClass{action_B;}action_D;"; + + +TEST(testClass, brace_0000) { + estyle::Generator interface; + //interface.properties.set("brace-class-in-new-line-before", "true"); + //interface.properties.set("brace-class-in-new-line-after", "true"); + //interface.properties.set("brace-class-in-space-before", "true"); + //interface.properties.set("brace-class-in-space-after", "true"); + //interface.properties.set("brace-class-out-new-line-before", "true"); + //interface.properties.set("brace-class-out-new-line-after", "true"); + //interface.properties.set("brace-class-out-space-before", "true"); + //interface.properties.set("brace-class-out-space-after", "true"); + etk::String outRef = "action_A;class MyClass{action_B;}action_D;"; + etk::String output = interface.process(source); + EXPECT_EQ(output, outRef); +} + +TEST(testClass, brace_1000) { + estyle::Generator interface; + interface.properties.set("brace-class-in-new-line-before", "true"); + //interface.properties.set("brace-class-in-new-line-after", "true"); + //interface.properties.set("brace-class-in-space-before", "true"); + //interface.properties.set("brace-class-in-space-after", "true"); + interface.properties.set("brace-class-out-new-line-before", "true"); + //interface.properties.set("brace-class-out-new-line-after", "true"); + //interface.properties.set("brace-class-out-space-before", "true"); + //interface.properties.set("brace-class-out-space-after", "true"); + etk::String outRef = "action_A;class MyClass\n{action_B;\n}action_D;"; + etk::String output = interface.process(source); + EXPECT_EQ(output, outRef); +} + +TEST(testClass, brace_1010) { + estyle::Generator interface; + interface.properties.set("brace-class-in-new-line-before", "true"); + //interface.properties.set("brace-class-in-new-line-after", "true"); + interface.properties.set("brace-class-in-space-before", "true"); + //interface.properties.set("brace-class-in-space-after", "true"); + interface.properties.set("brace-class-out-new-line-before", "true"); + //interface.properties.set("brace-class-out-new-line-after", "true"); + interface.properties.set("brace-class-out-space-before", "true"); + //interface.properties.set("brace-class-out-space-after", "true"); + etk::String outRef = "action_A;class MyClass\n{action_B;\n}action_D;"; + etk::String output = interface.process(source); + EXPECT_EQ(output, outRef); +} + +TEST(testClass, brace_1011) { + estyle::Generator interface; + interface.properties.set("brace-class-in-new-line-before", "true"); + //interface.properties.set("brace-class-in-new-line-after", "true"); + interface.properties.set("brace-class-in-space-before", "true"); + interface.properties.set("brace-class-in-space-after", "true"); + interface.properties.set("brace-class-out-new-line-before", "true"); + //interface.properties.set("brace-class-out-new-line-after", "true"); + interface.properties.set("brace-class-out-space-before", "true"); + interface.properties.set("brace-class-out-space-after", "true"); + etk::String outRef = "action_A;class MyClass\n{ action_B;\n} action_D;"; + etk::String output = interface.process(source); + EXPECT_EQ(output, outRef); +} + +TEST(testClass, brace_1100) { + estyle::Generator interface; + interface.properties.set("brace-class-in-new-line-before", "true"); + interface.properties.set("brace-class-in-new-line-after", "true"); + //interface.properties.set("brace-class-in-space-before", "true"); + //interface.properties.set("brace-class-in-space-after", "true"); + interface.properties.set("brace-class-out-new-line-before", "true"); + interface.properties.set("brace-class-out-new-line-after", "true"); + //interface.properties.set("brace-class-out-space-before", "true"); + //interface.properties.set("brace-class-out-space-after", "true"); + etk::String outRef = "action_A;class MyClass\n{\n\taction_B;\n}\naction_D;"; + etk::String output = interface.process(source); + EXPECT_EQ(output, outRef); +} + +TEST(testClass, brace_1101) { + estyle::Generator interface; + interface.properties.set("brace-class-in-new-line-before", "true"); + interface.properties.set("brace-class-in-new-line-after", "true"); + //interface.properties.set("brace-class-in-space-before", "true"); + interface.properties.set("brace-class-in-space-after", "true"); + interface.properties.set("brace-class-out-new-line-before", "true"); + interface.properties.set("brace-class-out-new-line-after", "true"); + //interface.properties.set("brace-class-out-space-before", "true"); + interface.properties.set("brace-class-out-space-after", "true"); + etk::String outRef = "action_A;class MyClass\n{\n\taction_B;\n}\naction_D;"; + etk::String output = interface.process(source); + EXPECT_EQ(output, outRef); +} + +TEST(testClass, brace_1110) { + estyle::Generator interface; + interface.properties.set("brace-class-in-new-line-before", "true"); + interface.properties.set("brace-class-in-new-line-after", "true"); + interface.properties.set("brace-class-in-space-before", "true"); + //interface.properties.set("brace-class-in-space-after", "true"); + interface.properties.set("brace-class-out-new-line-before", "true"); + interface.properties.set("brace-class-out-new-line-after", "true"); + interface.properties.set("brace-class-out-space-before", "true"); + //interface.properties.set("brace-class-out-space-after", "true"); + etk::String outRef = "action_A;class MyClass\n{\n\taction_B;\n}\naction_D;"; + etk::String output = interface.process(source); + EXPECT_EQ(output, outRef); +} + +TEST(testClass, brace_1111) { + estyle::Generator interface; + interface.properties.set("brace-class-in-new-line-before", "true"); + interface.properties.set("brace-class-in-new-line-after", "true"); + interface.properties.set("brace-class-in-space-before", "true"); + interface.properties.set("brace-class-in-space-after", "true"); + interface.properties.set("brace-class-out-new-line-before", "true"); + interface.properties.set("brace-class-out-new-line-after", "true"); + interface.properties.set("brace-class-out-space-before", "true"); + interface.properties.set("brace-class-out-space-after", "true"); + etk::String outRef = "action_A;class MyClass\n{\n\taction_B;\n}\naction_D;"; + etk::String output = interface.process(source); + EXPECT_EQ(output, outRef); +} + +TEST(testClass, brace_1001) { + estyle::Generator interface; + interface.properties.set("brace-class-in-new-line-before", "true"); + //interface.properties.set("brace-class-in-new-line-after", "true"); + //interface.properties.set("brace-class-in-space-before", "true"); + interface.properties.set("brace-class-in-space-after", "true"); + interface.properties.set("brace-class-out-new-line-before", "true"); + //interface.properties.set("brace-class-out-new-line-after", "true"); + //interface.properties.set("brace-class-out-space-before", "true"); + interface.properties.set("brace-class-out-space-after", "true"); + etk::String outRef = "action_A;class MyClass\n{ action_B;\n} action_D;"; + etk::String output = interface.process(source); + EXPECT_EQ(output, outRef); +} + + +TEST(testClass, brace_0100) { + estyle::Generator interface; + //interface.properties.set("brace-class-in-new-line-before", "true"); + interface.properties.set("brace-class-in-new-line-after", "true"); + //interface.properties.set("brace-class-in-space-before", "true"); + //interface.properties.set("brace-class-in-space-after", "true"); + //interface.properties.set("brace-class-out-new-line-before", "true"); + interface.properties.set("brace-class-out-new-line-after", "true"); + //interface.properties.set("brace-class-out-space-before", "true"); + //interface.properties.set("brace-class-out-space-after", "true"); + etk::String outRef = "action_A;class MyClass{\n\taction_B;}\naction_D;"; + etk::String output = interface.process(source); + EXPECT_EQ(output, outRef); +} + +TEST(testClass, brace_0101) { + estyle::Generator interface; + //interface.properties.set("brace-class-in-new-line-before", "true"); + interface.properties.set("brace-class-in-new-line-after", "true"); + //interface.properties.set("brace-class-in-space-before", "true"); + interface.properties.set("brace-class-in-space-after", "true"); + //interface.properties.set("brace-class-out-new-line-before", "true"); + interface.properties.set("brace-class-out-new-line-after", "true"); + //interface.properties.set("brace-class-out-space-before", "true"); + interface.properties.set("brace-class-out-space-after", "true"); + etk::String outRef = "action_A;class MyClass{\n\taction_B;}\naction_D;"; + etk::String output = interface.process(source); + EXPECT_EQ(output, outRef); +} + +TEST(testClass, brace_0110) { + estyle::Generator interface; + //interface.properties.set("brace-class-in-new-line-before", "true"); + interface.properties.set("brace-class-in-new-line-after", "true"); + interface.properties.set("brace-class-in-space-before", "true"); + //interface.properties.set("brace-class-in-space-after", "true"); + //interface.properties.set("brace-class-out-new-line-before", "true"); + interface.properties.set("brace-class-out-new-line-after", "true"); + interface.properties.set("brace-class-out-space-before", "true"); + //interface.properties.set("brace-class-out-space-after", "true"); + etk::String outRef = "action_A;class MyClass {\n\taction_B; }\naction_D;"; + etk::String output = interface.process(source); + EXPECT_EQ(output, outRef); +} + +TEST(testClass, brace_0010) { + estyle::Generator interface; + //interface.properties.set("brace-class-in-new-line-before", "true"); + //interface.properties.set("brace-class-in-new-line-after", "true"); + interface.properties.set("brace-class-in-space-before", "true"); + //interface.properties.set("brace-class-in-space-after", "true"); + //interface.properties.set("brace-class-out-new-line-before", "true"); + //interface.properties.set("brace-class-out-new-line-after", "true"); + interface.properties.set("brace-class-out-space-before", "true"); + //interface.properties.set("brace-class-out-space-after", "true"); + etk::String outRef = "action_A;class MyClass {action_B; }action_D;"; + etk::String output = interface.process(source); + EXPECT_EQ(output, outRef); +} + +TEST(testClass, brace_0011) { + estyle::Generator interface; + //interface.properties.set("brace-class-in-new-line-before", "true"); + //interface.properties.set("brace-class-in-new-line-after", "true"); + interface.properties.set("brace-class-in-space-before", "true"); + interface.properties.set("brace-class-in-space-after", "true"); + //interface.properties.set("brace-class-out-new-line-before", "true"); + //interface.properties.set("brace-class-out-new-line-after", "true"); + interface.properties.set("brace-class-out-space-before", "true"); + interface.properties.set("brace-class-out-space-after", "true"); + etk::String outRef = "action_A;class MyClass { action_B; } action_D;"; + etk::String output = interface.process(source); + EXPECT_EQ(output, outRef); +} + +TEST(testClass, brace_0111) { + estyle::Generator interface; + //interface.properties.set("brace-class-in-new-line-before", "true"); + interface.properties.set("brace-class-in-new-line-after", "true"); + interface.properties.set("brace-class-in-space-before", "true"); + interface.properties.set("brace-class-in-space-after", "true"); + //interface.properties.set("brace-class-out-new-line-before", "true"); + interface.properties.set("brace-class-out-new-line-after", "true"); + interface.properties.set("brace-class-out-space-before", "true"); + interface.properties.set("brace-class-out-space-after", "true"); + etk::String outRef = "action_A;class MyClass {\n\taction_B; }\naction_D;"; + etk::String output = interface.process(source); + EXPECT_EQ(output, outRef); +} + +TEST(testClass, brace_0001) { + estyle::Generator interface; + //interface.properties.set("brace-class-in-new-line-before", "true"); + //interface.properties.set("brace-class-in-new-line-after", "true"); + //interface.properties.set("brace-class-in-space-before", "true"); + interface.properties.set("brace-class-in-space-after", "true"); + //interface.properties.set("brace-class-out-new-line-before", "true"); + //interface.properties.set("brace-class-out-new-line-after", "true"); + //interface.properties.set("brace-class-out-space-before", "true"); + interface.properties.set("brace-class-out-space-after", "true"); + etk::String outRef = "action_A;class MyClass{ action_B;} action_D;"; + etk::String output = interface.process(source); + EXPECT_EQ(output, outRef); +} + + diff --git a/test/testStruct.cpp b/test/testStruct.cpp index e69de29..97b4b49 100644 --- a/test/testStruct.cpp +++ b/test/testStruct.cpp @@ -0,0 +1,257 @@ +/** + * @author Edouard DUPIN + * @copyright 2017, Edouard DUPIN, all right reserved + * @license MPL-2 (see license file) + */ +#include +#include +#include +#include +#include +#include + +static etk::String source = "action_A;struct MyStruct{action_B;}action_D;"; + + +TEST(testStruct, brace_0000) { + estyle::Generator interface; + //interface.properties.set("brace-struct-in-new-line-before", "true"); + //interface.properties.set("brace-struct-in-new-line-after", "true"); + //interface.properties.set("brace-struct-in-space-before", "true"); + //interface.properties.set("brace-struct-in-space-after", "true"); + //interface.properties.set("brace-struct-out-new-line-before", "true"); + //interface.properties.set("brace-struct-out-new-line-after", "true"); + //interface.properties.set("brace-struct-out-space-before", "true"); + //interface.properties.set("brace-struct-out-space-after", "true"); + etk::String outRef = "action_A;struct MyStruct{action_B;}action_D;"; + etk::String output = interface.process(source); + EXPECT_EQ(output, outRef); +} + +TEST(testStruct, brace_1000) { + estyle::Generator interface; + interface.properties.set("brace-struct-in-new-line-before", "true"); + //interface.properties.set("brace-struct-in-new-line-after", "true"); + //interface.properties.set("brace-struct-in-space-before", "true"); + //interface.properties.set("brace-struct-in-space-after", "true"); + interface.properties.set("brace-struct-out-new-line-before", "true"); + //interface.properties.set("brace-struct-out-new-line-after", "true"); + //interface.properties.set("brace-struct-out-space-before", "true"); + //interface.properties.set("brace-struct-out-space-after", "true"); + etk::String outRef = "action_A;struct MyStruct\n{action_B;\n}action_D;"; + etk::String output = interface.process(source); + EXPECT_EQ(output, outRef); +} + +TEST(testStruct, brace_1010) { + estyle::Generator interface; + interface.properties.set("brace-struct-in-new-line-before", "true"); + //interface.properties.set("brace-struct-in-new-line-after", "true"); + interface.properties.set("brace-struct-in-space-before", "true"); + //interface.properties.set("brace-struct-in-space-after", "true"); + interface.properties.set("brace-struct-out-new-line-before", "true"); + //interface.properties.set("brace-struct-out-new-line-after", "true"); + interface.properties.set("brace-struct-out-space-before", "true"); + //interface.properties.set("brace-struct-out-space-after", "true"); + etk::String outRef = "action_A;struct MyStruct\n{action_B;\n}action_D;"; + etk::String output = interface.process(source); + EXPECT_EQ(output, outRef); +} + +TEST(testStruct, brace_1011) { + estyle::Generator interface; + interface.properties.set("brace-struct-in-new-line-before", "true"); + //interface.properties.set("brace-struct-in-new-line-after", "true"); + interface.properties.set("brace-struct-in-space-before", "true"); + interface.properties.set("brace-struct-in-space-after", "true"); + interface.properties.set("brace-struct-out-new-line-before", "true"); + //interface.properties.set("brace-struct-out-new-line-after", "true"); + interface.properties.set("brace-struct-out-space-before", "true"); + interface.properties.set("brace-struct-out-space-after", "true"); + etk::String outRef = "action_A;struct MyStruct\n{ action_B;\n} action_D;"; + etk::String output = interface.process(source); + EXPECT_EQ(output, outRef); +} + +TEST(testStruct, brace_1100) { + estyle::Generator interface; + interface.properties.set("brace-struct-in-new-line-before", "true"); + interface.properties.set("brace-struct-in-new-line-after", "true"); + //interface.properties.set("brace-struct-in-space-before", "true"); + //interface.properties.set("brace-struct-in-space-after", "true"); + interface.properties.set("brace-struct-out-new-line-before", "true"); + interface.properties.set("brace-struct-out-new-line-after", "true"); + //interface.properties.set("brace-struct-out-space-before", "true"); + //interface.properties.set("brace-struct-out-space-after", "true"); + etk::String outRef = "action_A;struct MyStruct\n{\n\taction_B;\n}\naction_D;"; + etk::String output = interface.process(source); + EXPECT_EQ(output, outRef); +} + +TEST(testStruct, brace_1101) { + estyle::Generator interface; + interface.properties.set("brace-struct-in-new-line-before", "true"); + interface.properties.set("brace-struct-in-new-line-after", "true"); + //interface.properties.set("brace-struct-in-space-before", "true"); + interface.properties.set("brace-struct-in-space-after", "true"); + interface.properties.set("brace-struct-out-new-line-before", "true"); + interface.properties.set("brace-struct-out-new-line-after", "true"); + //interface.properties.set("brace-struct-out-space-before", "true"); + interface.properties.set("brace-struct-out-space-after", "true"); + etk::String outRef = "action_A;struct MyStruct\n{\n\taction_B;\n}\naction_D;"; + etk::String output = interface.process(source); + EXPECT_EQ(output, outRef); +} + +TEST(testStruct, brace_1110) { + estyle::Generator interface; + interface.properties.set("brace-struct-in-new-line-before", "true"); + interface.properties.set("brace-struct-in-new-line-after", "true"); + interface.properties.set("brace-struct-in-space-before", "true"); + //interface.properties.set("brace-struct-in-space-after", "true"); + interface.properties.set("brace-struct-out-new-line-before", "true"); + interface.properties.set("brace-struct-out-new-line-after", "true"); + interface.properties.set("brace-struct-out-space-before", "true"); + //interface.properties.set("brace-struct-out-space-after", "true"); + etk::String outRef = "action_A;struct MyStruct\n{\n\taction_B;\n}\naction_D;"; + etk::String output = interface.process(source); + EXPECT_EQ(output, outRef); +} + +TEST(testStruct, brace_1111) { + estyle::Generator interface; + interface.properties.set("brace-struct-in-new-line-before", "true"); + interface.properties.set("brace-struct-in-new-line-after", "true"); + interface.properties.set("brace-struct-in-space-before", "true"); + interface.properties.set("brace-struct-in-space-after", "true"); + interface.properties.set("brace-struct-out-new-line-before", "true"); + interface.properties.set("brace-struct-out-new-line-after", "true"); + interface.properties.set("brace-struct-out-space-before", "true"); + interface.properties.set("brace-struct-out-space-after", "true"); + etk::String outRef = "action_A;struct MyStruct\n{\n\taction_B;\n}\naction_D;"; + etk::String output = interface.process(source); + EXPECT_EQ(output, outRef); +} + +TEST(testStruct, brace_1001) { + estyle::Generator interface; + interface.properties.set("brace-struct-in-new-line-before", "true"); + //interface.properties.set("brace-struct-in-new-line-after", "true"); + //interface.properties.set("brace-struct-in-space-before", "true"); + interface.properties.set("brace-struct-in-space-after", "true"); + interface.properties.set("brace-struct-out-new-line-before", "true"); + //interface.properties.set("brace-struct-out-new-line-after", "true"); + //interface.properties.set("brace-struct-out-space-before", "true"); + interface.properties.set("brace-struct-out-space-after", "true"); + etk::String outRef = "action_A;struct MyStruct\n{ action_B;\n} action_D;"; + etk::String output = interface.process(source); + EXPECT_EQ(output, outRef); +} + + +TEST(testStruct, brace_0100) { + estyle::Generator interface; + //interface.properties.set("brace-struct-in-new-line-before", "true"); + interface.properties.set("brace-struct-in-new-line-after", "true"); + //interface.properties.set("brace-struct-in-space-before", "true"); + //interface.properties.set("brace-struct-in-space-after", "true"); + //interface.properties.set("brace-struct-out-new-line-before", "true"); + interface.properties.set("brace-struct-out-new-line-after", "true"); + //interface.properties.set("brace-struct-out-space-before", "true"); + //interface.properties.set("brace-struct-out-space-after", "true"); + etk::String outRef = "action_A;struct MyStruct{\n\taction_B;}\naction_D;"; + etk::String output = interface.process(source); + EXPECT_EQ(output, outRef); +} + +TEST(testStruct, brace_0101) { + estyle::Generator interface; + //interface.properties.set("brace-struct-in-new-line-before", "true"); + interface.properties.set("brace-struct-in-new-line-after", "true"); + //interface.properties.set("brace-struct-in-space-before", "true"); + interface.properties.set("brace-struct-in-space-after", "true"); + //interface.properties.set("brace-struct-out-new-line-before", "true"); + interface.properties.set("brace-struct-out-new-line-after", "true"); + //interface.properties.set("brace-struct-out-space-before", "true"); + interface.properties.set("brace-struct-out-space-after", "true"); + etk::String outRef = "action_A;struct MyStruct{\n\taction_B;}\naction_D;"; + etk::String output = interface.process(source); + EXPECT_EQ(output, outRef); +} + +TEST(testStruct, brace_0110) { + estyle::Generator interface; + //interface.properties.set("brace-struct-in-new-line-before", "true"); + interface.properties.set("brace-struct-in-new-line-after", "true"); + interface.properties.set("brace-struct-in-space-before", "true"); + //interface.properties.set("brace-struct-in-space-after", "true"); + //interface.properties.set("brace-struct-out-new-line-before", "true"); + interface.properties.set("brace-struct-out-new-line-after", "true"); + interface.properties.set("brace-struct-out-space-before", "true"); + //interface.properties.set("brace-struct-out-space-after", "true"); + etk::String outRef = "action_A;struct MyStruct {\n\taction_B; }\naction_D;"; + etk::String output = interface.process(source); + EXPECT_EQ(output, outRef); +} + +TEST(testStruct, brace_0010) { + estyle::Generator interface; + //interface.properties.set("brace-struct-in-new-line-before", "true"); + //interface.properties.set("brace-struct-in-new-line-after", "true"); + interface.properties.set("brace-struct-in-space-before", "true"); + //interface.properties.set("brace-struct-in-space-after", "true"); + //interface.properties.set("brace-struct-out-new-line-before", "true"); + //interface.properties.set("brace-struct-out-new-line-after", "true"); + interface.properties.set("brace-struct-out-space-before", "true"); + //interface.properties.set("brace-struct-out-space-after", "true"); + etk::String outRef = "action_A;struct MyStruct {action_B; }action_D;"; + etk::String output = interface.process(source); + EXPECT_EQ(output, outRef); +} + +TEST(testStruct, brace_0011) { + estyle::Generator interface; + //interface.properties.set("brace-struct-in-new-line-before", "true"); + //interface.properties.set("brace-struct-in-new-line-after", "true"); + interface.properties.set("brace-struct-in-space-before", "true"); + interface.properties.set("brace-struct-in-space-after", "true"); + //interface.properties.set("brace-struct-out-new-line-before", "true"); + //interface.properties.set("brace-struct-out-new-line-after", "true"); + interface.properties.set("brace-struct-out-space-before", "true"); + interface.properties.set("brace-struct-out-space-after", "true"); + etk::String outRef = "action_A;struct MyStruct { action_B; } action_D;"; + etk::String output = interface.process(source); + EXPECT_EQ(output, outRef); +} + +TEST(testStruct, brace_0111) { + estyle::Generator interface; + //interface.properties.set("brace-struct-in-new-line-before", "true"); + interface.properties.set("brace-struct-in-new-line-after", "true"); + interface.properties.set("brace-struct-in-space-before", "true"); + interface.properties.set("brace-struct-in-space-after", "true"); + //interface.properties.set("brace-struct-out-new-line-before", "true"); + interface.properties.set("brace-struct-out-new-line-after", "true"); + interface.properties.set("brace-struct-out-space-before", "true"); + interface.properties.set("brace-struct-out-space-after", "true"); + etk::String outRef = "action_A;struct MyStruct {\n\taction_B; }\naction_D;"; + etk::String output = interface.process(source); + EXPECT_EQ(output, outRef); +} + +TEST(testStruct, brace_0001) { + estyle::Generator interface; + //interface.properties.set("brace-struct-in-new-line-before", "true"); + //interface.properties.set("brace-struct-in-new-line-after", "true"); + //interface.properties.set("brace-struct-in-space-before", "true"); + interface.properties.set("brace-struct-in-space-after", "true"); + //interface.properties.set("brace-struct-out-new-line-before", "true"); + //interface.properties.set("brace-struct-out-new-line-after", "true"); + //interface.properties.set("brace-struct-out-space-before", "true"); + interface.properties.set("brace-struct-out-space-after", "true"); + etk::String outRef = "action_A;struct MyStruct{ action_B;} action_D;"; + etk::String output = interface.process(source); + EXPECT_EQ(output, outRef); +} + + diff --git a/test/testWhile.cpp b/test/testWhile.cpp index 62ce57b..816a8d8 100644 --- a/test/testWhile.cpp +++ b/test/testWhile.cpp @@ -436,7 +436,7 @@ TEST(testWhile, condition_1) { EXPECT_EQ(output, outRef); interface.properties.set("condition-while-multi-line-big-size", "20"); output = interface.process(base); - outRef = "action_A;while ( condition<6\n && my_stupid_variable==77 ){action_B;}action_D;"; + outRef = "action_A;while( condition<6\n && my_stupid_variable==77){action_B;}action_D;"; EXPECT_EQ(output, outRef); }