estyle/test/testFor.cpp

310 lines
15 KiB
C++
Raw Normal View History

2017-12-08 23:02:38 +01:00
/**
* @author Edouard DUPIN
* @copyright 2017, Edouard DUPIN, all right reserved
* @license MPL-2 (see license file)
*/
#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>
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
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");
etk::String outputRef = "action_A;\nfor (;\n; ){action_B;}action_D;";
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
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");
etk::String outputRef = "action_A;\nfor (;\n; )\n{action_B;\n}action_D;";
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
}
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");
etk::String outputRef = "action_A;\nfor (;\n; )\n{action_B;\n}action_D;";
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
}
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");
etk::String outputRef = "action_A;\nfor (;\n; )\n{ action_B;\n} action_D;";
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
}
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");
etk::String outputRef = "action_A;\nfor (;\n; )\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);
}
2017-12-08 23:02:38 +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");
etk::String outputRef = "action_A;\nfor (;\n; )\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);
}
2017-12-08 23:02:38 +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");
etk::String outputRef = "action_A;\nfor (;\n; )\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);
2017-12-08 23:02:38 +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");
etk::String outputRef = "action_A;\nfor (;\n; )\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);
}
2017-12-08 23:02:38 +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");
etk::String outputRef = "action_A;\nfor (;\n; )\n{ action_B;\n} action_D;";
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
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");
etk::String outputRef = "action_A;\nfor (;\n; ){\n\taction_B;}\naction_D;";
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
}
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");
etk::String outputRef = "action_A;\nfor (;\n; ){ \n\taction_B;} \naction_D;";
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");
etk::String outputRef = "action_A;\nfor (;\n; ) {\n\taction_B; }\naction_D;";
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
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");
etk::String outputRef = "action_A;\nfor (;\n; ) {action_B; }action_D;";
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
}
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");
etk::String outputRef = "action_A;\nfor (;\n; ) { action_B; } action_D;";
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");
etk::String outputRef = "action_A;\nfor (;\n; ) { \n\taction_B; } \naction_D;";
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");
etk::String outputRef = "action_A;\nfor (;\n; ){ action_B;} action_D;";
etk::String output = interface.process(sourceFor1Action);
EXPECT_EQ(output, outputRef);
output = interface.process(sourceFor1ActionNoBrace);
EXPECT_EQ(output, outputRef);
}