/** * @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 sourceFor1Action = "action_A;for(;;){action_B;}action_D;"; static etk::String sourceFor1ActionNoBrace = "action_A;for(;;)action_B;action_D;"; static etk::String sourceFor2Action = "action_A;for(;;){action_B;action_C;}action_D;"; TEST(testFor, brace_for_0000) { estyle::Generator interface; //interface.properties.set("brace-for-in-new-line-before", "true"); //interface.properties.set("brace-for-in-new-line-after", "true"); //interface.properties.set("brace-for-in-space-before", "true"); //interface.properties.set("brace-for-in-space-after", "true"); //interface.properties.set("brace-for-out-new-line-before", "true"); //interface.properties.set("brace-for-out-new-line-after", "true"); //interface.properties.set("brace-for-out-space-before", "true"); //interface.properties.set("brace-for-out-space-after", "true"); //interface.properties.set("brace-for-single", "true"); etk::String outputRef = "action_A;\nfor (;;){action_B;}action_D;"; etk::String output = interface.process(sourceFor1Action); EXPECT_EQ(output, outputRef); output = interface.process(sourceFor1ActionNoBrace); EXPECT_EQ(output, outputRef); } TEST(testFor, brace_for_1000) { estyle::Generator interface; interface.properties.set("brace-for-in-new-line-before", "true"); //interface.properties.set("brace-for-in-new-line-after", "true"); //interface.properties.set("brace-for-in-space-before", "true"); //interface.properties.set("brace-for-in-space-after", "true"); interface.properties.set("brace-for-out-new-line-before", "true"); //interface.properties.set("brace-for-out-new-line-after", "true"); //interface.properties.set("brace-for-out-space-before", "true"); //interface.properties.set("brace-for-out-space-after", "true"); //interface.properties.set("brace-for-single", "true"); etk::String outputRef = "action_A;\nfor (;;)\n{action_B;\n}action_D;"; etk::String output = interface.process(sourceFor1Action); EXPECT_EQ(output, outputRef); output = interface.process(sourceFor1ActionNoBrace); EXPECT_EQ(output, outputRef); } TEST(testFor, brace_for_1010) { estyle::Generator interface; interface.properties.set("brace-for-in-new-line-before", "true"); //interface.properties.set("brace-for-in-new-line-after", "true"); interface.properties.set("brace-for-in-space-before", "true"); //interface.properties.set("brace-for-in-space-after", "true"); interface.properties.set("brace-for-out-new-line-before", "true"); //interface.properties.set("brace-for-out-new-line-after", "true"); interface.properties.set("brace-for-out-space-before", "true"); //interface.properties.set("brace-for-out-space-after", "true"); //interface.properties.set("brace-for-single", "true"); etk::String outputRef = "action_A;\nfor (;;)\n{action_B;\n}action_D;"; etk::String output = interface.process(sourceFor1Action); EXPECT_EQ(output, outputRef); output = interface.process(sourceFor1ActionNoBrace); EXPECT_EQ(output, outputRef); } TEST(testFor, brace_for_1011) { estyle::Generator interface; interface.properties.set("brace-for-in-new-line-before", "true"); //interface.properties.set("brace-for-in-new-line-after", "true"); interface.properties.set("brace-for-in-space-before", "true"); interface.properties.set("brace-for-in-space-after", "true"); interface.properties.set("brace-for-out-new-line-before", "true"); //interface.properties.set("brace-for-out-new-line-after", "true"); interface.properties.set("brace-for-out-space-before", "true"); interface.properties.set("brace-for-out-space-after", "true"); //interface.properties.set("brace-for-single", "true"); etk::String outputRef = "action_A;\nfor (;;)\n{ action_B;\n} action_D;"; etk::String output = interface.process(sourceFor1Action); EXPECT_EQ(output, outputRef); output = interface.process(sourceFor1ActionNoBrace); EXPECT_EQ(output, outputRef); } TEST(testFor, brace_for_1100) { estyle::Generator interface; interface.properties.set("brace-for-in-new-line-before", "true"); interface.properties.set("brace-for-in-new-line-after", "true"); //interface.properties.set("brace-for-in-space-before", "true"); //interface.properties.set("brace-for-in-space-after", "true"); interface.properties.set("brace-for-out-new-line-before", "true"); interface.properties.set("brace-for-out-new-line-after", "true"); //interface.properties.set("brace-for-out-space-before", "true"); //interface.properties.set("brace-for-out-space-after", "true"); //interface.properties.set("brace-for-single", "true"); etk::String outputRef = "action_A;\nfor (;;)\n{\n\taction_B;\n}\naction_D;"; etk::String output = interface.process(sourceFor1Action); EXPECT_EQ(output, outputRef); output = interface.process(sourceFor1ActionNoBrace); EXPECT_EQ(output, outputRef); } TEST(testFor, brace_for_1101) { estyle::Generator interface; interface.properties.set("brace-for-in-new-line-before", "true"); interface.properties.set("brace-for-in-new-line-after", "true"); //interface.properties.set("brace-for-in-space-before", "true"); interface.properties.set("brace-for-in-space-after", "true"); interface.properties.set("brace-for-out-new-line-before", "true"); interface.properties.set("brace-for-out-new-line-after", "true"); //interface.properties.set("brace-for-out-space-before", "true"); interface.properties.set("brace-for-out-space-after", "true"); //interface.properties.set("brace-for-single", "true"); etk::String outputRef = "action_A;\nfor (;;)\n{\n\taction_B;\n}\naction_D;"; etk::String output = interface.process(sourceFor1Action); EXPECT_EQ(output, outputRef); output = interface.process(sourceFor1ActionNoBrace); EXPECT_EQ(output, outputRef); } TEST(testFor, brace_for_1110) { estyle::Generator interface; interface.properties.set("brace-for-in-new-line-before", "true"); interface.properties.set("brace-for-in-new-line-after", "true"); interface.properties.set("brace-for-in-space-before", "true"); //interface.properties.set("brace-for-in-space-after", "true"); interface.properties.set("brace-for-out-new-line-before", "true"); interface.properties.set("brace-for-out-new-line-after", "true"); interface.properties.set("brace-for-out-space-before", "true"); //interface.properties.set("brace-for-out-space-after", "true"); //interface.properties.set("brace-for-single", "true"); etk::String outputRef = "action_A;\nfor (;;)\n{\n\taction_B;\n}\naction_D;"; etk::String output = interface.process(sourceFor1Action); EXPECT_EQ(output, outputRef); output = interface.process(sourceFor1ActionNoBrace); EXPECT_EQ(output, outputRef); } TEST(testFor, brace_for_1111) { estyle::Generator interface; interface.properties.set("brace-for-in-new-line-before", "true"); interface.properties.set("brace-for-in-new-line-after", "true"); interface.properties.set("brace-for-in-space-before", "true"); interface.properties.set("brace-for-in-space-after", "true"); interface.properties.set("brace-for-out-new-line-before", "true"); interface.properties.set("brace-for-out-new-line-after", "true"); interface.properties.set("brace-for-out-space-before", "true"); interface.properties.set("brace-for-out-space-after", "true"); //interface.properties.set("brace-for-single", "true"); etk::String outputRef = "action_A;\nfor (;;)\n{\n\taction_B;\n}\naction_D;"; etk::String output = interface.process(sourceFor1Action); EXPECT_EQ(output, outputRef); output = interface.process(sourceFor1ActionNoBrace); EXPECT_EQ(output, outputRef); } TEST(testFor, brace_for_1001) { estyle::Generator interface; interface.properties.set("brace-for-in-new-line-before", "true"); //interface.properties.set("brace-for-in-new-line-after", "true"); //interface.properties.set("brace-for-in-space-before", "true"); interface.properties.set("brace-for-in-space-after", "true"); interface.properties.set("brace-for-out-new-line-before", "true"); //interface.properties.set("brace-for-out-new-line-after", "true"); //interface.properties.set("brace-for-out-space-before", "true"); interface.properties.set("brace-for-out-space-after", "true"); //interface.properties.set("brace-for-single", "true"); etk::String outputRef = "action_A;\nfor (;;)\n{ action_B;\n} action_D;"; etk::String output = interface.process(sourceFor1Action); EXPECT_EQ(output, outputRef); output = interface.process(sourceFor1ActionNoBrace); EXPECT_EQ(output, outputRef); } TEST(testFor, brace_for_0100) { estyle::Generator interface; //interface.properties.set("brace-for-in-new-line-before", "true"); interface.properties.set("brace-for-in-new-line-after", "true"); //interface.properties.set("brace-for-in-space-before", "true"); //interface.properties.set("brace-for-in-space-after", "true"); //interface.properties.set("brace-for-out-new-line-before", "true"); interface.properties.set("brace-for-out-new-line-after", "true"); //interface.properties.set("brace-for-out-space-before", "true"); //interface.properties.set("brace-for-out-space-after", "true"); //interface.properties.set("brace-for-single", "true"); etk::String outputRef = "action_A;\nfor (;;){\n\taction_B;}\naction_D;"; etk::String output = interface.process(sourceFor1Action); EXPECT_EQ(output, outputRef); output = interface.process(sourceFor1ActionNoBrace); EXPECT_EQ(output, outputRef); } TEST(testFor, brace_for_0101) { estyle::Generator interface; //interface.properties.set("brace-for-in-new-line-before", "true"); interface.properties.set("brace-for-in-new-line-after", "true"); //interface.properties.set("brace-for-in-space-before", "true"); interface.properties.set("brace-for-in-space-after", "true"); //interface.properties.set("brace-for-out-new-line-before", "true"); interface.properties.set("brace-for-out-new-line-after", "true"); //interface.properties.set("brace-for-out-space-before", "true"); interface.properties.set("brace-for-out-space-after", "true"); //interface.properties.set("brace-for-single", "true"); etk::String outputRef = "action_A;\nfor (;;){\n\taction_B;}\naction_D;"; etk::String output = interface.process(sourceFor1Action); EXPECT_EQ(output, outputRef); output = interface.process(sourceFor1ActionNoBrace); EXPECT_EQ(output, outputRef); } TEST(testFor, brace_for_0110) { estyle::Generator interface; //interface.properties.set("brace-for-in-new-line-before", "true"); interface.properties.set("brace-for-in-new-line-after", "true"); interface.properties.set("brace-for-in-space-before", "true"); //interface.properties.set("brace-for-in-space-after", "true"); //interface.properties.set("brace-for-out-new-line-before", "true"); interface.properties.set("brace-for-out-new-line-after", "true"); interface.properties.set("brace-for-out-space-before", "true"); //interface.properties.set("brace-for-out-space-after", "true"); //interface.properties.set("brace-for-single", "true"); etk::String outputRef = "action_A;\nfor (;;) {\n\taction_B; }\naction_D;"; etk::String output = interface.process(sourceFor1Action); EXPECT_EQ(output, outputRef); output = interface.process(sourceFor1ActionNoBrace); EXPECT_EQ(output, outputRef); } TEST(testFor, brace_for_0010) { estyle::Generator interface; //interface.properties.set("brace-for-in-new-line-before", "true"); //interface.properties.set("brace-for-in-new-line-after", "true"); interface.properties.set("brace-for-in-space-before", "true"); //interface.properties.set("brace-for-in-space-after", "true"); //interface.properties.set("brace-for-out-new-line-before", "true"); //interface.properties.set("brace-for-out-new-line-after", "true"); interface.properties.set("brace-for-out-space-before", "true"); //interface.properties.set("brace-for-out-space-after", "true"); //interface.properties.set("brace-for-single", "true"); etk::String outputRef = "action_A;\nfor (;;) {action_B; }action_D;"; etk::String output = interface.process(sourceFor1Action); EXPECT_EQ(output, outputRef); output = interface.process(sourceFor1ActionNoBrace); EXPECT_EQ(output, outputRef); } TEST(testFor, brace_for_0011) { estyle::Generator interface; //interface.properties.set("brace-for-in-new-line-before", "true"); //interface.properties.set("brace-for-in-new-line-after", "true"); interface.properties.set("brace-for-in-space-before", "true"); interface.properties.set("brace-for-in-space-after", "true"); //interface.properties.set("brace-for-out-new-line-before", "true"); //interface.properties.set("brace-for-out-new-line-after", "true"); interface.properties.set("brace-for-out-space-before", "true"); interface.properties.set("brace-for-out-space-after", "true"); //interface.properties.set("brace-for-single", "true"); etk::String outputRef = "action_A;\nfor (;;) { action_B; } action_D;"; etk::String output = interface.process(sourceFor1Action); EXPECT_EQ(output, outputRef); output = interface.process(sourceFor1ActionNoBrace); EXPECT_EQ(output, outputRef); } TEST(testFor, brace_for_0111) { estyle::Generator interface; //interface.properties.set("brace-for-in-new-line-before", "true"); interface.properties.set("brace-for-in-new-line-after", "true"); interface.properties.set("brace-for-in-space-before", "true"); interface.properties.set("brace-for-in-space-after", "true"); //interface.properties.set("brace-for-out-new-line-before", "true"); interface.properties.set("brace-for-out-new-line-after", "true"); interface.properties.set("brace-for-out-space-before", "true"); interface.properties.set("brace-for-out-space-after", "true"); //interface.properties.set("brace-for-single", "true"); etk::String outputRef = "action_A;\nfor (;;) {\n\taction_B; }\naction_D;"; etk::String output = interface.process(sourceFor1Action); EXPECT_EQ(output, outputRef); output = interface.process(sourceFor1ActionNoBrace); EXPECT_EQ(output, outputRef); } TEST(testFor, brace_for_0001) { estyle::Generator interface; //interface.properties.set("brace-for-in-new-line-before", "true"); //interface.properties.set("brace-for-in-new-line-after", "true"); //interface.properties.set("brace-for-in-space-before", "true"); interface.properties.set("brace-for-in-space-after", "true"); //interface.properties.set("brace-for-out-new-line-before", "true"); //interface.properties.set("brace-for-out-new-line-after", "true"); //interface.properties.set("brace-for-out-space-before", "true"); interface.properties.set("brace-for-out-space-after", "true"); //interface.properties.set("brace-for-single", "true"); etk::String outputRef = "action_A;\nfor (;;){ action_B;} action_D;"; etk::String output = interface.process(sourceFor1Action); EXPECT_EQ(output, outputRef); output = interface.process(sourceFor1ActionNoBrace); EXPECT_EQ(output, outputRef); } TEST(testFor, brace_for_single_00) { estyle::Generator interface; //interface.properties.set("brace-for-single-one-line-size-max", "40"); interface.properties.set("brace-for-single", "true"); //interface.properties.set("brace-for-single-in-new-line", "true"); //interface.properties.set("brace-for-single-in-space", "true"); //interface.properties.set("brace-for-single-out-new-line", "true"); //interface.properties.set("brace-for-single-out-space", "true"); etk::String outputRef = "action_A;\nfor (;;)action_B;\naction_D;"; etk::String output = interface.process(sourceFor1Action); EXPECT_EQ(output, outputRef); output = interface.process(sourceFor1ActionNoBrace); EXPECT_EQ(output, outputRef); } TEST(testFor, brace_for_single_10) { estyle::Generator interface; //interface.properties.set("brace-for-single-one-line-size-max", "40"); interface.properties.set("brace-for-single", "true"); interface.properties.set("brace-for-single-in-new-line", "true"); //interface.properties.set("brace-for-single-in-space", "true"); interface.properties.set("brace-for-single-out-new-line", "true"); //interface.properties.set("brace-for-single-out-space", "true"); etk::String outputRef = "action_A;\nfor (;;)\n\taction_B;\naction_D;"; etk::String output = interface.process(sourceFor1Action); EXPECT_EQ(output, outputRef); output = interface.process(sourceFor1ActionNoBrace); EXPECT_EQ(output, outputRef); } TEST(testFor, brace_for_single_01) { estyle::Generator interface; //interface.properties.set("brace-for-single-one-line-size-max", "40"); interface.properties.set("brace-for-single", "true"); //interface.properties.set("brace-for-single-in-new-line", "true"); interface.properties.set("brace-for-single-in-space", "true"); //interface.properties.set("brace-for-single-out-new-line", "true"); interface.properties.set("brace-for-single-out-space", "true"); etk::String outputRef = "action_A;\nfor (;;) action_B; action_D;"; etk::String output = interface.process(sourceFor1Action); EXPECT_EQ(output, outputRef); output = interface.process(sourceFor1ActionNoBrace); EXPECT_EQ(output, outputRef); } TEST(testFor, brace_for_single_11) { estyle::Generator interface; //interface.properties.set("brace-for-single-one-line-size-max", "40"); interface.properties.set("brace-for-single", "true"); interface.properties.set("brace-for-single-in-new-line", "true"); interface.properties.set("brace-for-single-in-space", "true"); interface.properties.set("brace-for-single-out-new-line", "true"); interface.properties.set("brace-for-single-out-space", "true"); etk::String outputRef = "action_A;\nfor (;;)\n\taction_B;\naction_D;"; etk::String output = interface.process(sourceFor1Action); EXPECT_EQ(output, outputRef); output = interface.process(sourceFor1ActionNoBrace); EXPECT_EQ(output, outputRef); } TEST(testFor, brace_for_oneLine_0) { estyle::Generator interface; interface.properties.set("brace-for-in-new-line-before", "true"); interface.properties.set("brace-for-in-new-line-after", "true"); interface.properties.set("brace-for-in-space-before", "true"); interface.properties.set("brace-for-in-space-after", "true"); interface.properties.set("brace-for-out-new-line-before", "true"); interface.properties.set("brace-for-out-new-line-after", "true"); interface.properties.set("brace-for-out-space-before", "true"); //interface.properties.set("brace-for-out-space-after", "true"); interface.properties.set("brace-for-single-one-line-size-max", "40"); //interface.properties.set("brace-for-single", "true"); etk::String outputRef = "action_A;\nfor (;;) { action_B; }\naction_D;"; etk::String output = interface.process(sourceFor1Action); EXPECT_EQ(output, outputRef); output = interface.process(sourceFor1ActionNoBrace); EXPECT_EQ(output, outputRef); } TEST(testFor, brace_for_oneLine_1) { estyle::Generator interface; interface.properties.set("brace-for-single-one-line-size-max", "40"); interface.properties.set("brace-for-single", "true"); interface.properties.set("brace-for-single-in-new-line", "true"); interface.properties.set("brace-for-single-in-space", "true"); interface.properties.set("brace-for-single-out-new-line", "true"); interface.properties.set("brace-for-single-out-space", "true"); etk::String outputRef = "action_A;\nfor (;;) action_B;\naction_D;"; etk::String output = interface.process(sourceFor1Action); EXPECT_EQ(output, outputRef); output = interface.process(sourceFor1ActionNoBrace); EXPECT_EQ(output, outputRef); } TEST(testFor, condition_0) { estyle::Generator interface; //interface.properties.set("brace-for-in-new-line-before", "true"); //interface.properties.set("brace-for-in-new-line-after", "true"); //interface.properties.set("brace-for-in-space-before", "true"); etk::String outputRef = "action_A;\nfor (;;){action_B;}action_D;"; etk::String output = interface.process(sourceFor1Action); EXPECT_EQ(output, outputRef); //output = interface.process(sourceFor1ActionNoBrace); //EXPECT_EQ(output, outputRef); } TEST(testFor, condition_1) { estyle::Generator interface; //interface.properties.set("brace-for-in-new-line-before", "true"); //interface.properties.set("brace-for-in-new-line-after", "true"); //interface.properties.set("brace-for-in-space-before", "true"); etk::String outputRef = "action_A;\nfor (instanciation =4; condition<6; ++inclemantation){action_B;}action_D;"; etk::String base = "action_A;for(instanciation=4; condition<6; ++inclemantation){action_B;}action_D;"; etk::String output = interface.process(base); EXPECT_EQ(output, outputRef); interface.properties.set("condition-for-multi-line-big-size", "20"); output = interface.process(base); outputRef = "action_A;\nfor (instanciation =4;\n condition<6;\n ++inclemantation){action_B;}action_D;"; EXPECT_EQ(output, outputRef); }