[DEV] add do...while

This commit is contained in:
Edouard DUPIN 2018-01-02 22:28:43 +01:00
parent bfc351e2a4
commit 42272a00e4
3 changed files with 508 additions and 25 deletions

View File

@ -181,6 +181,47 @@ estyle::BraceProperty& estyle::BraceProperty::operator=(BraceProperty&& _obj) {
return *this;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
estyle::ParentheseProperty::ParentheseProperty() :
inSpaceBefore(false),
inSpaceAfter(false),
outSpaceBefore(false),
outSpaceAfter(false),
oneLineMaxSize(-1) {
}
estyle::ParentheseProperty::ParentheseProperty(class estyle::Generator* _generator, const etk::String& _typeName):
inSpaceBefore(_generator, "parenthese-" + _typeName + "-in-space-before", false, "Set a space before the input parenthese (if not already present)"),
inSpaceAfter(_generator, "parenthese-" + _typeName + "-in-space-after", false, "Set a space after the input parenthese (if not already present)"),
outSpaceBefore(_generator, "parenthese-" + _typeName + "-out-space-before", false, "Set a space before the input parenthese (if not already present)"),
outSpaceAfter(_generator, "parenthese-" + _typeName + "-out-space-after", false, "Set a space after the input parenthese (if not already present)"),
oneLineMaxSize(_generator, "parenthese-" + _typeName + "-single-one-line-size-max", -1, "Set in a single line if the size if < XXX (-1 to disable)") {
}
estyle::ParentheseProperty::ParentheseProperty(estyle::ParentheseProperty&& _obj) :
inSpaceBefore(etk::move(_obj.inSpaceBefore)),
inSpaceAfter(etk::move(_obj.inSpaceAfter)),
outSpaceBefore(etk::move(_obj.outSpaceBefore)),
outSpaceAfter(etk::move(_obj.outSpaceAfter)),
oneLineMaxSize(etk::move(_obj.oneLineMaxSize)) {
}
estyle::ParentheseProperty& estyle::ParentheseProperty::operator=(ParentheseProperty&& _obj) {
inSpaceBefore = etk::move(_obj.inSpaceBefore);
inSpaceAfter = etk::move(_obj.inSpaceAfter);
outSpaceBefore = etk::move(_obj.outSpaceBefore);
outSpaceAfter = etk::move(_obj.outSpaceAfter);
oneLineMaxSize = etk::move(_obj.oneLineMaxSize);
return *this;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void estyle::Generator::clear() {
m_offset = 0;
m_offsetStack.clear();
@ -210,12 +251,15 @@ estyle::Generator::Generator():
propertyBrace.set("for", etk::move(estyle::BraceProperty(this, "for")));
propertyBrace.set("while", etk::move(estyle::BraceProperty(this, "while")));
propertyBrace.set("namespace", etk::move(estyle::BraceProperty(this, "namespace", false)));
propertyBrace.set("block", etk::move(estyle::BraceProperty(this, "block", false)));
propertyBrace.set("do-while", etk::move(estyle::BraceProperty(this, "do-while")));
propertyBrace.set("switch", etk::move(estyle::BraceProperty(this, "switch", false)));
propertyBrace.set("class", etk::move(estyle::BraceProperty(this, "class", false)));
propertyBrace.set("struct", etk::move(estyle::BraceProperty(this, "struct", false)));
propertyBrace.set("block", etk::move(estyle::BraceProperty(this, "block", false)));
//ParentheseProperty
}
estyle::Generator::~Generator() {
@ -325,6 +369,26 @@ void estyle::Generator::addSpace(bool _force) {
}
m_output += " ";
}
void estyle::Generator::addSpaceIfNeeded() {
if (m_output.size() == 0) {
return;
}
if (m_output.back() == '\0') {
return;
}
if (m_output.back() == '\n') {
return;
}
if ( ( m_output.back() >= '0'
&& m_output.back() <= '9' )
|| ( m_output.back() >= 'a'
&& m_output.back() <= 'z' )
|| ( m_output.back() >= 'A'
&& m_output.back() <= 'Z' )
|| m_output.back() == '_' ) {
m_output += " ";
}
}
bool estyle::Generator::onNewLine() {
if (m_output.size() == 0) {
@ -680,38 +744,48 @@ int32_t estyle::Generator::process(int32_t _startId,
continue;
}
if ( elem == estyle::lexer::RESERVED_IF
|| elem == estyle::lexer::RESERVED_WHILE) {
|| elem == estyle::lexer::RESERVED_WHILE
|| elem == estyle::lexer::RESERVED_DO) {
addNewLineIfSemiColon();
addSpace();
if (elem == estyle::lexer::RESERVED_IF) {
m_output += "if ";
m_output += "if";
typePush("if");
if (previousIs(iii, estyle::lexer::RESERVED_ELSE) == true) {
offsetPush(4 + 5);
} else {
offsetPush(4);
}
} else {
m_output += "while ";
} else if (elem == estyle::lexer::RESERVED_WHILE) {
m_output += "while";
typePush("while");
offsetPush(7);
} else {
m_output += "do";
typePush("do-while");
}
for (int64_t jjj=iii+1; jjj<m_lexer.size(); ++jjj) {
enum estyle::lexer::tocken elem = m_lexer.getTocken(jjj);
if (elem == estyle::lexer::RESERVED_NEW_LINE) {
// OK ==> normal case ...
} else if (elem == estyle::lexer::PARENTHESE_IN) {
// find condition section ...
iii = generateCondition(jjj);
break;
} else {
ESTYLE_ERROR("Get 'if' without '(' element");
bool haveError = false;
if (elem != estyle::lexer::RESERVED_DO) {
for (int64_t jjj=iii+1; jjj<m_lexer.size(); ++jjj) {
enum estyle::lexer::tocken elem2 = m_lexer.getTocken(jjj);
if (elem2 == estyle::lexer::RESERVED_NEW_LINE) {
// OK ==> normal case ...
} else if (elem2 == estyle::lexer::PARENTHESE_IN) {
// find condition section ...
iii = generateCondition(jjj);
break;
} else {
ESTYLE_ERROR("Get '" << elem << "' without '(' element");
haveError = true;
break;
}
}
offsetPop();
if (haveError == true) {
typePop();
continue;
}
}
offsetPop();
bool needBrace = false;
bool haveBrace = false;
int32_t subGenerationStart = iii+1;
@ -740,6 +814,37 @@ int32_t estyle::Generator::process(int32_t _startId,
} else {
iii -= 2;
}
if (elem == estyle::lexer::RESERVED_DO) {
if (nextIs(iii+1, estyle::lexer::RESERVED_WHILE) == false) {
ESTYLE_ERROR("find a 'do ... ' without 'while' ...");
typePop();
continue;
} else {
addSpaceIfNeeded();
iii++;
m_output += "while ";
offsetPush(6);
for (int64_t jjj=iii+1; jjj<m_lexer.size(); ++jjj) {
enum estyle::lexer::tocken elem2 = m_lexer.getTocken(jjj);
if (elem2 == estyle::lexer::RESERVED_NEW_LINE) {
// OK ==> normal case ...
} else if (elem2 == estyle::lexer::PARENTHESE_IN) {
// find condition section ...
iii = generateCondition(jjj);
break;
} else {
ESTYLE_ERROR("Get 'do ... while ' without '(' element");
haveError = true;
break;
}
}
offsetPop();
if (haveError == true) {
typePop();
continue;
}
}
}
typePop();
continue;
}
@ -911,14 +1016,7 @@ int64_t estyle::Generator::generateBrace(int64_t _start, int64_t _stop, bool _ne
// add 1 space if needed
addSpace();
} else {
if ( m_output.size() != 0
&& ( m_output.back() != ' '
&& m_output.back() != ')'
&& m_output.back() != '>'
&& m_output.back() != ']'
&& m_output.back() != '\t')) {
addSpace();
}
addSpaceIfNeeded();
}
}
indentationPush();

View File

@ -38,6 +38,21 @@ namespace estyle {
BraceProperty& operator=(BraceProperty&& _obj);
BraceProperty& operator=(const BraceProperty& _obj) = delete;
};
class ParentheseProperty {
public:
ParentheseProperty();
ParentheseProperty(estyle::Generator* _generator, const etk::String& _typeName);
eproperty::Value<bool> inSpaceBefore;
eproperty::Value<bool> inSpaceAfter;
eproperty::Value<bool> outSpaceBefore;
eproperty::Value<bool> outSpaceAfter;
eproperty::Value<int32_t> oneLineMaxSize;
ParentheseProperty(const ParentheseProperty& _obj) = delete;
ParentheseProperty(ParentheseProperty&& _obj);
~ParentheseProperty() = default;
ParentheseProperty& operator=(ParentheseProperty&& _obj);
ParentheseProperty& operator=(const ParentheseProperty& _obj) = delete;
};
class Generator : public eproperty::Interface {
public:
Generator();
@ -56,6 +71,7 @@ namespace estyle {
// Brace section
// brace for "if"
etk::Map<etk::String, estyle::BraceProperty> propertyBrace;
etk::Map<etk::String, estyle::ParentheseProperty> propertyParenthese;
private:
void clear();
@ -88,6 +104,7 @@ namespace estyle {
* @brief Add space " " if no space or '\t' is set before and add the indentation if needed (last char is a "\n")
*/
void addSpace(bool _force=false);
void addSpaceIfNeeded();
/**
* @brief Add Indentation "\t\t\t " if start of line
*/

View File

@ -0,0 +1,368 @@
/**
* @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>
#include <test-debug/debug.hpp>
#include <etest/etest.hpp>
static etk::String sourceIf1Action = "action_A;do{action_B;}while(true);action_D;";
static etk::String sourceIf1ActionNoBrace = "action_A;do action_B; while(true);action_D;";
static etk::String sourceIf2Action = "action_A;do{action_B;action_C;}while(true);action_D;";
TEST(testDoWhile, brace_0000) {
estyle::Generator interface;
//interface.properties.set("brace-do-while-in-new-line-before", "true");
//interface.properties.set("brace-do-while-in-new-line-after", "true");
//interface.properties.set("brace-do-while-in-space-before", "true");
//interface.properties.set("brace-do-while-in-space-after", "true");
//interface.properties.set("brace-do-while-out-new-line-before", "true");
//interface.properties.set("brace-do-while-out-new-line-after", "true");
//interface.properties.set("brace-do-while-out-space-before", "true");
//interface.properties.set("brace-do-while-out-space-after", "true");
//interface.properties.set("brace-do-while-single", "true");
etk::String outputRef = "action_A;\ndo{action_B;}while (true );\naction_D;";
etk::String output = interface.process(sourceIf1Action);
EXPECT_EQ(output, outputRef);
output = interface.process(sourceIf1ActionNoBrace);
EXPECT_EQ(output, outputRef);
}
TEST(testDoWhile, brace_1000) {
estyle::Generator interface;
interface.properties.set("brace-do-while-in-new-line-before", "true");
//interface.properties.set("brace-do-while-in-new-line-after", "true");
//interface.properties.set("brace-do-while-in-space-before", "true");
//interface.properties.set("brace-do-while-in-space-after", "true");
interface.properties.set("brace-do-while-out-new-line-before", "true");
//interface.properties.set("brace-do-while-out-new-line-after", "true");
//interface.properties.set("brace-do-while-out-space-before", "true");
//interface.properties.set("brace-do-while-out-space-after", "true");
//interface.properties.set("brace-do-while-single", "true");
etk::String outputRef = "action_A;\ndo\n{action_B;\n}while (true );\naction_D;";
etk::String output = interface.process(sourceIf1Action);
EXPECT_EQ(output, outputRef);
output = interface.process(sourceIf1ActionNoBrace);
EXPECT_EQ(output, outputRef);
}
TEST(testDoWhile, brace_1010) {
estyle::Generator interface;
interface.properties.set("brace-do-while-in-new-line-before", "true");
//interface.properties.set("brace-do-while-in-new-line-after", "true");
interface.properties.set("brace-do-while-in-space-before", "true");
//interface.properties.set("brace-do-while-in-space-after", "true");
interface.properties.set("brace-do-while-out-new-line-before", "true");
//interface.properties.set("brace-do-while-out-new-line-after", "true");
interface.properties.set("brace-do-while-out-space-before", "true");
//interface.properties.set("brace-do-while-out-space-after", "true");
//interface.properties.set("brace-do-while-single", "true");
etk::String outputRef = "action_A;\ndo\n{action_B;\n}while (true );\naction_D;";
etk::String output = interface.process(sourceIf1Action);
EXPECT_EQ(output, outputRef);
output = interface.process(sourceIf1ActionNoBrace);
EXPECT_EQ(output, outputRef);
}
TEST(testDoWhile, brace_1011) {
estyle::Generator interface;
interface.properties.set("brace-do-while-in-new-line-before", "true");
//interface.properties.set("brace-do-while-in-new-line-after", "true");
interface.properties.set("brace-do-while-in-space-before", "true");
interface.properties.set("brace-do-while-in-space-after", "true");
interface.properties.set("brace-do-while-out-new-line-before", "true");
//interface.properties.set("brace-do-while-out-new-line-after", "true");
interface.properties.set("brace-do-while-out-space-before", "true");
interface.properties.set("brace-do-while-out-space-after", "true");
//interface.properties.set("brace-do-while-single", "true");
etk::String outputRef = "action_A;\ndo\n{ action_B;\n} while (true );\naction_D;";
etk::String output = interface.process(sourceIf1Action);
EXPECT_EQ(output, outputRef);
output = interface.process(sourceIf1ActionNoBrace);
EXPECT_EQ(output, outputRef);
}
TEST(testDoWhile, brace_1100) {
estyle::Generator interface;
interface.properties.set("brace-do-while-in-new-line-before", "true");
interface.properties.set("brace-do-while-in-new-line-after", "true");
//interface.properties.set("brace-do-while-in-space-before", "true");
//interface.properties.set("brace-do-while-in-space-after", "true");
interface.properties.set("brace-do-while-out-new-line-before", "true");
interface.properties.set("brace-do-while-out-new-line-after", "true");
//interface.properties.set("brace-do-while-out-space-before", "true");
//interface.properties.set("brace-do-while-out-space-after", "true");
//interface.properties.set("brace-do-while-single", "true");
etk::String outputRef = "action_A;\ndo\n{\n\taction_B;\n}\nwhile (true );\naction_D;";
etk::String output = interface.process(sourceIf1Action);
EXPECT_EQ(output, outputRef);
output = interface.process(sourceIf1ActionNoBrace);
EXPECT_EQ(output, outputRef);
}
TEST(testDoWhile, brace_1101) {
estyle::Generator interface;
interface.properties.set("brace-do-while-in-new-line-before", "true");
interface.properties.set("brace-do-while-in-new-line-after", "true");
//interface.properties.set("brace-do-while-in-space-before", "true");
interface.properties.set("brace-do-while-in-space-after", "true");
interface.properties.set("brace-do-while-out-new-line-before", "true");
interface.properties.set("brace-do-while-out-new-line-after", "true");
//interface.properties.set("brace-do-while-out-space-before", "true");
interface.properties.set("brace-do-while-out-space-after", "true");
//interface.properties.set("brace-do-while-single", "true");
etk::String outputRef = "action_A;\ndo\n{\n\taction_B;\n}\nwhile (true );\naction_D;";
etk::String output = interface.process(sourceIf1Action);
EXPECT_EQ(output, outputRef);
output = interface.process(sourceIf1ActionNoBrace);
EXPECT_EQ(output, outputRef);
}
TEST(testDoWhile, brace_1110) {
estyle::Generator interface;
interface.properties.set("brace-do-while-in-new-line-before", "true");
interface.properties.set("brace-do-while-in-new-line-after", "true");
interface.properties.set("brace-do-while-in-space-before", "true");
//interface.properties.set("brace-do-while-in-space-after", "true");
interface.properties.set("brace-do-while-out-new-line-before", "true");
interface.properties.set("brace-do-while-out-new-line-after", "true");
interface.properties.set("brace-do-while-out-space-before", "true");
//interface.properties.set("brace-do-while-out-space-after", "true");
//interface.properties.set("brace-do-while-single", "true");
etk::String outputRef = "action_A;\ndo\n{\n\taction_B;\n}\nwhile (true );\naction_D;";
etk::String output = interface.process(sourceIf1Action);
EXPECT_EQ(output, outputRef);
output = interface.process(sourceIf1ActionNoBrace);
EXPECT_EQ(output, outputRef);
}
TEST(testDoWhile, brace_1111) {
estyle::Generator interface;
interface.properties.set("brace-do-while-in-new-line-before", "true");
interface.properties.set("brace-do-while-in-new-line-after", "true");
interface.properties.set("brace-do-while-in-space-before", "true");
interface.properties.set("brace-do-while-in-space-after", "true");
interface.properties.set("brace-do-while-out-new-line-before", "true");
interface.properties.set("brace-do-while-out-new-line-after", "true");
interface.properties.set("brace-do-while-out-space-before", "true");
interface.properties.set("brace-do-while-out-space-after", "true");
//interface.properties.set("brace-do-while-single", "true");
etk::String outputRef = "action_A;\ndo\n{\n\taction_B;\n}\nwhile (true );\naction_D;";
etk::String output = interface.process(sourceIf1Action);
EXPECT_EQ(output, outputRef);
output = interface.process(sourceIf1ActionNoBrace);
EXPECT_EQ(output, outputRef);
}
TEST(testDoWhile, brace_1001) {
estyle::Generator interface;
interface.properties.set("brace-do-while-in-new-line-before", "true");
//interface.properties.set("brace-do-while-in-new-line-after", "true");
//interface.properties.set("brace-do-while-in-space-before", "true");
interface.properties.set("brace-do-while-in-space-after", "true");
interface.properties.set("brace-do-while-out-new-line-before", "true");
//interface.properties.set("brace-do-while-out-new-line-after", "true");
//interface.properties.set("brace-do-while-out-space-before", "true");
interface.properties.set("brace-do-while-out-space-after", "true");
//interface.properties.set("brace-do-while-single", "true");
etk::String outputRef = "action_A;\ndo\n{ action_B;\n} while (true );\naction_D;";
etk::String output = interface.process(sourceIf1Action);
EXPECT_EQ(output, outputRef);
output = interface.process(sourceIf1ActionNoBrace);
EXPECT_EQ(output, outputRef);
}
TEST(testDoWhile, brace_0100) {
estyle::Generator interface;
//interface.properties.set("brace-do-while-in-new-line-before", "true");
interface.properties.set("brace-do-while-in-new-line-after", "true");
//interface.properties.set("brace-do-while-in-space-before", "true");
//interface.properties.set("brace-do-while-in-space-after", "true");
//interface.properties.set("brace-do-while-out-new-line-before", "true");
interface.properties.set("brace-do-while-out-new-line-after", "true");
//interface.properties.set("brace-do-while-out-space-before", "true");
//interface.properties.set("brace-do-while-out-space-after", "true");
//interface.properties.set("brace-do-while-single", "true");
etk::String outputRef = "action_A;\ndo{\n\taction_B;}\nwhile (true );\naction_D;";
etk::String output = interface.process(sourceIf1Action);
EXPECT_EQ(output, outputRef);
output = interface.process(sourceIf1ActionNoBrace);
EXPECT_EQ(output, outputRef);
}
TEST(testDoWhile, brace_0101) {
estyle::Generator interface;
//interface.properties.set("brace-do-while-in-new-line-before", "true");
interface.properties.set("brace-do-while-in-new-line-after", "true");
//interface.properties.set("brace-do-while-in-space-before", "true");
interface.properties.set("brace-do-while-in-space-after", "true");
//interface.properties.set("brace-do-while-out-new-line-before", "true");
interface.properties.set("brace-do-while-out-new-line-after", "true");
//interface.properties.set("brace-do-while-out-space-before", "true");
interface.properties.set("brace-do-while-out-space-after", "true");
//interface.properties.set("brace-do-while-single", "true");
etk::String outputRef = "action_A;\ndo{\n\taction_B;}\nwhile (true );\naction_D;";
etk::String output = interface.process(sourceIf1Action);
EXPECT_EQ(output, outputRef);
output = interface.process(sourceIf1ActionNoBrace);
EXPECT_EQ(output, outputRef);
}
TEST(testDoWhile, brace_0110) {
estyle::Generator interface;
//interface.properties.set("brace-do-while-in-new-line-before", "true");
interface.properties.set("brace-do-while-in-new-line-after", "true");
interface.properties.set("brace-do-while-in-space-before", "true");
//interface.properties.set("brace-do-while-in-space-after", "true");
//interface.properties.set("brace-do-while-out-new-line-before", "true");
interface.properties.set("brace-do-while-out-new-line-after", "true");
interface.properties.set("brace-do-while-out-space-before", "true");
//interface.properties.set("brace-do-while-out-space-after", "true");
//interface.properties.set("brace-do-while-single", "true");
etk::String outputRef = "action_A;\ndo {\n\taction_B; }\nwhile (true );\naction_D;";
etk::String output = interface.process(sourceIf1Action);
EXPECT_EQ(output, outputRef);
output = interface.process(sourceIf1ActionNoBrace);
EXPECT_EQ(output, outputRef);
}
TEST(testDoWhile, brace_0010) {
estyle::Generator interface;
//interface.properties.set("brace-do-while-in-new-line-before", "true");
//interface.properties.set("brace-do-while-in-new-line-after", "true");
interface.properties.set("brace-do-while-in-space-before", "true");
//interface.properties.set("brace-do-while-in-space-after", "true");
//interface.properties.set("brace-do-while-out-new-line-before", "true");
//interface.properties.set("brace-do-while-out-new-line-after", "true");
interface.properties.set("brace-do-while-out-space-before", "true");
//interface.properties.set("brace-do-while-out-space-after", "true");
//interface.properties.set("brace-do-while-single", "true");
etk::String outputRef = "action_A;\ndo {action_B; }while (true );\naction_D;";
etk::String output = interface.process(sourceIf1Action);
EXPECT_EQ(output, outputRef);
output = interface.process(sourceIf1ActionNoBrace);
EXPECT_EQ(output, outputRef);
}
TEST(testDoWhile, brace_0011) {
estyle::Generator interface;
//interface.properties.set("brace-do-while-in-new-line-before", "true");
//interface.properties.set("brace-do-while-in-new-line-after", "true");
interface.properties.set("brace-do-while-in-space-before", "true");
interface.properties.set("brace-do-while-in-space-after", "true");
//interface.properties.set("brace-do-while-out-new-line-before", "true");
//interface.properties.set("brace-do-while-out-new-line-after", "true");
interface.properties.set("brace-do-while-out-space-before", "true");
interface.properties.set("brace-do-while-out-space-after", "true");
//interface.properties.set("brace-do-while-single", "true");
etk::String outputRef = "action_A;\ndo { action_B; } while (true );\naction_D;";
etk::String output = interface.process(sourceIf1Action);
EXPECT_EQ(output, outputRef);
output = interface.process(sourceIf1ActionNoBrace);
EXPECT_EQ(output, outputRef);
}
TEST(testDoWhile, brace_0111) {
estyle::Generator interface;
//interface.properties.set("brace-do-while-in-new-line-before", "true");
interface.properties.set("brace-do-while-in-new-line-after", "true");
interface.properties.set("brace-do-while-in-space-before", "true");
interface.properties.set("brace-do-while-in-space-after", "true");
//interface.properties.set("brace-do-while-out-new-line-before", "true");
interface.properties.set("brace-do-while-out-new-line-after", "true");
interface.properties.set("brace-do-while-out-space-before", "true");
interface.properties.set("brace-do-while-out-space-after", "true");
//interface.properties.set("brace-do-while-single", "true");
etk::String outputRef = "action_A;\ndo {\n\taction_B; }\nwhile (true );\naction_D;";
etk::String output = interface.process(sourceIf1Action);
EXPECT_EQ(output, outputRef);
output = interface.process(sourceIf1ActionNoBrace);
EXPECT_EQ(output, outputRef);
}
TEST(testDoWhile, brace_0001) {
estyle::Generator interface;
//interface.properties.set("brace-do-while-in-new-line-before", "true");
//interface.properties.set("brace-do-while-in-new-line-after", "true");
//interface.properties.set("brace-do-while-in-space-before", "true");
interface.properties.set("brace-do-while-in-space-after", "true");
//interface.properties.set("brace-do-while-out-new-line-before", "true");
//interface.properties.set("brace-do-while-out-new-line-after", "true");
//interface.properties.set("brace-do-while-out-space-before", "true");
interface.properties.set("brace-do-while-out-space-after", "true");
//interface.properties.set("brace-do-while-single", "true");
etk::String outputRef = "action_A;\ndo{ action_B;} while (true );\naction_D;";
etk::String output = interface.process(sourceIf1Action);
EXPECT_EQ(output, outputRef);
output = interface.process(sourceIf1ActionNoBrace);
EXPECT_EQ(output, outputRef);
}
TEST(testDoWhile, brace_single_00) {
estyle::Generator interface;
//interface.properties.set("brace-do-while-single-one-line-size-max", "40");
interface.properties.set("brace-do-while-single", "true");
//interface.properties.set("brace-do-while-single-in-new-line", "true");
//interface.properties.set("brace-do-while-single-in-space", "true");
//interface.properties.set("brace-do-while-single-out-new-line", "true");
//interface.properties.set("brace-do-while-single-out-space", "true");
etk::String outputRef = "action_A;\ndo action_B;while (true );\naction_D;";
etk::String output = interface.process(sourceIf1Action);
EXPECT_EQ(output, outputRef);
output = interface.process(sourceIf1ActionNoBrace);
EXPECT_EQ(output, outputRef);
}
TEST(testDoWhile, brace_single_10) {
estyle::Generator interface;
//interface.properties.set("brace-do-while-single-one-line-size-max", "40");
interface.properties.set("brace-do-while-single", "true");
interface.properties.set("brace-do-while-single-in-new-line", "true");
//interface.properties.set("brace-do-while-single-in-space", "true");
interface.properties.set("brace-do-while-single-out-new-line", "true");
//interface.properties.set("brace-do-while-single-out-space", "true");
etk::String outputRef = "action_A;\ndo\n\taction_B;\nwhile (true );\naction_D;";
etk::String output = interface.process(sourceIf1Action);
EXPECT_EQ(output, outputRef);
output = interface.process(sourceIf1ActionNoBrace);
EXPECT_EQ(output, outputRef);
}
TEST(testDoWhile, brace_single_01) {
estyle::Generator interface;
//interface.properties.set("brace-do-while-single-one-line-size-max", "40");
interface.properties.set("brace-do-while-single", "true");
//interface.properties.set("brace-do-while-single-in-new-line", "true");
interface.properties.set("brace-do-while-single-in-space", "true");
//interface.properties.set("brace-do-while-single-out-new-line", "true");
interface.properties.set("brace-do-while-single-out-space", "true");
etk::String outputRef = "action_A;\ndo action_B; while (true );\naction_D;";
etk::String output = interface.process(sourceIf1Action);
EXPECT_EQ(output, outputRef);
output = interface.process(sourceIf1ActionNoBrace);
EXPECT_EQ(output, outputRef);
}
TEST(testDoWhile, brace_single_11) {
estyle::Generator interface;
//interface.properties.set("brace-do-while-single-one-line-size-max", "40");
interface.properties.set("brace-do-while-single", "true");
interface.properties.set("brace-do-while-single-in-new-line", "true");
interface.properties.set("brace-do-while-single-in-space", "true");
interface.properties.set("brace-do-while-single-out-new-line", "true");
interface.properties.set("brace-do-while-single-out-space", "true");
etk::String outputRef = "action_A;\ndo\n\taction_B;\nwhile (true );\naction_D;";
etk::String output = interface.process(sourceIf1Action);
EXPECT_EQ(output, outputRef);
output = interface.process(sourceIf1ActionNoBrace);
EXPECT_EQ(output, outputRef);
}