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-27 23:55:18 +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-27 23:55:18 +01:00
|
|
|
|
2017-12-28 15:35:20 +01:00
|
|
|
static etk::String sourceIf1Action = "action_A;if(true){action_B;}action_D;";
|
|
|
|
static etk::String sourceIf1ActionNoBrace = "action_A;if(true)action_B;action_D;";
|
|
|
|
static etk::String sourceIf2Action = "action_A;if(true){action_B;action_C;}action_D;";
|
2017-12-27 23:55:18 +01:00
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|