2017-12-08 23:02:38 +01:00
|
|
|
/**
|
|
|
|
* @author Edouard DUPIN
|
|
|
|
* @copyright 2017, Edouard DUPIN, all right reserved
|
|
|
|
* @license MPL-2 (see license file)
|
|
|
|
*/
|
2017-12-28 15:35:20 +01:00
|
|
|
#include <estyle/estyle.hpp>
|
|
|
|
#include <estyle/Generator.hpp>
|
|
|
|
#include <etk/etk.hpp>
|
|
|
|
#include <etk/os/FSNode.hpp>
|
2017-12-08 23:02:38 +01:00
|
|
|
#include <test-debug/debug.hpp>
|
|
|
|
#include <etest/etest.hpp>
|
|
|
|
|
2017-12-28 15:35:20 +01:00
|
|
|
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;";
|
2017-12-08 23:02:38 +01:00
|
|
|
|
|
|
|
|
2017-12-28 15:35:20 +01:00
|
|
|
TEST(testBraceFor, 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");
|
2017-12-28 15:48:12 +01:00
|
|
|
etk::String outputRef = "action_A;\nfor (;\n; ){action_B;}action_D;";
|
2017-12-28 15:35:20 +01:00
|
|
|
etk::String output = interface.process(sourceFor1Action);
|
|
|
|
EXPECT_EQ(output, outputRef);
|
|
|
|
output = interface.process(sourceFor1ActionNoBrace);
|
|
|
|
EXPECT_EQ(output, outputRef);
|
|
|
|
}
|
2017-12-08 23:02:38 +01:00
|
|
|
|
2017-12-28 15:35:20 +01:00
|
|
|
TEST(testBraceFor, 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");
|
2017-12-28 15:48:12 +01:00
|
|
|
etk::String outputRef = "action_A;\nfor (;\n; )\n{action_B;\n}action_D;";
|
2017-12-28 15:35:20 +01:00
|
|
|
etk::String output = interface.process(sourceFor1Action);
|
|
|
|
EXPECT_EQ(output, outputRef);
|
|
|
|
output = interface.process(sourceFor1ActionNoBrace);
|
|
|
|
EXPECT_EQ(output, outputRef);
|
2017-12-08 23:02:38 +01:00
|
|
|
}
|
|
|
|
|
2017-12-28 15:35:20 +01:00
|
|
|
TEST(testBraceFor, 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");
|
2017-12-28 15:48:12 +01:00
|
|
|
etk::String outputRef = "action_A;\nfor (;\n; )\n{action_B;\n}action_D;";
|
2017-12-28 15:35:20 +01:00
|
|
|
etk::String output = interface.process(sourceFor1Action);
|
|
|
|
EXPECT_EQ(output, outputRef);
|
|
|
|
output = interface.process(sourceFor1ActionNoBrace);
|
|
|
|
EXPECT_EQ(output, outputRef);
|
2017-12-08 23:02:38 +01:00
|
|
|
}
|
|
|
|
|
2017-12-28 15:35:20 +01:00
|
|
|
TEST(testBraceFor, 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");
|
2017-12-28 15:48:12 +01:00
|
|
|
etk::String outputRef = "action_A;\nfor (;\n; )\n{ action_B;\n} action_D;";
|
2017-12-28 15:35:20 +01:00
|
|
|
etk::String output = interface.process(sourceFor1Action);
|
|
|
|
EXPECT_EQ(output, outputRef);
|
|
|
|
output = interface.process(sourceFor1ActionNoBrace);
|
|
|
|
EXPECT_EQ(output, outputRef);
|
2017-12-08 23:02:38 +01:00
|
|
|
}
|
|
|
|
|
2017-12-28 15:35:20 +01:00
|
|
|
TEST(testBraceFor, 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");
|
2017-12-28 15:48:12 +01:00
|
|
|
etk::String outputRef = "action_A;\nfor (;\n; )\n{\n\taction_B;\n}\naction_D;";
|
2017-12-28 15:35:20 +01:00
|
|
|
etk::String output = interface.process(sourceFor1Action);
|
|
|
|
EXPECT_EQ(output, outputRef);
|
|
|
|
output = interface.process(sourceFor1ActionNoBrace);
|
|
|
|
EXPECT_EQ(output, outputRef);
|
|
|
|
}
|
2017-12-08 23:02:38 +01:00
|
|
|
|
2017-12-28 15:35:20 +01:00
|
|
|
TEST(testBraceFor, 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");
|
2017-12-28 15:48:12 +01:00
|
|
|
etk::String outputRef = "action_A;\nfor (;\n; )\n{ \n\taction_B;\n} \naction_D;";
|
2017-12-28 15:35:20 +01:00
|
|
|
etk::String output = interface.process(sourceFor1Action);
|
|
|
|
EXPECT_EQ(output, outputRef);
|
|
|
|
output = interface.process(sourceFor1ActionNoBrace);
|
|
|
|
EXPECT_EQ(output, outputRef);
|
|
|
|
}
|
2017-12-08 23:02:38 +01:00
|
|
|
|
2017-12-28 15:35:20 +01:00
|
|
|
TEST(testBraceFor, 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");
|
2017-12-28 15:48:12 +01:00
|
|
|
etk::String outputRef = "action_A;\nfor (;\n; )\n{\n\taction_B;\n}\naction_D;";
|
2017-12-28 15:35:20 +01:00
|
|
|
etk::String output = interface.process(sourceFor1Action);
|
|
|
|
EXPECT_EQ(output, outputRef);
|
|
|
|
output = interface.process(sourceFor1ActionNoBrace);
|
|
|
|
EXPECT_EQ(output, outputRef);
|
2017-12-08 23:02:38 +01:00
|
|
|
}
|
|
|
|
|
2017-12-28 15:35:20 +01:00
|
|
|
TEST(testBraceFor, 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");
|
2017-12-28 15:48:12 +01:00
|
|
|
etk::String outputRef = "action_A;\nfor (;\n; )\n{ \n\taction_B;\n} \naction_D;";
|
2017-12-28 15:35:20 +01:00
|
|
|
etk::String output = interface.process(sourceFor1Action);
|
|
|
|
EXPECT_EQ(output, outputRef);
|
|
|
|
output = interface.process(sourceFor1ActionNoBrace);
|
|
|
|
EXPECT_EQ(output, outputRef);
|
|
|
|
}
|
2017-12-08 23:02:38 +01:00
|
|
|
|
2017-12-28 15:35:20 +01:00
|
|
|
TEST(testBraceFor, 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");
|
2017-12-28 15:48:12 +01:00
|
|
|
etk::String outputRef = "action_A;\nfor (;\n; )\n{ action_B;\n} action_D;";
|
2017-12-28 15:35:20 +01:00
|
|
|
etk::String output = interface.process(sourceFor1Action);
|
|
|
|
EXPECT_EQ(output, outputRef);
|
|
|
|
output = interface.process(sourceFor1ActionNoBrace);
|
|
|
|
EXPECT_EQ(output, outputRef);
|
|
|
|
}
|
2017-12-08 23:02:38 +01:00
|
|
|
|
|
|
|
|
2017-12-28 15:35:20 +01:00
|
|
|
TEST(testBraceFor, 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");
|
2017-12-28 15:48:12 +01:00
|
|
|
etk::String outputRef = "action_A;\nfor (;\n; ){\n\taction_B;}\naction_D;";
|
2017-12-28 15:35:20 +01:00
|
|
|
etk::String output = interface.process(sourceFor1Action);
|
|
|
|
EXPECT_EQ(output, outputRef);
|
|
|
|
output = interface.process(sourceFor1ActionNoBrace);
|
|
|
|
EXPECT_EQ(output, outputRef);
|
2017-12-08 23:02:38 +01:00
|
|
|
}
|
|
|
|
|
2017-12-28 15:35:20 +01:00
|
|
|
TEST(testBraceFor, 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");
|
2017-12-28 15:48:12 +01:00
|
|
|
etk::String outputRef = "action_A;\nfor (;\n; ){ \n\taction_B;} \naction_D;";
|
2017-12-28 15:35:20 +01:00
|
|
|
etk::String output = interface.process(sourceFor1Action);
|
|
|
|
EXPECT_EQ(output, outputRef);
|
|
|
|
output = interface.process(sourceFor1ActionNoBrace);
|
|
|
|
EXPECT_EQ(output, outputRef);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(testBraceFor, 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");
|
2017-12-28 15:48:12 +01:00
|
|
|
etk::String outputRef = "action_A;\nfor (;\n; ) {\n\taction_B; }\naction_D;";
|
2017-12-28 15:35:20 +01:00
|
|
|
etk::String output = interface.process(sourceFor1Action);
|
|
|
|
EXPECT_EQ(output, outputRef);
|
|
|
|
output = interface.process(sourceFor1ActionNoBrace);
|
|
|
|
EXPECT_EQ(output, outputRef);
|
|
|
|
}
|
2017-12-08 23:02:38 +01:00
|
|
|
|
2017-12-28 15:35:20 +01:00
|
|
|
TEST(testBraceFor, 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");
|
2017-12-28 15:48:12 +01:00
|
|
|
etk::String outputRef = "action_A;\nfor (;\n; ) {action_B; }action_D;";
|
2017-12-28 15:35:20 +01:00
|
|
|
etk::String output = interface.process(sourceFor1Action);
|
|
|
|
EXPECT_EQ(output, outputRef);
|
|
|
|
output = interface.process(sourceFor1ActionNoBrace);
|
|
|
|
EXPECT_EQ(output, outputRef);
|
2017-12-08 23:02:38 +01:00
|
|
|
}
|
|
|
|
|
2017-12-28 15:35:20 +01:00
|
|
|
TEST(testBraceFor, 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");
|
2017-12-28 15:48:12 +01:00
|
|
|
etk::String outputRef = "action_A;\nfor (;\n; ) { action_B; } action_D;";
|
2017-12-28 15:35:20 +01:00
|
|
|
etk::String output = interface.process(sourceFor1Action);
|
|
|
|
EXPECT_EQ(output, outputRef);
|
|
|
|
output = interface.process(sourceFor1ActionNoBrace);
|
|
|
|
EXPECT_EQ(output, outputRef);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(testBraceFor, 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");
|
2017-12-28 15:48:12 +01:00
|
|
|
etk::String outputRef = "action_A;\nfor (;\n; ) { \n\taction_B; } \naction_D;";
|
2017-12-28 15:35:20 +01:00
|
|
|
etk::String output = interface.process(sourceFor1Action);
|
|
|
|
EXPECT_EQ(output, outputRef);
|
|
|
|
output = interface.process(sourceFor1ActionNoBrace);
|
|
|
|
EXPECT_EQ(output, outputRef);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(testBraceFor, 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");
|
2017-12-28 15:48:12 +01:00
|
|
|
etk::String outputRef = "action_A;\nfor (;\n; ){ action_B;} action_D;";
|
2017-12-28 15:35:20 +01:00
|
|
|
etk::String output = interface.process(sourceFor1Action);
|
|
|
|
EXPECT_EQ(output, outputRef);
|
|
|
|
output = interface.process(sourceFor1ActionNoBrace);
|
|
|
|
EXPECT_EQ(output, outputRef);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|