/** * @author Edouard DUPIN * @copyright 2017, Edouard DUPIN, all right reserved * @license MPL-2 (see license file) */ #include #include #include #include #include #include etk::String sourceIf1Action = "action_A;if(true){action_B;}action_D;"; etk::String sourceIf1ActionNoBrace = "action_A;if(true)action_B;action_D;"; etk::String sourceIf2Action = "action_A;if(true){action_B;action_C;}action_D;"; TEST(testBraceIf, brace_if_0000) { estyle::Generator interface; //interface.properties.set("brace-if-in-new-line-before", "true"); //interface.properties.set("brace-if-in-new-line-after", "true"); //interface.properties.set("brace-if-in-space-before", "true"); //interface.properties.set("brace-if-in-space-after", "true"); //interface.properties.set("brace-if-out-new-line-before", "true"); //interface.properties.set("brace-if-out-new-line-after", "true"); //interface.properties.set("brace-if-out-space-before", "true"); //interface.properties.set("brace-if-out-space-after", "true"); //interface.properties.set("brace-if-single", "true"); etk::String outputRef = "action_A;\nif (true ){action_B;}action_D;"; etk::String output = interface.process(sourceIf1Action); EXPECT_EQ(output, outputRef); output = interface.process(sourceIf1ActionNoBrace); EXPECT_EQ(output, outputRef); } TEST(testBraceIf, brace_if_1000) { estyle::Generator interface; interface.properties.set("brace-if-in-new-line-before", "true"); //interface.properties.set("brace-if-in-new-line-after", "true"); //interface.properties.set("brace-if-in-space-before", "true"); //interface.properties.set("brace-if-in-space-after", "true"); interface.properties.set("brace-if-out-new-line-before", "true"); //interface.properties.set("brace-if-out-new-line-after", "true"); //interface.properties.set("brace-if-out-space-before", "true"); //interface.properties.set("brace-if-out-space-after", "true"); //interface.properties.set("brace-if-single", "true"); etk::String outputRef = "action_A;\nif (true )\n{action_B;\n}action_D;"; etk::String output = interface.process(sourceIf1Action); EXPECT_EQ(output, outputRef); output = interface.process(sourceIf1ActionNoBrace); EXPECT_EQ(output, outputRef); } TEST(testBraceIf, brace_if_1010) { estyle::Generator interface; interface.properties.set("brace-if-in-new-line-before", "true"); //interface.properties.set("brace-if-in-new-line-after", "true"); interface.properties.set("brace-if-in-space-before", "true"); //interface.properties.set("brace-if-in-space-after", "true"); interface.properties.set("brace-if-out-new-line-before", "true"); //interface.properties.set("brace-if-out-new-line-after", "true"); interface.properties.set("brace-if-out-space-before", "true"); //interface.properties.set("brace-if-out-space-after", "true"); //interface.properties.set("brace-if-single", "true"); etk::String outputRef = "action_A;\nif (true )\n{action_B;\n}action_D;"; etk::String output = interface.process(sourceIf1Action); EXPECT_EQ(output, outputRef); output = interface.process(sourceIf1ActionNoBrace); EXPECT_EQ(output, outputRef); } TEST(testBraceIf, brace_if_1011) { estyle::Generator interface; interface.properties.set("brace-if-in-new-line-before", "true"); //interface.properties.set("brace-if-in-new-line-after", "true"); interface.properties.set("brace-if-in-space-before", "true"); interface.properties.set("brace-if-in-space-after", "true"); interface.properties.set("brace-if-out-new-line-before", "true"); //interface.properties.set("brace-if-out-new-line-after", "true"); interface.properties.set("brace-if-out-space-before", "true"); interface.properties.set("brace-if-out-space-after", "true"); //interface.properties.set("brace-if-single", "true"); etk::String outputRef = "action_A;\nif (true )\n{ action_B;\n} action_D;"; etk::String output = interface.process(sourceIf1Action); EXPECT_EQ(output, outputRef); output = interface.process(sourceIf1ActionNoBrace); EXPECT_EQ(output, outputRef); } TEST(testBraceIf, brace_if_1100) { estyle::Generator interface; interface.properties.set("brace-if-in-new-line-before", "true"); interface.properties.set("brace-if-in-new-line-after", "true"); //interface.properties.set("brace-if-in-space-before", "true"); //interface.properties.set("brace-if-in-space-after", "true"); interface.properties.set("brace-if-out-new-line-before", "true"); interface.properties.set("brace-if-out-new-line-after", "true"); //interface.properties.set("brace-if-out-space-before", "true"); //interface.properties.set("brace-if-out-space-after", "true"); //interface.properties.set("brace-if-single", "true"); etk::String outputRef = "action_A;\nif (true )\n{\n\taction_B;\n}\naction_D;"; etk::String output = interface.process(sourceIf1Action); EXPECT_EQ(output, outputRef); output = interface.process(sourceIf1ActionNoBrace); EXPECT_EQ(output, outputRef); } TEST(testBraceIf, brace_if_1101) { estyle::Generator interface; interface.properties.set("brace-if-in-new-line-before", "true"); interface.properties.set("brace-if-in-new-line-after", "true"); //interface.properties.set("brace-if-in-space-before", "true"); interface.properties.set("brace-if-in-space-after", "true"); interface.properties.set("brace-if-out-new-line-before", "true"); interface.properties.set("brace-if-out-new-line-after", "true"); //interface.properties.set("brace-if-out-space-before", "true"); interface.properties.set("brace-if-out-space-after", "true"); //interface.properties.set("brace-if-single", "true"); etk::String outputRef = "action_A;\nif (true )\n{ \n\taction_B;\n} \naction_D;"; etk::String output = interface.process(sourceIf1Action); EXPECT_EQ(output, outputRef); output = interface.process(sourceIf1ActionNoBrace); EXPECT_EQ(output, outputRef); } TEST(testBraceIf, brace_if_1110) { estyle::Generator interface; interface.properties.set("brace-if-in-new-line-before", "true"); interface.properties.set("brace-if-in-new-line-after", "true"); interface.properties.set("brace-if-in-space-before", "true"); //interface.properties.set("brace-if-in-space-after", "true"); interface.properties.set("brace-if-out-new-line-before", "true"); interface.properties.set("brace-if-out-new-line-after", "true"); interface.properties.set("brace-if-out-space-before", "true"); //interface.properties.set("brace-if-out-space-after", "true"); //interface.properties.set("brace-if-single", "true"); etk::String outputRef = "action_A;\nif (true )\n{\n\taction_B;\n}\naction_D;"; etk::String output = interface.process(sourceIf1Action); EXPECT_EQ(output, outputRef); output = interface.process(sourceIf1ActionNoBrace); EXPECT_EQ(output, outputRef); } TEST(testBraceIf, brace_if_1111) { estyle::Generator interface; interface.properties.set("brace-if-in-new-line-before", "true"); interface.properties.set("brace-if-in-new-line-after", "true"); interface.properties.set("brace-if-in-space-before", "true"); interface.properties.set("brace-if-in-space-after", "true"); interface.properties.set("brace-if-out-new-line-before", "true"); interface.properties.set("brace-if-out-new-line-after", "true"); interface.properties.set("brace-if-out-space-before", "true"); interface.properties.set("brace-if-out-space-after", "true"); //interface.properties.set("brace-if-single", "true"); etk::String outputRef = "action_A;\nif (true )\n{ \n\taction_B;\n} \naction_D;"; etk::String output = interface.process(sourceIf1Action); EXPECT_EQ(output, outputRef); output = interface.process(sourceIf1ActionNoBrace); EXPECT_EQ(output, outputRef); } TEST(testBraceIf, brace_if_1001) { estyle::Generator interface; interface.properties.set("brace-if-in-new-line-before", "true"); //interface.properties.set("brace-if-in-new-line-after", "true"); //interface.properties.set("brace-if-in-space-before", "true"); interface.properties.set("brace-if-in-space-after", "true"); interface.properties.set("brace-if-out-new-line-before", "true"); //interface.properties.set("brace-if-out-new-line-after", "true"); //interface.properties.set("brace-if-out-space-before", "true"); interface.properties.set("brace-if-out-space-after", "true"); //interface.properties.set("brace-if-single", "true"); etk::String outputRef = "action_A;\nif (true )\n{ action_B;\n} action_D;"; etk::String output = interface.process(sourceIf1Action); EXPECT_EQ(output, outputRef); output = interface.process(sourceIf1ActionNoBrace); EXPECT_EQ(output, outputRef); } TEST(testBraceIf, brace_if_0100) { estyle::Generator interface; //interface.properties.set("brace-if-in-new-line-before", "true"); interface.properties.set("brace-if-in-new-line-after", "true"); //interface.properties.set("brace-if-in-space-before", "true"); //interface.properties.set("brace-if-in-space-after", "true"); //interface.properties.set("brace-if-out-new-line-before", "true"); interface.properties.set("brace-if-out-new-line-after", "true"); //interface.properties.set("brace-if-out-space-before", "true"); //interface.properties.set("brace-if-out-space-after", "true"); //interface.properties.set("brace-if-single", "true"); etk::String outputRef = "action_A;\nif (true ){\n\taction_B;}\naction_D;"; etk::String output = interface.process(sourceIf1Action); EXPECT_EQ(output, outputRef); output = interface.process(sourceIf1ActionNoBrace); EXPECT_EQ(output, outputRef); } TEST(testBraceIf, brace_if_0101) { estyle::Generator interface; //interface.properties.set("brace-if-in-new-line-before", "true"); interface.properties.set("brace-if-in-new-line-after", "true"); //interface.properties.set("brace-if-in-space-before", "true"); interface.properties.set("brace-if-in-space-after", "true"); //interface.properties.set("brace-if-out-new-line-before", "true"); interface.properties.set("brace-if-out-new-line-after", "true"); //interface.properties.set("brace-if-out-space-before", "true"); interface.properties.set("brace-if-out-space-after", "true"); //interface.properties.set("brace-if-single", "true"); etk::String outputRef = "action_A;\nif (true ){ \n\taction_B;} \naction_D;"; etk::String output = interface.process(sourceIf1Action); EXPECT_EQ(output, outputRef); output = interface.process(sourceIf1ActionNoBrace); EXPECT_EQ(output, outputRef); } TEST(testBraceIf, brace_if_0110) { estyle::Generator interface; //interface.properties.set("brace-if-in-new-line-before", "true"); interface.properties.set("brace-if-in-new-line-after", "true"); interface.properties.set("brace-if-in-space-before", "true"); //interface.properties.set("brace-if-in-space-after", "true"); //interface.properties.set("brace-if-out-new-line-before", "true"); interface.properties.set("brace-if-out-new-line-after", "true"); interface.properties.set("brace-if-out-space-before", "true"); //interface.properties.set("brace-if-out-space-after", "true"); //interface.properties.set("brace-if-single", "true"); etk::String outputRef = "action_A;\nif (true ) {\n\taction_B; }\naction_D;"; etk::String output = interface.process(sourceIf1Action); EXPECT_EQ(output, outputRef); output = interface.process(sourceIf1ActionNoBrace); EXPECT_EQ(output, outputRef); } TEST(testBraceIf, brace_if_0010) { estyle::Generator interface; //interface.properties.set("brace-if-in-new-line-before", "true"); //interface.properties.set("brace-if-in-new-line-after", "true"); interface.properties.set("brace-if-in-space-before", "true"); //interface.properties.set("brace-if-in-space-after", "true"); //interface.properties.set("brace-if-out-new-line-before", "true"); //interface.properties.set("brace-if-out-new-line-after", "true"); interface.properties.set("brace-if-out-space-before", "true"); //interface.properties.set("brace-if-out-space-after", "true"); //interface.properties.set("brace-if-single", "true"); etk::String outputRef = "action_A;\nif (true ) {action_B; }action_D;"; etk::String output = interface.process(sourceIf1Action); EXPECT_EQ(output, outputRef); output = interface.process(sourceIf1ActionNoBrace); EXPECT_EQ(output, outputRef); } TEST(testBraceIf, brace_if_0011) { estyle::Generator interface; //interface.properties.set("brace-if-in-new-line-before", "true"); //interface.properties.set("brace-if-in-new-line-after", "true"); interface.properties.set("brace-if-in-space-before", "true"); interface.properties.set("brace-if-in-space-after", "true"); //interface.properties.set("brace-if-out-new-line-before", "true"); //interface.properties.set("brace-if-out-new-line-after", "true"); interface.properties.set("brace-if-out-space-before", "true"); interface.properties.set("brace-if-out-space-after", "true"); //interface.properties.set("brace-if-single", "true"); etk::String outputRef = "action_A;\nif (true ) { action_B; } action_D;"; etk::String output = interface.process(sourceIf1Action); EXPECT_EQ(output, outputRef); output = interface.process(sourceIf1ActionNoBrace); EXPECT_EQ(output, outputRef); } TEST(testBraceIf, brace_if_0111) { estyle::Generator interface; //interface.properties.set("brace-if-in-new-line-before", "true"); interface.properties.set("brace-if-in-new-line-after", "true"); interface.properties.set("brace-if-in-space-before", "true"); interface.properties.set("brace-if-in-space-after", "true"); //interface.properties.set("brace-if-out-new-line-before", "true"); interface.properties.set("brace-if-out-new-line-after", "true"); interface.properties.set("brace-if-out-space-before", "true"); interface.properties.set("brace-if-out-space-after", "true"); //interface.properties.set("brace-if-single", "true"); etk::String outputRef = "action_A;\nif (true ) { \n\taction_B; } \naction_D;"; etk::String output = interface.process(sourceIf1Action); EXPECT_EQ(output, outputRef); output = interface.process(sourceIf1ActionNoBrace); EXPECT_EQ(output, outputRef); } TEST(testBraceIf, brace_if_0001) { estyle::Generator interface; //interface.properties.set("brace-if-in-new-line-before", "true"); //interface.properties.set("brace-if-in-new-line-after", "true"); //interface.properties.set("brace-if-in-space-before", "true"); interface.properties.set("brace-if-in-space-after", "true"); //interface.properties.set("brace-if-out-new-line-before", "true"); //interface.properties.set("brace-if-out-new-line-after", "true"); //interface.properties.set("brace-if-out-space-before", "true"); interface.properties.set("brace-if-out-space-after", "true"); //interface.properties.set("brace-if-single", "true"); etk::String outputRef = "action_A;\nif (true ){ action_B;} action_D;"; etk::String output = interface.process(sourceIf1Action); EXPECT_EQ(output, outputRef); output = interface.process(sourceIf1ActionNoBrace); EXPECT_EQ(output, outputRef); }