/** * @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_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 outRef = "action_A;for(;;){action_B;}action_D;"; etk::String output = interface.process(sourceFor1Action); EXPECT_EQ(output, outRef); output = interface.process(sourceFor1ActionNoBrace); EXPECT_EQ(output, outRef); } TEST(testFor, brace_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 outRef = "action_A;for(;;)\n{action_B;\n}action_D;"; etk::String output = interface.process(sourceFor1Action); EXPECT_EQ(output, outRef); output = interface.process(sourceFor1ActionNoBrace); EXPECT_EQ(output, outRef); } TEST(testFor, brace_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 outRef = "action_A;for(;;)\n{action_B;\n}action_D;"; etk::String output = interface.process(sourceFor1Action); EXPECT_EQ(output, outRef); output = interface.process(sourceFor1ActionNoBrace); EXPECT_EQ(output, outRef); } TEST(testFor, brace_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 outRef = "action_A;for(;;)\n{ action_B;\n} action_D;"; etk::String output = interface.process(sourceFor1Action); EXPECT_EQ(output, outRef); output = interface.process(sourceFor1ActionNoBrace); EXPECT_EQ(output, outRef); } TEST(testFor, brace_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 outRef = "action_A;for(;;)\n{\n\taction_B;\n}\naction_D;"; etk::String output = interface.process(sourceFor1Action); EXPECT_EQ(output, outRef); output = interface.process(sourceFor1ActionNoBrace); EXPECT_EQ(output, outRef); } TEST(testFor, brace_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 outRef = "action_A;for(;;)\n{\n\taction_B;\n}\naction_D;"; etk::String output = interface.process(sourceFor1Action); EXPECT_EQ(output, outRef); output = interface.process(sourceFor1ActionNoBrace); EXPECT_EQ(output, outRef); } TEST(testFor, brace_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 outRef = "action_A;for(;;)\n{\n\taction_B;\n}\naction_D;"; etk::String output = interface.process(sourceFor1Action); EXPECT_EQ(output, outRef); output = interface.process(sourceFor1ActionNoBrace); EXPECT_EQ(output, outRef); } TEST(testFor, brace_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 outRef = "action_A;for(;;)\n{\n\taction_B;\n}\naction_D;"; etk::String output = interface.process(sourceFor1Action); EXPECT_EQ(output, outRef); output = interface.process(sourceFor1ActionNoBrace); EXPECT_EQ(output, outRef); } TEST(testFor, brace_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 outRef = "action_A;for(;;)\n{ action_B;\n} action_D;"; etk::String output = interface.process(sourceFor1Action); EXPECT_EQ(output, outRef); output = interface.process(sourceFor1ActionNoBrace); EXPECT_EQ(output, outRef); } TEST(testFor, brace_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 outRef = "action_A;for(;;){\n\taction_B;}\naction_D;"; etk::String output = interface.process(sourceFor1Action); EXPECT_EQ(output, outRef); output = interface.process(sourceFor1ActionNoBrace); EXPECT_EQ(output, outRef); } TEST(testFor, brace_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 outRef = "action_A;for(;;){\n\taction_B;}\naction_D;"; etk::String output = interface.process(sourceFor1Action); EXPECT_EQ(output, outRef); output = interface.process(sourceFor1ActionNoBrace); EXPECT_EQ(output, outRef); } TEST(testFor, brace_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 outRef = "action_A;for(;;) {\n\taction_B; }\naction_D;"; etk::String output = interface.process(sourceFor1Action); EXPECT_EQ(output, outRef); output = interface.process(sourceFor1ActionNoBrace); EXPECT_EQ(output, outRef); } TEST(testFor, brace_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 outRef = "action_A;for(;;) {action_B; }action_D;"; etk::String output = interface.process(sourceFor1Action); EXPECT_EQ(output, outRef); output = interface.process(sourceFor1ActionNoBrace); EXPECT_EQ(output, outRef); } TEST(testFor, brace_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 outRef = "action_A;for(;;) { action_B; } action_D;"; etk::String output = interface.process(sourceFor1Action); EXPECT_EQ(output, outRef); output = interface.process(sourceFor1ActionNoBrace); EXPECT_EQ(output, outRef); } TEST(testFor, brace_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 outRef = "action_A;for(;;) {\n\taction_B; }\naction_D;"; etk::String output = interface.process(sourceFor1Action); EXPECT_EQ(output, outRef); output = interface.process(sourceFor1ActionNoBrace); EXPECT_EQ(output, outRef); } TEST(testFor, brace_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 outRef = "action_A;for(;;){ action_B;} action_D;"; etk::String output = interface.process(sourceFor1Action); EXPECT_EQ(output, outRef); output = interface.process(sourceFor1ActionNoBrace); EXPECT_EQ(output, outRef); } TEST(testFor, brace_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 outRef = "action_A;for(;;)action_B;action_D;"; etk::String output = interface.process(sourceFor1Action); EXPECT_EQ(output, outRef); output = interface.process(sourceFor1ActionNoBrace); EXPECT_EQ(output, outRef); } TEST(testFor, brace_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 outRef = "action_A;for(;;)\n\taction_B;\naction_D;"; etk::String output = interface.process(sourceFor1Action); EXPECT_EQ(output, outRef); output = interface.process(sourceFor1ActionNoBrace); EXPECT_EQ(output, outRef); } TEST(testFor, brace_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 outRef = "action_A;for(;;) action_B; action_D;"; etk::String output = interface.process(sourceFor1Action); EXPECT_EQ(output, outRef); output = interface.process(sourceFor1ActionNoBrace); EXPECT_EQ(output, outRef); } TEST(testFor, brace_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 outRef = "action_A;for(;;)\n\taction_B;\naction_D;"; etk::String output = interface.process(sourceFor1Action); EXPECT_EQ(output, outRef); output = interface.process(sourceFor1ActionNoBrace); EXPECT_EQ(output, outRef); } TEST(testFor, brace_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 outRef = "action_A;for(;;) { action_B; }\naction_D;"; etk::String output = interface.process(sourceFor1Action); EXPECT_EQ(output, outRef); output = interface.process(sourceFor1ActionNoBrace); EXPECT_EQ(output, outRef); } TEST(testFor, brace_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 outRef = "action_A;for(;;) action_B;\naction_D;"; etk::String output = interface.process(sourceFor1Action); EXPECT_EQ(output, outRef); output = interface.process(sourceFor1ActionNoBrace); EXPECT_EQ(output, outRef); } 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 outRef = "action_A;for(;;){action_B;}action_D;"; etk::String output = interface.process(sourceFor1Action); EXPECT_EQ(output, outRef); //output = interface.process(sourceFor1ActionNoBrace); //EXPECT_EQ(output, outRef); } 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 outRef = "action_A;for(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, outRef); interface.properties.set("parenthese-for-single-one-line-size-max", "20"); output = interface.process(base); outRef = "action_A;for(instanciation =4;\n condition<6;\n ++inclemantation){action_B;}action_D;"; EXPECT_EQ(output, outRef); }