diff --git a/estyle/Generator.cpp b/estyle/Generator.cpp index abc90e8..df8671c 100644 --- a/estyle/Generator.cpp +++ b/estyle/Generator.cpp @@ -98,146 +98,6 @@ static void setPropertyDoxygenMultiLine(eproperty::List& _data) { _data.add(DOXYGEN_MULTI_LINE__NORMAL_SINGLE_LINE_EXCLAMATION, "single-line-exclamation"); } -estyle::GroupProperty::GroupProperty() : - inNewLineBefore(false), - inNewLineAfter(false), - inSpaceBefore(false), - inSpaceAfter(false), - inIndentBefore(false), - inIndentAfter(false), - outNewLineBefore(false), - outNewLineAfter(false), - outSpaceBefore(false), - outSpaceAfter(false), - outIndentBefore(false), - outIndentAfter(false), - oneLineIfSingleMaxSize(-1), - single(false), - singleInNewLine(false), - singleInSpace(false), - singleOutNewLine(false), - singleOutSpace(false) { - -} -estyle::GroupProperty::GroupProperty(class estyle::Generator* _generator, const etk::String& _groupName, const etk::String& _typeName, bool _allowSingle): - inNewLineBefore(_generator, _groupName + "-" + _typeName + "-in-new-line-before", false, "Set a new line before the input brace"), - inNewLineAfter(_generator, _groupName + "-" + _typeName + "-in-new-line-after", false, "Set a new line after the input brace"), - inSpaceBefore(_generator, _groupName + "-" + _typeName + "-in-space-before", false, "Set a space before the input brace (if not already present)"), - inSpaceAfter(_generator, _groupName + "-" + _typeName + "-in-space-after", false, "Set a space after the input brace (if not already present)"), - inIndentBefore(_generator, _groupName + "-" + _typeName + "-in-indent-before", false, "Increment indendation before adding brace"), - inIndentAfter(_generator, _groupName + "-" + _typeName + "-in-indent-after", false, "Increment indendation after adding brace"), - outNewLineBefore(_generator, _groupName + "-" + _typeName + "-out-new-line-before", false, "Set a new line before the input " + _groupName + ""), - outNewLineAfter(_generator, _groupName + "-" + _typeName + "-out-new-line-after", false, "Set a new line after the input " + _groupName + ""), - outSpaceBefore(_generator, _groupName + "-" + _typeName + "-out-space-before", false, "Set a space before the input " + _groupName + " (if not already present)"), - outSpaceAfter(_generator, _groupName + "-" + _typeName + "-out-space-after", false, "Set a space after the input " + _groupName + " (if not already present)"), - outIndentBefore(_generator, _groupName + "-" + _typeName + "-out-indent-before", false, "Decrement indendation before adding " + _groupName + ""), - outIndentAfter(_generator, _groupName + "-" + _typeName + "-out-indent-after", false, "Decrement indendation after adding " + _groupName + ""), - oneLineIfSingleMaxSize((_allowSingle==true? - etk::move(eproperty::Value(_generator, _groupName + "-" + _typeName + "-single-one-line-size-max", -1, "Set i a single line if the size if < XXX (-1 to disable)")): - etk::move(eproperty::Value(-1)) )), - single((_allowSingle==true? - etk::move(eproperty::Value(_generator, _groupName + "-" + _typeName + "-single", false, "remove or add " + _groupName + " if only 1 action is present.")): - etk::move(eproperty::Value(false)) )), - singleInNewLine((_allowSingle==true? - etk::move(eproperty::Value(_generator, _groupName + "-" + _typeName + "-single-in-new-line", false, "Set new line before action.")): - etk::move(eproperty::Value(false)) )), - singleInSpace((_allowSingle==true? - etk::move(eproperty::Value(_generator, _groupName + "-" + _typeName + "-single-in-space", false, "Set Space before action.")): - etk::move(eproperty::Value(false)) )), - singleOutNewLine((_allowSingle==true? - etk::move(eproperty::Value(_generator, _groupName + "-" + _typeName + "-single-out-new-line", false, "Set new line after action.")): - etk::move(eproperty::Value(false)) )), - singleOutSpace((_allowSingle==true? - etk::move(eproperty::Value(_generator, _groupName + "-" + _typeName + "-single-out-space", false, "Set space after action.")): - etk::move(eproperty::Value(false)) )) { - -} - -estyle::GroupProperty::GroupProperty(estyle::GroupProperty&& _obj) : - inNewLineBefore(etk::move(_obj.inNewLineBefore)), - inNewLineAfter(etk::move(_obj.inNewLineAfter)), - inSpaceBefore(etk::move(_obj.inSpaceBefore)), - inSpaceAfter(etk::move(_obj.inSpaceAfter)), - inIndentBefore(etk::move(_obj.inIndentBefore)), - inIndentAfter(etk::move(_obj.inIndentAfter)), - outNewLineBefore(etk::move(_obj.outNewLineBefore)), - outNewLineAfter(etk::move(_obj.outNewLineAfter)), - outSpaceBefore(etk::move(_obj.outSpaceBefore)), - outSpaceAfter(etk::move(_obj.outSpaceAfter)), - outIndentBefore(etk::move(_obj.outIndentBefore)), - outIndentAfter(etk::move(_obj.outIndentAfter)), - oneLineIfSingleMaxSize(etk::move(_obj.oneLineIfSingleMaxSize)), - single(etk::move(_obj.single)), - singleInNewLine(etk::move(_obj.singleInNewLine)), - singleInSpace(etk::move(_obj.singleInSpace)), - singleOutNewLine(etk::move(_obj.singleOutNewLine)), - singleOutSpace(etk::move(_obj.singleOutSpace)) { - -} - -estyle::GroupProperty& estyle::GroupProperty::operator=(GroupProperty&& _obj) { - inNewLineBefore = etk::move(_obj.inNewLineBefore); - inNewLineAfter = etk::move(_obj.inNewLineAfter); - inSpaceBefore = etk::move(_obj.inSpaceBefore); - inSpaceAfter = etk::move(_obj.inSpaceAfter); - inIndentBefore = etk::move(_obj.inIndentBefore); - inIndentAfter = etk::move(_obj.inIndentAfter); - outNewLineBefore = etk::move(_obj.outNewLineBefore); - outNewLineAfter = etk::move(_obj.outNewLineAfter); - outSpaceBefore = etk::move(_obj.outSpaceBefore); - outSpaceAfter = etk::move(_obj.outSpaceAfter); - outIndentBefore = etk::move(_obj.outIndentBefore); - outIndentAfter = etk::move(_obj.outIndentAfter); - oneLineIfSingleMaxSize = etk::move(_obj.oneLineIfSingleMaxSize); - single = etk::move(_obj.single); - singleInNewLine = etk::move(_obj.singleInNewLine); - singleInSpace = etk::move(_obj.singleInSpace); - singleOutNewLine = etk::move(_obj.singleOutNewLine); - singleOutSpace = etk::move(_obj.singleOutSpace); - return *this; -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - -estyle::ParentheseProperty::ParentheseProperty() : - inSpaceBefore(false), - inSpaceAfter(false), - outSpaceBefore(false), - outSpaceAfter(false), - oneLineMaxSize(20000) { - -} -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", 20000, "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(); @@ -269,13 +129,21 @@ estyle::Generator::Generator(): propertyBrace.set("switch", etk::move(estyle::GroupProperty(this, "brace", "switch", false))); propertyBrace.set("class", etk::move(estyle::GroupProperty(this, "brace", "class", false))); propertyBrace.set("struct", etk::move(estyle::GroupProperty(this, "brace", "struct", false))); + propertyBrace.set("try", etk::move(estyle::GroupProperty(this, "brace", "try", false))); + propertyBrace.set("catch", etk::move(estyle::GroupProperty(this, "brace", "catch", false))); propertyParenthese.set("if", etk::move(estyle::GroupProperty(this, "parenthese", "if"))); + propertyParenthese["if"].oneLineMaxSize.set(2000); propertyParenthese.set("for", etk::move(estyle::GroupProperty(this, "parenthese", "for"))); + propertyParenthese["for"].oneLineMaxSize.set(2000); propertyParenthese.set("while", etk::move(estyle::GroupProperty(this, "parenthese", "while"))); + propertyParenthese["while"].oneLineMaxSize.set(2000); propertyParenthese.set("do-while", etk::move(estyle::GroupProperty(this, "parenthese", "do-while"))); + propertyParenthese["do-while"].oneLineMaxSize.set(2000); propertyParenthese.set("switch", etk::move(estyle::GroupProperty(this, "parenthese", "switch"))); + propertyParenthese["switch"].oneLineMaxSize.set(2000); propertyParenthese.set("block", etk::move(estyle::GroupProperty(this, "parenthese", "block"))); + propertyParenthese["block"].oneLineMaxSize.set(2000); } @@ -309,11 +177,13 @@ etk::String estyle::Generator::getDoxygenNLine(const etk::String& _data) { } -void estyle::Generator::addNewLine() { - while ( ( m_output.back() == ' ' - || m_output.back() == '\t') - && m_output.size()>0) { - m_output.popBack(); +void estyle::Generator::addNewLine(bool _force) { + if (_force == false) { + while ( ( m_output.back() == ' ' + || m_output.back() == '\t') + && m_output.size()>0) { + m_output.popBack(); + } } if (m_output.size() == 0) { return; @@ -1039,58 +909,81 @@ int64_t estyle::Generator::generateBrace(int64_t _start, int64_t _stop, bool _ne ESTYLE_ERROR(" outNewLineAfter " << propertyBrace[m_type].outNewLineAfter.get()); */ int32_t rawSize = countRawSize(_start, _stop); - bool removeNewLine = propertyBrace[m_type].oneLineIfSingleMaxSize.get() >= rawSize; - ESTYLE_ERROR("check: " << propertyBrace[m_type].oneLineIfSingleMaxSize.get() << " >= " << rawSize); + ESTYLE_ERROR(" rawSize = " << rawSize); + bool removeNewLine = propertyBrace[m_type].oneLineMaxSize.get() >= rawSize; + ESTYLE_ERROR("check: " << propertyBrace[m_type].oneLineMaxSize.get() << " >= " << rawSize); if (_needBrace == false) { if (propertyBrace[m_type].single.get() == false) { _needBrace = true; } } - if (_needBrace == true) { + if ( _needBrace == true + || rawSize == 0) { + if (propertyBrace[m_type].inIndentBefore.get() == true) { + indentationPush(); + addIndent(); + } if ( propertyBrace[m_type].inNewLineBefore.get() == true && removeNewLine == false) { addNewLine(); - // add indentation addSpace(); } else if (propertyBrace[m_type].inSpaceBefore.get() == true) { - // add 1 space if needed addSpace(); } m_output += "{"; + if (propertyBrace[m_type].inIndentAfter.get() == true) { + indentationPush(); + } if ( propertyBrace[m_type].inNewLineAfter.get() == true && removeNewLine == false) { addNewLine(); - } else if (propertyBrace[m_type].inSpaceAfter.get() == true) { - // add 1 space if needed + } else if ( propertyBrace[m_type].inSpaceAfter.get() == true + && rawSize != 0) { addSpace(); } + if (rawSize == 0) { + if ( m_output.back() == '\n' + || m_output.back() == '\r') { + if (propertyBrace[m_type].emptyIndent.get() == true) { + addIndent(); + addNewLine(true); + } + } else if (propertyBrace[m_type].emptySpace.get() == true) { + addSpace(); + } + } } else { + if (propertyBrace[m_type].singleIndent.get() == true) { + indentationPush(); + } if ( propertyBrace[m_type].singleInNewLine.get() == true && removeNewLine == false) { addNewLine(); } else if (propertyBrace[m_type].singleInSpace.get() == true) { - // add 1 space if needed addSpace(); } else { addSpaceIfNeeded(); } } - indentationPush(); // TODO: maybe check the last element int64_t out = process(_start, _stop); - indentationPop(); if (_needBrace == true) { + if (propertyBrace[m_type].outUnIndentBefore.get() == true) { + indentationPop(); + } if ( propertyBrace[m_type].outNewLineBefore.get() == true && removeNewLine == false) { addNewLine(); - // add indentation addSpace(); - } else if (propertyBrace[m_type].outSpaceBefore.get() == true) { - // add 1 space if needed + } else if ( propertyBrace[m_type].outSpaceBefore.get() == true + && rawSize != 0) { addSpace(); } m_output += "}"; + if (propertyBrace[m_type].outUnIndentAfter.get() == true) { + indentationPop(); + } if ( propertyBrace[m_type].outSpaceAfter.get() == true && propertyBrace[m_type].outNewLineAfter.get() == false) { // add 1 space if needed @@ -1109,6 +1002,9 @@ int64_t estyle::Generator::generateBrace(int64_t _start, int64_t _stop, bool _ne } } } else { + if (propertyBrace[m_type].singleIndent.get() == true) { + indentationPop(); + } if (propertyBrace[m_type].singleOutSpace.get() == true) { // add 1 space if needed addSpace(); diff --git a/estyle/Generator.hpp b/estyle/Generator.hpp index 6550c82..3a4bd19 100644 --- a/estyle/Generator.hpp +++ b/estyle/Generator.hpp @@ -7,56 +7,13 @@ #include #include +#include #include #include #include #include namespace estyle { - class Generator; - class GroupProperty { - public: - GroupProperty(); - GroupProperty(estyle::Generator* _generator, const etk::String& _groupName, const etk::String& _typeName, bool _allowSingle=true); - eproperty::Value inNewLineBefore; - eproperty::Value inNewLineAfter; - eproperty::Value inSpaceBefore; - eproperty::Value inSpaceAfter; - eproperty::Value inIndentBefore; - eproperty::Value inIndentAfter; - eproperty::Value outNewLineBefore; - eproperty::Value outNewLineAfter; - eproperty::Value outSpaceBefore; - eproperty::Value outSpaceAfter; - eproperty::Value outIndentBefore; - eproperty::Value outIndentAfter; - eproperty::Value oneLineIfSingleMaxSize; - eproperty::Value single; - eproperty::Value singleInNewLine; - eproperty::Value singleInSpace; - eproperty::Value singleOutNewLine; - eproperty::Value singleOutSpace; - GroupProperty(const GroupProperty& _obj) = delete; - GroupProperty(GroupProperty&& _obj); - ~GroupProperty() = default; - GroupProperty& operator=(GroupProperty&& _obj); - GroupProperty& operator=(const GroupProperty& _obj) = delete; - }; - class ParentheseProperty { - public: - ParentheseProperty(); - ParentheseProperty(estyle::Generator* _generator, const etk::String& _typeName); - eproperty::Value inSpaceBefore; - eproperty::Value inSpaceAfter; - eproperty::Value outSpaceBefore; - eproperty::Value outSpaceAfter; - eproperty::Value 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(); @@ -114,7 +71,7 @@ namespace estyle { /** * @brief Add newline if no newLine is set before */ - void addNewLine(); + void addNewLine(bool _force=false); void addNewLineIfSemiColon(); /// check if the previous cheracter is a newline or not... bool onNewLine(); diff --git a/estyle/GroupProperty.cpp b/estyle/GroupProperty.cpp new file mode 100644 index 0000000..d569544 --- /dev/null +++ b/estyle/GroupProperty.cpp @@ -0,0 +1,119 @@ +/** + * @author Edouard DUPIN + * @copyright 2017, Edouard DUPIN, all right reserved + * @license MPL-2 (see license file) + */ +#include +#include + +estyle::GroupProperty::GroupProperty() : + inNewLineBefore(false), + inNewLineAfter(false), + inSpaceBefore(false), + inSpaceAfter(false), + inIndentBefore(false), + inIndentAfter(false), + outNewLineBefore(false), + outNewLineAfter(false), + outSpaceBefore(false), + outSpaceAfter(false), + outUnIndentBefore(false), + outUnIndentAfter(false), + oneLineMaxSize(-1), + single(false), + singleInNewLine(false), + singleInSpace(false), + singleOutNewLine(false), + singleOutSpace(false), + singleIndent(false), + emptySpace(false), + emptyIndent(false) { + +} + +estyle::GroupProperty::GroupProperty(class estyle::Generator* _generator, const etk::String& _groupName, const etk::String& _typeName, bool _allowSingle): + inNewLineBefore(_generator, _groupName + "-" + _typeName + "-in-new-line-before", false, "Set a new line before the input brace"), + inNewLineAfter(_generator, _groupName + "-" + _typeName + "-in-new-line-after", false, "Set a new line after the input brace"), + inSpaceBefore(_generator, _groupName + "-" + _typeName + "-in-space-before", false, "Set a space before the input brace (if not already present)"), + inSpaceAfter(_generator, _groupName + "-" + _typeName + "-in-space-after", false, "Set a space after the input brace (if not already present)"), + inIndentBefore(_generator, _groupName + "-" + _typeName + "-in-indent-before", false, "Increment indendation before adding brace"), + inIndentAfter(_generator, _groupName + "-" + _typeName + "-in-indent-after", false, "Increment indendation after adding brace"), + outNewLineBefore(_generator, _groupName + "-" + _typeName + "-out-new-line-before", false, "Set a new line before the input " + _groupName + ""), + outNewLineAfter(_generator, _groupName + "-" + _typeName + "-out-new-line-after", false, "Set a new line after the input " + _groupName + ""), + outSpaceBefore(_generator, _groupName + "-" + _typeName + "-out-space-before", false, "Set a space before the input " + _groupName + " (if not already present)"), + outSpaceAfter(_generator, _groupName + "-" + _typeName + "-out-space-after", false, "Set a space after the input " + _groupName + " (if not already present)"), + outUnIndentBefore(_generator, _groupName + "-" + _typeName + "-out-unindent-before", false, "Decrement indendation before adding " + _groupName + ""), + outUnIndentAfter(_generator, _groupName + "-" + _typeName + "-out-unindent-after", false, "Decrement indendation after adding " + _groupName + ""), + oneLineMaxSize(_generator, _groupName + "-" + _typeName + "-one-line-size-max", -1, "Set i a single line if the size if < XXX (-1 to disable)"), + single((_allowSingle==true? + etk::move(eproperty::Value(_generator, _groupName + "-" + _typeName + "-single", false, "remove or add " + _groupName + " if only 1 action is present.")): + etk::move(eproperty::Value(false)) )), + singleInNewLine((_allowSingle==true? + etk::move(eproperty::Value(_generator, _groupName + "-" + _typeName + "-single-in-new-line", false, "Set new line before action.")): + etk::move(eproperty::Value(false)) )), + singleInSpace((_allowSingle==true? + etk::move(eproperty::Value(_generator, _groupName + "-" + _typeName + "-single-in-space", false, "Set Space before action.")): + etk::move(eproperty::Value(false)) )), + singleOutNewLine((_allowSingle==true? + etk::move(eproperty::Value(_generator, _groupName + "-" + _typeName + "-single-out-new-line", false, "Set new line after action.")): + etk::move(eproperty::Value(false)) )), + singleOutSpace((_allowSingle==true? + etk::move(eproperty::Value(_generator, _groupName + "-" + _typeName + "-single-out-space", false, "Set space after action.")): + etk::move(eproperty::Value(false)) )), + singleIndent((_allowSingle==true? + etk::move(eproperty::Value(_generator, _groupName + "-" + _typeName + "-single-indent", false, "Enable indentation inside single element.")): + etk::move(eproperty::Value(false)) )), + emptySpace(_generator, _groupName + "-" + _typeName + "-empty-space", false, "Set One space inside the group"), + emptyIndent(_generator, _groupName + "-" + _typeName + "-empty-indent", false, "Set an indented empty line if multiple-line") { + +} + +estyle::GroupProperty::GroupProperty(estyle::GroupProperty&& _obj) : + inNewLineBefore(etk::move(_obj.inNewLineBefore)), + inNewLineAfter(etk::move(_obj.inNewLineAfter)), + inSpaceBefore(etk::move(_obj.inSpaceBefore)), + inSpaceAfter(etk::move(_obj.inSpaceAfter)), + inIndentBefore(etk::move(_obj.inIndentBefore)), + inIndentAfter(etk::move(_obj.inIndentAfter)), + outNewLineBefore(etk::move(_obj.outNewLineBefore)), + outNewLineAfter(etk::move(_obj.outNewLineAfter)), + outSpaceBefore(etk::move(_obj.outSpaceBefore)), + outSpaceAfter(etk::move(_obj.outSpaceAfter)), + outUnIndentBefore(etk::move(_obj.outUnIndentBefore)), + outUnIndentAfter(etk::move(_obj.outUnIndentAfter)), + oneLineMaxSize(etk::move(_obj.oneLineMaxSize)), + single(etk::move(_obj.single)), + singleInNewLine(etk::move(_obj.singleInNewLine)), + singleInSpace(etk::move(_obj.singleInSpace)), + singleOutNewLine(etk::move(_obj.singleOutNewLine)), + singleOutSpace(etk::move(_obj.singleOutSpace)), + singleIndent(etk::move(_obj.singleIndent)), + emptySpace(etk::move(_obj.emptySpace)), + emptyIndent(etk::move(_obj.emptyIndent)) { + +} + +estyle::GroupProperty& estyle::GroupProperty::operator=(GroupProperty&& _obj) { + inNewLineBefore = etk::move(_obj.inNewLineBefore); + inNewLineAfter = etk::move(_obj.inNewLineAfter); + inSpaceBefore = etk::move(_obj.inSpaceBefore); + inSpaceAfter = etk::move(_obj.inSpaceAfter); + inIndentBefore = etk::move(_obj.inIndentBefore); + inIndentAfter = etk::move(_obj.inIndentAfter); + outNewLineBefore = etk::move(_obj.outNewLineBefore); + outNewLineAfter = etk::move(_obj.outNewLineAfter); + outSpaceBefore = etk::move(_obj.outSpaceBefore); + outSpaceAfter = etk::move(_obj.outSpaceAfter); + outUnIndentBefore = etk::move(_obj.outUnIndentBefore); + outUnIndentAfter = etk::move(_obj.outUnIndentAfter); + oneLineMaxSize = etk::move(_obj.oneLineMaxSize); + single = etk::move(_obj.single); + singleInNewLine = etk::move(_obj.singleInNewLine); + singleInSpace = etk::move(_obj.singleInSpace); + singleOutNewLine = etk::move(_obj.singleOutNewLine); + singleOutSpace = etk::move(_obj.singleOutSpace); + singleIndent = etk::move(_obj.singleIndent); + emptySpace = etk::move(_obj.emptySpace); + emptyIndent = etk::move(_obj.emptyIndent); + return *this; +} diff --git a/estyle/GroupProperty.hpp b/estyle/GroupProperty.hpp new file mode 100644 index 0000000..8c938a5 --- /dev/null +++ b/estyle/GroupProperty.hpp @@ -0,0 +1,54 @@ +/** + * @author Edouard DUPIN + * @copyright 2017, Edouard DUPIN, all right reserved + * @license MPL-2 (see license file) + */ +#pragma once + +#include +#include +#include +#include +#include +#include +#include + +namespace estyle { + class Generator; + class GroupProperty { + public: + GroupProperty(); + GroupProperty(estyle::Generator* _generator, const etk::String& _groupName, const etk::String& _typeName, bool _allowSingle=true); + // in + eproperty::Value inNewLineBefore; + eproperty::Value inNewLineAfter; + eproperty::Value inSpaceBefore; + eproperty::Value inSpaceAfter; + eproperty::Value inIndentBefore; + eproperty::Value inIndentAfter; + // out + eproperty::Value outNewLineBefore; + eproperty::Value outNewLineAfter; + eproperty::Value outSpaceBefore; + eproperty::Value outSpaceAfter; + eproperty::Value outUnIndentBefore; + eproperty::Value outUnIndentAfter; + // single + eproperty::Value oneLineMaxSize; + eproperty::Value single; + eproperty::Value singleInNewLine; + eproperty::Value singleInSpace; + eproperty::Value singleOutNewLine; + eproperty::Value singleOutSpace; + eproperty::Value singleIndent; + // empty + eproperty::Value emptySpace; + eproperty::Value emptyIndent; + + GroupProperty(const GroupProperty& _obj) = delete; + GroupProperty(GroupProperty&& _obj); + ~GroupProperty() = default; + GroupProperty& operator=(GroupProperty&& _obj); + GroupProperty& operator=(const GroupProperty& _obj) = delete; + }; +} diff --git a/lutin_estyle.py b/lutin_estyle.py index 647a41c..2167382 100644 --- a/lutin_estyle.py +++ b/lutin_estyle.py @@ -19,6 +19,7 @@ def configure(target, my_module): my_module.add_src_file([ 'estyle/debug.cpp', 'estyle/estyle.cpp', + 'estyle/GroupProperty.cpp', 'estyle/Generator.cpp', 'estyle/lexer/Lexer.cpp', 'estyle/lexer/tocken.cpp', @@ -26,6 +27,7 @@ def configure(target, my_module): my_module.add_header_file([ 'estyle/debug.hpp', 'estyle/estyle.hpp', + 'estyle/GroupProperty.hpp', 'estyle/Generator.hpp', 'estyle/lexer/Lexer.hpp', 'estyle/lexer/tocken.hpp', diff --git a/test/testIf.cpp b/test/testIf.cpp index 439ffab..bfe0eb4 100644 --- a/test/testIf.cpp +++ b/test/testIf.cpp @@ -10,39 +10,29 @@ #include #include +static etk::String sourceIf0Action = "action_A;if(true){}action_D;"; 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;"; -TEST(testIf, brace_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 outRef = "action_A;if(true){action_B;}action_D;"; - etk::String output = interface.process(sourceIf1Action); - EXPECT_EQ(output, outRef); - output = interface.process(sourceIf1ActionNoBrace); - EXPECT_EQ(output, outRef); -} - -TEST(testIf, brace_1000) { +TEST(testIf, brace_100000) { estyle::Generator interface; + // in: 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-in-indent-before", "true"); + //interface.properties.set("brace-if-in-indent-after", "true"); + // out: 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-out-unindent-after", "true"); + //interface.properties.set("brace-if-out-unindent-before", "true"); + // single: //interface.properties.set("brace-if-single", "true"); etk::String outRef = "action_A;if(true)\n{action_B;\n}action_D;"; etk::String output = interface.process(sourceIf1Action); @@ -51,16 +41,23 @@ TEST(testIf, brace_1000) { EXPECT_EQ(output, outRef); } -TEST(testIf, brace_1010) { +TEST(testIf, brace_101000) { estyle::Generator interface; + // in: 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-in-indent-before", "true"); + //interface.properties.set("brace-if-in-indent-after", "true"); + // out: 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-out-unindent-after", "true"); + //interface.properties.set("brace-if-out-unindent-before", "true"); + // single: //interface.properties.set("brace-if-single", "true"); etk::String outRef = "action_A;if(true)\n{action_B;\n}action_D;"; etk::String output = interface.process(sourceIf1Action); @@ -69,16 +66,23 @@ TEST(testIf, brace_1010) { EXPECT_EQ(output, outRef); } -TEST(testIf, brace_1011) { +TEST(testIf, brace_101100) { estyle::Generator interface; + // in: 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-in-indent-before", "true"); + //interface.properties.set("brace-if-in-indent-after", "true"); + // out: 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-out-unindent-after", "true"); + //interface.properties.set("brace-if-out-unindent-before", "true"); + // single: //interface.properties.set("brace-if-single", "true"); etk::String outRef = "action_A;if(true)\n{ action_B;\n} action_D;"; etk::String output = interface.process(sourceIf1Action); @@ -87,88 +91,123 @@ TEST(testIf, brace_1011) { EXPECT_EQ(output, outRef); } -TEST(testIf, brace_1100) { +TEST(testIf, brace_110000) { estyle::Generator interface; + // in: 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-in-indent-before", "true"); + //interface.properties.set("brace-if-in-indent-after", "true"); + // out: 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-out-unindent-after", "true"); + //interface.properties.set("brace-if-out-unindent-before", "true"); + // single: //interface.properties.set("brace-if-single", "true"); - etk::String outRef = "action_A;if(true)\n{\n\taction_B;\n}\naction_D;"; + etk::String outRef = "action_A;if(true)\n{\naction_B;\n}\naction_D;"; etk::String output = interface.process(sourceIf1Action); EXPECT_EQ(output, outRef); output = interface.process(sourceIf1ActionNoBrace); EXPECT_EQ(output, outRef); } -TEST(testIf, brace_1101) { +TEST(testIf, brace_110100) { estyle::Generator interface; + // in: 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-in-indent-before", "true"); + //interface.properties.set("brace-if-in-indent-after", "true"); + // out: 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-out-unindent-after", "true"); + //interface.properties.set("brace-if-out-unindent-before", "true"); + // single: //interface.properties.set("brace-if-single", "true"); - etk::String outRef = "action_A;if(true)\n{\n\taction_B;\n}\naction_D;"; + etk::String outRef = "action_A;if(true)\n{\naction_B;\n}\naction_D;"; etk::String output = interface.process(sourceIf1Action); EXPECT_EQ(output, outRef); output = interface.process(sourceIf1ActionNoBrace); EXPECT_EQ(output, outRef); } -TEST(testIf, brace_1110) { +TEST(testIf, brace_111000) { estyle::Generator interface; + // in: 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-in-indent-before", "true"); + //interface.properties.set("brace-if-in-indent-after", "true"); + // out: 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-out-unindent-after", "true"); + //interface.properties.set("brace-if-out-unindent-before", "true"); + // single: //interface.properties.set("brace-if-single", "true"); - etk::String outRef = "action_A;if(true)\n{\n\taction_B;\n}\naction_D;"; + etk::String outRef = "action_A;if(true)\n{\naction_B;\n}\naction_D;"; etk::String output = interface.process(sourceIf1Action); EXPECT_EQ(output, outRef); output = interface.process(sourceIf1ActionNoBrace); EXPECT_EQ(output, outRef); } -TEST(testIf, brace_1111) { +TEST(testIf, brace_111100) { estyle::Generator interface; + // in: 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-in-indent-before", "true"); + //interface.properties.set("brace-if-in-indent-after", "true"); + // out: 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-out-unindent-after", "true"); + //interface.properties.set("brace-if-out-unindent-before", "true"); + // single: //interface.properties.set("brace-if-single", "true"); - etk::String outRef = "action_A;if(true)\n{\n\taction_B;\n}\naction_D;"; + etk::String outRef = "action_A;if(true)\n{\naction_B;\n}\naction_D;"; etk::String output = interface.process(sourceIf1Action); EXPECT_EQ(output, outRef); output = interface.process(sourceIf1ActionNoBrace); EXPECT_EQ(output, outRef); } -TEST(testIf, brace_1001) { +TEST(testIf, brace_100100) { estyle::Generator interface; + // in: 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-in-indent-before", "true"); + //interface.properties.set("brace-if-in-indent-after", "true"); + // out: 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-out-unindent-after", "true"); + //interface.properties.set("brace-if-out-unindent-before", "true"); + // single: //interface.properties.set("brace-if-single", "true"); etk::String outRef = "action_A;if(true)\n{ action_B;\n} action_D;"; etk::String output = interface.process(sourceIf1Action); @@ -178,70 +217,98 @@ TEST(testIf, brace_1001) { } -TEST(testIf, brace_0100) { +TEST(testIf, brace_010000) { estyle::Generator interface; + // in: //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-in-indent-before", "true"); + //interface.properties.set("brace-if-in-indent-after", "true"); + // out: //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-out-unindent-after", "true"); + //interface.properties.set("brace-if-out-unindent-before", "true"); + // single: //interface.properties.set("brace-if-single", "true"); - etk::String outRef = "action_A;if(true){\n\taction_B;}\naction_D;"; + etk::String outRef = "action_A;if(true){\naction_B;}\naction_D;"; etk::String output = interface.process(sourceIf1Action); EXPECT_EQ(output, outRef); output = interface.process(sourceIf1ActionNoBrace); EXPECT_EQ(output, outRef); } -TEST(testIf, brace_0101) { +TEST(testIf, brace_010100) { estyle::Generator interface; + // in: //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-in-indent-before", "true"); + //interface.properties.set("brace-if-in-indent-after", "true"); + // out: //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-out-unindent-after", "true"); + //interface.properties.set("brace-if-out-unindent-before", "true"); + // single: //interface.properties.set("brace-if-single", "true"); - etk::String outRef = "action_A;if(true){\n\taction_B;}\naction_D;"; + etk::String outRef = "action_A;if(true){\naction_B;}\naction_D;"; etk::String output = interface.process(sourceIf1Action); EXPECT_EQ(output, outRef); output = interface.process(sourceIf1ActionNoBrace); EXPECT_EQ(output, outRef); } -TEST(testIf, brace_0110) { +TEST(testIf, brace_011000) { estyle::Generator interface; + // in: //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-in-indent-before", "true"); + //interface.properties.set("brace-if-in-indent-after", "true"); + // out: //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-out-unindent-after", "true"); + //interface.properties.set("brace-if-out-unindent-before", "true"); + // single: //interface.properties.set("brace-if-single", "true"); - etk::String outRef = "action_A;if(true) {\n\taction_B; }\naction_D;"; + etk::String outRef = "action_A;if(true) {\naction_B; }\naction_D;"; etk::String output = interface.process(sourceIf1Action); EXPECT_EQ(output, outRef); output = interface.process(sourceIf1ActionNoBrace); EXPECT_EQ(output, outRef); } -TEST(testIf, brace_0010) { +TEST(testIf, brace_001000) { estyle::Generator interface; + // in: //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-in-indent-before", "true"); + //interface.properties.set("brace-if-in-indent-after", "true"); + // out: //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-out-unindent-after", "true"); + //interface.properties.set("brace-if-out-unindent-before", "true"); + // single: //interface.properties.set("brace-if-single", "true"); etk::String outRef = "action_A;if(true) {action_B; }action_D;"; etk::String output = interface.process(sourceIf1Action); @@ -250,16 +317,23 @@ TEST(testIf, brace_0010) { EXPECT_EQ(output, outRef); } -TEST(testIf, brace_0011) { +TEST(testIf, brace_001100) { estyle::Generator interface; + // in: //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-in-indent-before", "true"); + //interface.properties.set("brace-if-in-indent-after", "true"); + // out: //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-out-unindent-after", "true"); + //interface.properties.set("brace-if-out-unindent-before", "true"); + // single: //interface.properties.set("brace-if-single", "true"); etk::String outRef = "action_A;if(true) { action_B; } action_D;"; etk::String output = interface.process(sourceIf1Action); @@ -268,16 +342,324 @@ TEST(testIf, brace_0011) { EXPECT_EQ(output, outRef); } -TEST(testIf, brace_0111) { +TEST(testIf, brace_011100) { estyle::Generator interface; + // in: //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-in-indent-before", "true"); + //interface.properties.set("brace-if-in-indent-after", "true"); + // out: //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-out-unindent-after", "true"); + //interface.properties.set("brace-if-out-unindent-before", "true"); + // single: + //interface.properties.set("brace-if-single", "true"); + etk::String outRef = "action_A;if(true) {\naction_B; }\naction_D;"; + etk::String output = interface.process(sourceIf1Action); + EXPECT_EQ(output, outRef); + output = interface.process(sourceIf1ActionNoBrace); + EXPECT_EQ(output, outRef); +} + +TEST(testIf, brace_000100) { + estyle::Generator interface; + // in: + //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-in-indent-before", "true"); + //interface.properties.set("brace-if-in-indent-after", "true"); + // out: + //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-out-unindent-after", "true"); + //interface.properties.set("brace-if-out-unindent-before", "true"); + // single: + //interface.properties.set("brace-if-single", "true"); + etk::String outRef = "action_A;if(true){ action_B;} action_D;"; + etk::String output = interface.process(sourceIf1Action); + EXPECT_EQ(output, outRef); + output = interface.process(sourceIf1ActionNoBrace); + EXPECT_EQ(output, outRef); +} +///////////////////////////////////////////////////////////////////////////////////////// +TEST(testIf, brace_100001) { + estyle::Generator interface; + // in: + 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-in-indent-before", "true"); + interface.properties.set("brace-if-in-indent-after", "true"); + // out: + 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-out-unindent-after", "true"); + interface.properties.set("brace-if-out-unindent-before", "true"); + // single: + //interface.properties.set("brace-if-single", "true"); + etk::String outRef = "action_A;if(true)\n{action_B;\n}action_D;"; + etk::String output = interface.process(sourceIf1Action); + EXPECT_EQ(output, outRef); + output = interface.process(sourceIf1ActionNoBrace); + EXPECT_EQ(output, outRef); +} + +TEST(testIf, brace_101001) { + estyle::Generator interface; + // in: + 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-in-indent-before", "true"); + interface.properties.set("brace-if-in-indent-after", "true"); + // out: + 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-out-unindent-after", "true"); + interface.properties.set("brace-if-out-unindent-before", "true"); + // single: + //interface.properties.set("brace-if-single", "true"); + etk::String outRef = "action_A;if(true)\n{action_B;\n}action_D;"; + etk::String output = interface.process(sourceIf1Action); + EXPECT_EQ(output, outRef); + output = interface.process(sourceIf1ActionNoBrace); + EXPECT_EQ(output, outRef); +} + +TEST(testIf, brace_101101) { + estyle::Generator interface; + // in: + 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-in-indent-before", "true"); + interface.properties.set("brace-if-in-indent-after", "true"); + // out: + 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-out-unindent-after", "true"); + interface.properties.set("brace-if-out-unindent-before", "true"); + // single: + //interface.properties.set("brace-if-single", "true"); + etk::String outRef = "action_A;if(true)\n{ action_B;\n} action_D;"; + etk::String output = interface.process(sourceIf1Action); + EXPECT_EQ(output, outRef); + output = interface.process(sourceIf1ActionNoBrace); + EXPECT_EQ(output, outRef); +} + +TEST(testIf, brace_110001) { + estyle::Generator interface; + // in: + 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-in-indent-before", "true"); + interface.properties.set("brace-if-in-indent-after", "true"); + // out: + 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-out-unindent-after", "true"); + interface.properties.set("brace-if-out-unindent-before", "true"); + // single: + //interface.properties.set("brace-if-single", "true"); + etk::String outRef = "action_A;if(true)\n{\n\taction_B;\n}\naction_D;"; + etk::String output = interface.process(sourceIf1Action); + EXPECT_EQ(output, outRef); + output = interface.process(sourceIf1ActionNoBrace); + EXPECT_EQ(output, outRef); +} + +TEST(testIf, brace_110101) { + estyle::Generator interface; + // in: + 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-in-indent-before", "true"); + interface.properties.set("brace-if-in-indent-after", "true"); + // out: + 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-out-unindent-after", "true"); + interface.properties.set("brace-if-out-unindent-before", "true"); + // single: + //interface.properties.set("brace-if-single", "true"); + etk::String outRef = "action_A;if(true)\n{\n\taction_B;\n}\naction_D;"; + etk::String output = interface.process(sourceIf1Action); + EXPECT_EQ(output, outRef); + output = interface.process(sourceIf1ActionNoBrace); + EXPECT_EQ(output, outRef); +} + +TEST(testIf, brace_111001) { + estyle::Generator interface; + // in: + 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-in-indent-before", "true"); + interface.properties.set("brace-if-in-indent-after", "true"); + // out: + 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-out-unindent-after", "true"); + interface.properties.set("brace-if-out-unindent-before", "true"); + // single: + //interface.properties.set("brace-if-single", "true"); + etk::String outRef = "action_A;if(true)\n{\n\taction_B;\n}\naction_D;"; + etk::String output = interface.process(sourceIf1Action); + EXPECT_EQ(output, outRef); + output = interface.process(sourceIf1ActionNoBrace); + EXPECT_EQ(output, outRef); +} + +TEST(testIf, brace_111101) { + estyle::Generator interface; + // in: + 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-in-indent-before", "true"); + interface.properties.set("brace-if-in-indent-after", "true"); + // out: + 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-out-unindent-after", "true"); + interface.properties.set("brace-if-out-unindent-before", "true"); + // single: + //interface.properties.set("brace-if-single", "true"); + etk::String outRef = "action_A;if(true)\n{\n\taction_B;\n}\naction_D;"; + etk::String output = interface.process(sourceIf1Action); + EXPECT_EQ(output, outRef); + output = interface.process(sourceIf1ActionNoBrace); + EXPECT_EQ(output, outRef); +} + +TEST(testIf, brace_100101) { + estyle::Generator interface; + // in: + 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-in-indent-before", "true"); + interface.properties.set("brace-if-in-indent-after", "true"); + // out: + 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-out-unindent-after", "true"); + interface.properties.set("brace-if-out-unindent-before", "true"); + // single: + //interface.properties.set("brace-if-single", "true"); + etk::String outRef = "action_A;if(true)\n{ action_B;\n} action_D;"; + etk::String output = interface.process(sourceIf1Action); + EXPECT_EQ(output, outRef); + output = interface.process(sourceIf1ActionNoBrace); + EXPECT_EQ(output, outRef); +} + + +TEST(testIf, brace_010001) { + estyle::Generator interface; + // in: + //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-in-indent-before", "true"); + interface.properties.set("brace-if-in-indent-after", "true"); + // out: + //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-out-unindent-after", "true"); + interface.properties.set("brace-if-out-unindent-before", "true"); + // single: + //interface.properties.set("brace-if-single", "true"); + etk::String outRef = "action_A;if(true){\n\taction_B;}\naction_D;"; + etk::String output = interface.process(sourceIf1Action); + EXPECT_EQ(output, outRef); + output = interface.process(sourceIf1ActionNoBrace); + EXPECT_EQ(output, outRef); +} + +TEST(testIf, brace_010101) { + estyle::Generator interface; + // in: + //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-in-indent-before", "true"); + interface.properties.set("brace-if-in-indent-after", "true"); + // out: + //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-out-unindent-after", "true"); + interface.properties.set("brace-if-out-unindent-before", "true"); + // single: + //interface.properties.set("brace-if-single", "true"); + etk::String outRef = "action_A;if(true){\n\taction_B;}\naction_D;"; + etk::String output = interface.process(sourceIf1Action); + EXPECT_EQ(output, outRef); + output = interface.process(sourceIf1ActionNoBrace); + EXPECT_EQ(output, outRef); +} + +TEST(testIf, brace_011001) { + estyle::Generator interface; + // in: + //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-in-indent-before", "true"); + interface.properties.set("brace-if-in-indent-after", "true"); + // out: + //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-out-unindent-after", "true"); + interface.properties.set("brace-if-out-unindent-before", "true"); + // single: //interface.properties.set("brace-if-single", "true"); etk::String outRef = "action_A;if(true) {\n\taction_B; }\naction_D;"; etk::String output = interface.process(sourceIf1Action); @@ -286,16 +668,98 @@ TEST(testIf, brace_0111) { EXPECT_EQ(output, outRef); } -TEST(testIf, brace_0001) { +TEST(testIf, brace_001001) { estyle::Generator interface; + // in: + //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-in-indent-before", "true"); + interface.properties.set("brace-if-in-indent-after", "true"); + // out: + //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-out-unindent-after", "true"); + interface.properties.set("brace-if-out-unindent-before", "true"); + // single: + //interface.properties.set("brace-if-single", "true"); + etk::String outRef = "action_A;if(true) {action_B; }action_D;"; + etk::String output = interface.process(sourceIf1Action); + EXPECT_EQ(output, outRef); + output = interface.process(sourceIf1ActionNoBrace); + EXPECT_EQ(output, outRef); +} + +TEST(testIf, brace_001101) { + estyle::Generator interface; + // in: + //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-in-indent-before", "true"); + interface.properties.set("brace-if-in-indent-after", "true"); + // out: + //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-out-unindent-after", "true"); + interface.properties.set("brace-if-out-unindent-before", "true"); + // single: + //interface.properties.set("brace-if-single", "true"); + etk::String outRef = "action_A;if(true) { action_B; } action_D;"; + etk::String output = interface.process(sourceIf1Action); + EXPECT_EQ(output, outRef); + output = interface.process(sourceIf1ActionNoBrace); + EXPECT_EQ(output, outRef); +} + +TEST(testIf, brace_011101) { + estyle::Generator interface; + // in: + //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-in-indent-before", "true"); + interface.properties.set("brace-if-in-indent-after", "true"); + // out: + //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-out-unindent-after", "true"); + interface.properties.set("brace-if-out-unindent-before", "true"); + // single: + //interface.properties.set("brace-if-single", "true"); + etk::String outRef = "action_A;if(true) {\n\taction_B; }\naction_D;"; + etk::String output = interface.process(sourceIf1Action); + EXPECT_EQ(output, outRef); + output = interface.process(sourceIf1ActionNoBrace); + EXPECT_EQ(output, outRef); +} + +TEST(testIf, brace_000101) { + estyle::Generator interface; + // in: //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-in-indent-before", "true"); + interface.properties.set("brace-if-in-indent-after", "true"); + // out: //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-out-unindent-after", "true"); + interface.properties.set("brace-if-out-unindent-before", "true"); + // single: //interface.properties.set("brace-if-single", "true"); etk::String outRef = "action_A;if(true){ action_B;} action_D;"; etk::String output = interface.process(sourceIf1Action); @@ -303,16 +767,777 @@ TEST(testIf, brace_0001) { output = interface.process(sourceIf1ActionNoBrace); EXPECT_EQ(output, outRef); } - - -TEST(testIf, brace_single_00) { +///////////////////////////////////////////////////////////////////////////////////////// +TEST(testIf, brace_100010) { estyle::Generator interface; - //interface.properties.set("brace-if-single-one-line-size-max", "40"); + // in: + 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-in-indent-before", "true"); + //interface.properties.set("brace-if-in-indent-after", "true"); + // out: + 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-out-unindent-after", "true"); + //interface.properties.set("brace-if-out-unindent-before", "true"); + // single: + //interface.properties.set("brace-if-single", "true"); + etk::String outRef = "action_A;if(true)\n\t{action_B;\n\t}action_D;"; + etk::String output = interface.process(sourceIf1Action); + EXPECT_EQ(output, outRef); + output = interface.process(sourceIf1ActionNoBrace); + EXPECT_EQ(output, outRef); +} + +TEST(testIf, brace_101010) { + estyle::Generator interface; + // in: + 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-in-indent-before", "true"); + //interface.properties.set("brace-if-in-indent-after", "true"); + // out: + 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-out-unindent-after", "true"); + //interface.properties.set("brace-if-out-unindent-before", "true"); + // single: + //interface.properties.set("brace-if-single", "true"); + etk::String outRef = "action_A;if(true)\n\t{action_B;\n\t}action_D;"; + etk::String output = interface.process(sourceIf1Action); + EXPECT_EQ(output, outRef); + output = interface.process(sourceIf1ActionNoBrace); + EXPECT_EQ(output, outRef); +} + +TEST(testIf, brace_101110) { + estyle::Generator interface; + // in: + 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-in-indent-before", "true"); + //interface.properties.set("brace-if-in-indent-after", "true"); + // out: + 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-out-unindent-after", "true"); + //interface.properties.set("brace-if-out-unindent-before", "true"); + // single: + //interface.properties.set("brace-if-single", "true"); + etk::String outRef = "action_A;if(true)\n\t{ action_B;\n\t} action_D;"; + etk::String output = interface.process(sourceIf1Action); + EXPECT_EQ(output, outRef); + output = interface.process(sourceIf1ActionNoBrace); + EXPECT_EQ(output, outRef); +} + +TEST(testIf, brace_110010) { + estyle::Generator interface; + // in: + 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-in-indent-before", "true"); + //interface.properties.set("brace-if-in-indent-after", "true"); + // out: + 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-out-unindent-after", "true"); + //interface.properties.set("brace-if-out-unindent-before", "true"); + // single: + //interface.properties.set("brace-if-single", "true"); + etk::String outRef = "action_A;if(true)\n\t{\n\taction_B;\n\t}\naction_D;"; + etk::String output = interface.process(sourceIf1Action); + EXPECT_EQ(output, outRef); + output = interface.process(sourceIf1ActionNoBrace); + EXPECT_EQ(output, outRef); +} + +TEST(testIf, brace_110110) { + estyle::Generator interface; + // in: + 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-in-indent-before", "true"); + //interface.properties.set("brace-if-in-indent-after", "true"); + // out: + 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-out-unindent-after", "true"); + //interface.properties.set("brace-if-out-unindent-before", "true"); + // single: + //interface.properties.set("brace-if-single", "true"); + etk::String outRef = "action_A;if(true)\n\t{\n\taction_B;\n\t}\naction_D;"; + etk::String output = interface.process(sourceIf1Action); + EXPECT_EQ(output, outRef); + output = interface.process(sourceIf1ActionNoBrace); + EXPECT_EQ(output, outRef); +} + +TEST(testIf, brace_111010) { + estyle::Generator interface; + // in: + 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-in-indent-before", "true"); + //interface.properties.set("brace-if-in-indent-after", "true"); + // out: + 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-out-unindent-after", "true"); + //interface.properties.set("brace-if-out-unindent-before", "true"); + // single: + //interface.properties.set("brace-if-single", "true"); + etk::String outRef = "action_A;if(true)\n\t{\n\taction_B;\n\t}\naction_D;"; + etk::String output = interface.process(sourceIf1Action); + EXPECT_EQ(output, outRef); + output = interface.process(sourceIf1ActionNoBrace); + EXPECT_EQ(output, outRef); +} + +TEST(testIf, brace_111110) { + estyle::Generator interface; + // in: + 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-in-indent-before", "true"); + //interface.properties.set("brace-if-in-indent-after", "true"); + // out: + 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-out-unindent-after", "true"); + //interface.properties.set("brace-if-out-unindent-before", "true"); + // single: + //interface.properties.set("brace-if-single", "true"); + etk::String outRef = "action_A;if(true)\n\t{\n\taction_B;\n\t}\naction_D;"; + etk::String output = interface.process(sourceIf1Action); + EXPECT_EQ(output, outRef); + output = interface.process(sourceIf1ActionNoBrace); + EXPECT_EQ(output, outRef); +} + +TEST(testIf, brace_100110) { + estyle::Generator interface; + // in: + 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-in-indent-before", "true"); + //interface.properties.set("brace-if-in-indent-after", "true"); + // out: + 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-out-unindent-after", "true"); + //interface.properties.set("brace-if-out-unindent-before", "true"); + // single: + //interface.properties.set("brace-if-single", "true"); + etk::String outRef = "action_A;if(true)\n\t{ action_B;\n\t} action_D;"; + etk::String output = interface.process(sourceIf1Action); + EXPECT_EQ(output, outRef); + output = interface.process(sourceIf1ActionNoBrace); + EXPECT_EQ(output, outRef); +} + + +TEST(testIf, brace_010010) { + estyle::Generator interface; + // in: + //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-in-indent-before", "true"); + //interface.properties.set("brace-if-in-indent-after", "true"); + // out: + //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-out-unindent-after", "true"); + //interface.properties.set("brace-if-out-unindent-before", "true"); + // single: + //interface.properties.set("brace-if-single", "true"); + etk::String outRef = "action_A;if(true){\n\taction_B;}\naction_D;"; + etk::String output = interface.process(sourceIf1Action); + EXPECT_EQ(output, outRef); + output = interface.process(sourceIf1ActionNoBrace); + EXPECT_EQ(output, outRef); +} + +TEST(testIf, brace_010110) { + estyle::Generator interface; + // in: + //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-in-indent-before", "true"); + //interface.properties.set("brace-if-in-indent-after", "true"); + // out: + //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-out-unindent-after", "true"); + //interface.properties.set("brace-if-out-unindent-before", "true"); + // single: + //interface.properties.set("brace-if-single", "true"); + etk::String outRef = "action_A;if(true){\n\taction_B;}\naction_D;"; + etk::String output = interface.process(sourceIf1Action); + EXPECT_EQ(output, outRef); + output = interface.process(sourceIf1ActionNoBrace); + EXPECT_EQ(output, outRef); +} + +TEST(testIf, brace_011010) { + estyle::Generator interface; + // in: + //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-in-indent-before", "true"); + //interface.properties.set("brace-if-in-indent-after", "true"); + // out: + //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-out-unindent-after", "true"); + //interface.properties.set("brace-if-out-unindent-before", "true"); + // single: + //interface.properties.set("brace-if-single", "true"); + etk::String outRef = "action_A;if(true) {\n\taction_B; }\naction_D;"; + etk::String output = interface.process(sourceIf1Action); + EXPECT_EQ(output, outRef); + output = interface.process(sourceIf1ActionNoBrace); + EXPECT_EQ(output, outRef); +} + +TEST(testIf, brace_001010) { + estyle::Generator interface; + // in: + //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-in-indent-before", "true"); + //interface.properties.set("brace-if-in-indent-after", "true"); + // out: + //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-out-unindent-after", "true"); + //interface.properties.set("brace-if-out-unindent-before", "true"); + // single: + //interface.properties.set("brace-if-single", "true"); + etk::String outRef = "action_A;if(true) {action_B; }action_D;"; + etk::String output = interface.process(sourceIf1Action); + EXPECT_EQ(output, outRef); + output = interface.process(sourceIf1ActionNoBrace); + EXPECT_EQ(output, outRef); +} + +TEST(testIf, brace_001110) { + estyle::Generator interface; + // in: + //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-in-indent-before", "true"); + //interface.properties.set("brace-if-in-indent-after", "true"); + // out: + //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-out-unindent-after", "true"); + //interface.properties.set("brace-if-out-unindent-before", "true"); + // single: + //interface.properties.set("brace-if-single", "true"); + etk::String outRef = "action_A;if(true) { action_B; } action_D;"; + etk::String output = interface.process(sourceIf1Action); + EXPECT_EQ(output, outRef); + output = interface.process(sourceIf1ActionNoBrace); + EXPECT_EQ(output, outRef); +} + +TEST(testIf, brace_011110) { + estyle::Generator interface; + // in: + //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-in-indent-before", "true"); + //interface.properties.set("brace-if-in-indent-after", "true"); + // out: + //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-out-unindent-after", "true"); + //interface.properties.set("brace-if-out-unindent-before", "true"); + // single: + //interface.properties.set("brace-if-single", "true"); + etk::String outRef = "action_A;if(true) {\n\taction_B; }\naction_D;"; + etk::String output = interface.process(sourceIf1Action); + EXPECT_EQ(output, outRef); + output = interface.process(sourceIf1ActionNoBrace); + EXPECT_EQ(output, outRef); +} + +TEST(testIf, brace_000110) { + estyle::Generator interface; + // in: + //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-in-indent-before", "true"); + //interface.properties.set("brace-if-in-indent-after", "true"); + // out: + //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-out-unindent-after", "true"); + //interface.properties.set("brace-if-out-unindent-before", "true"); + // single: + //interface.properties.set("brace-if-single", "true"); + etk::String outRef = "action_A;if(true){ action_B;} action_D;"; + etk::String output = interface.process(sourceIf1Action); + EXPECT_EQ(output, outRef); + output = interface.process(sourceIf1ActionNoBrace); + EXPECT_EQ(output, outRef); +} +///////////////////////////////////////////////////////////////////////////////////////// +TEST(testIf, brace_100011) { + estyle::Generator interface; + // in: + 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-in-indent-before", "true"); + interface.properties.set("brace-if-in-indent-after", "true"); + // out: + 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-out-unindent-after", "true"); + interface.properties.set("brace-if-out-unindent-before", "true"); + // single: + //interface.properties.set("brace-if-single", "true"); + etk::String outRef = "action_A;if(true)\n\t{action_B;\n\t}action_D;"; + etk::String output = interface.process(sourceIf1Action); + EXPECT_EQ(output, outRef); + output = interface.process(sourceIf1ActionNoBrace); + EXPECT_EQ(output, outRef); +} + +TEST(testIf, brace_101011) { + estyle::Generator interface; + // in: + 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-in-indent-before", "true"); + interface.properties.set("brace-if-in-indent-after", "true"); + // out: + 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-out-unindent-after", "true"); + interface.properties.set("brace-if-out-unindent-before", "true"); + // single: + //interface.properties.set("brace-if-single", "true"); + etk::String outRef = "action_A;if(true)\n\t{action_B;\n\t}action_D;"; + etk::String output = interface.process(sourceIf1Action); + EXPECT_EQ(output, outRef); + output = interface.process(sourceIf1ActionNoBrace); + EXPECT_EQ(output, outRef); +} + +TEST(testIf, brace_101111) { + estyle::Generator interface; + // in: + 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-in-indent-before", "true"); + interface.properties.set("brace-if-in-indent-after", "true"); + // out: + 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-out-unindent-after", "true"); + interface.properties.set("brace-if-out-unindent-before", "true"); + // single: + //interface.properties.set("brace-if-single", "true"); + etk::String outRef = "action_A;if(true)\n\t{ action_B;\n\t} action_D;"; + etk::String output = interface.process(sourceIf1Action); + EXPECT_EQ(output, outRef); + output = interface.process(sourceIf1ActionNoBrace); + EXPECT_EQ(output, outRef); +} + +TEST(testIf, brace_110011) { + estyle::Generator interface; + // in: + 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-in-indent-before", "true"); + interface.properties.set("brace-if-in-indent-after", "true"); + // out: + 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-out-unindent-after", "true"); + interface.properties.set("brace-if-out-unindent-before", "true"); + // single: + //interface.properties.set("brace-if-single", "true"); + etk::String outRef = "action_A;if(true)\n\t{\n\t\taction_B;\n\t}\naction_D;"; + etk::String output = interface.process(sourceIf1Action); + EXPECT_EQ(output, outRef); + output = interface.process(sourceIf1ActionNoBrace); + EXPECT_EQ(output, outRef); +} + +TEST(testIf, brace_110111) { + estyle::Generator interface; + // in: + 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-in-indent-before", "true"); + interface.properties.set("brace-if-in-indent-after", "true"); + // out: + 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-out-unindent-after", "true"); + interface.properties.set("brace-if-out-unindent-before", "true"); + // single: + //interface.properties.set("brace-if-single", "true"); + etk::String outRef = "action_A;if(true)\n\t{\n\t\taction_B;\n\t}\naction_D;"; + etk::String output = interface.process(sourceIf1Action); + EXPECT_EQ(output, outRef); + output = interface.process(sourceIf1ActionNoBrace); + EXPECT_EQ(output, outRef); +} + +TEST(testIf, brace_111011) { + estyle::Generator interface; + // in: + 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-in-indent-before", "true"); + interface.properties.set("brace-if-in-indent-after", "true"); + // out: + 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-out-unindent-after", "true"); + interface.properties.set("brace-if-out-unindent-before", "true"); + // single: + //interface.properties.set("brace-if-single", "true"); + etk::String outRef = "action_A;if(true)\n\t{\n\t\taction_B;\n\t}\naction_D;"; + etk::String output = interface.process(sourceIf1Action); + EXPECT_EQ(output, outRef); + output = interface.process(sourceIf1ActionNoBrace); + EXPECT_EQ(output, outRef); +} + +TEST(testIf, brace_111111) { + estyle::Generator interface; + // in: + 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-in-indent-before", "true"); + interface.properties.set("brace-if-in-indent-after", "true"); + // out: + 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-out-unindent-after", "true"); + interface.properties.set("brace-if-out-unindent-before", "true"); + // single: + //interface.properties.set("brace-if-single", "true"); + etk::String outRef = "action_A;if(true)\n\t{\n\t\taction_B;\n\t}\naction_D;"; + etk::String output = interface.process(sourceIf1Action); + EXPECT_EQ(output, outRef); + output = interface.process(sourceIf1ActionNoBrace); + EXPECT_EQ(output, outRef); +} + +TEST(testIf, brace_100111) { + estyle::Generator interface; + // in: + 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-in-indent-before", "true"); + interface.properties.set("brace-if-in-indent-after", "true"); + // out: + 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-out-unindent-after", "true"); + interface.properties.set("brace-if-out-unindent-before", "true"); + // single: + //interface.properties.set("brace-if-single", "true"); + etk::String outRef = "action_A;if(true)\n\t{ action_B;\n\t} action_D;"; + etk::String output = interface.process(sourceIf1Action); + EXPECT_EQ(output, outRef); + output = interface.process(sourceIf1ActionNoBrace); + EXPECT_EQ(output, outRef); +} + + +TEST(testIf, brace_010011) { + estyle::Generator interface; + // in: + //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-in-indent-before", "true"); + interface.properties.set("brace-if-in-indent-after", "true"); + // out: + //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-out-unindent-after", "true"); + interface.properties.set("brace-if-out-unindent-before", "true"); + // single: + //interface.properties.set("brace-if-single", "true"); + etk::String outRef = "action_A;if(true){\n\t\taction_B;}\naction_D;"; + etk::String output = interface.process(sourceIf1Action); + EXPECT_EQ(output, outRef); + output = interface.process(sourceIf1ActionNoBrace); + EXPECT_EQ(output, outRef); +} + +TEST(testIf, brace_010111) { + estyle::Generator interface; + // in: + //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-in-indent-before", "true"); + interface.properties.set("brace-if-in-indent-after", "true"); + // out: + //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-out-unindent-after", "true"); + interface.properties.set("brace-if-out-unindent-before", "true"); + // single: + //interface.properties.set("brace-if-single", "true"); + etk::String outRef = "action_A;if(true){\n\t\taction_B;}\naction_D;"; + etk::String output = interface.process(sourceIf1Action); + EXPECT_EQ(output, outRef); + output = interface.process(sourceIf1ActionNoBrace); + EXPECT_EQ(output, outRef); +} + +TEST(testIf, brace_011011) { + estyle::Generator interface; + // in: + //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-in-indent-before", "true"); + interface.properties.set("brace-if-in-indent-after", "true"); + // out: + //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-out-unindent-after", "true"); + interface.properties.set("brace-if-out-unindent-before", "true"); + // single: + //interface.properties.set("brace-if-single", "true"); + etk::String outRef = "action_A;if(true) {\n\t\taction_B; }\naction_D;"; + etk::String output = interface.process(sourceIf1Action); + EXPECT_EQ(output, outRef); + output = interface.process(sourceIf1ActionNoBrace); + EXPECT_EQ(output, outRef); +} + +TEST(testIf, brace_001011) { + estyle::Generator interface; + // in: + //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-in-indent-before", "true"); + interface.properties.set("brace-if-in-indent-after", "true"); + // out: + //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-out-unindent-after", "true"); + interface.properties.set("brace-if-out-unindent-before", "true"); + // single: + //interface.properties.set("brace-if-single", "true"); + etk::String outRef = "action_A;if(true) {action_B; }action_D;"; + etk::String output = interface.process(sourceIf1Action); + EXPECT_EQ(output, outRef); + output = interface.process(sourceIf1ActionNoBrace); + EXPECT_EQ(output, outRef); +} + +TEST(testIf, brace_001111) { + estyle::Generator interface; + // in: + //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-in-indent-before", "true"); + interface.properties.set("brace-if-in-indent-after", "true"); + // out: + //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-out-unindent-after", "true"); + interface.properties.set("brace-if-out-unindent-before", "true"); + // single: + //interface.properties.set("brace-if-single", "true"); + etk::String outRef = "action_A;if(true) { action_B; } action_D;"; + etk::String output = interface.process(sourceIf1Action); + EXPECT_EQ(output, outRef); + output = interface.process(sourceIf1ActionNoBrace); + EXPECT_EQ(output, outRef); +} + +TEST(testIf, brace_011111) { + estyle::Generator interface; + // in: + //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-in-indent-before", "true"); + interface.properties.set("brace-if-in-indent-after", "true"); + // out: + //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-out-unindent-after", "true"); + interface.properties.set("brace-if-out-unindent-before", "true"); + // single: + //interface.properties.set("brace-if-single", "true"); + etk::String outRef = "action_A;if(true) {\n\t\taction_B; }\naction_D;"; + etk::String output = interface.process(sourceIf1Action); + EXPECT_EQ(output, outRef); + output = interface.process(sourceIf1ActionNoBrace); + EXPECT_EQ(output, outRef); +} + +TEST(testIf, brace_000111) { + estyle::Generator interface; + // in: + //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-in-indent-before", "true"); + interface.properties.set("brace-if-in-indent-after", "true"); + // out: + //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-out-unindent-after", "true"); + interface.properties.set("brace-if-out-unindent-before", "true"); + // single: + //interface.properties.set("brace-if-single", "true"); + etk::String outRef = "action_A;if(true){ action_B;} action_D;"; + etk::String output = interface.process(sourceIf1Action); + EXPECT_EQ(output, outRef); + output = interface.process(sourceIf1ActionNoBrace); + EXPECT_EQ(output, outRef); +} +///////////////////////////////////////////////////////////////////////////////////////// + + + + + + + + + +TEST(testIf, brace_single_000) { + estyle::Generator interface; + //interface.properties.set("brace-if-one-line-size-max", "40"); interface.properties.set("brace-if-single", "true"); //interface.properties.set("brace-if-single-in-new-line", "true"); //interface.properties.set("brace-if-single-in-space", "true"); //interface.properties.set("brace-if-single-out-new-line", "true"); //interface.properties.set("brace-if-single-out-space", "true"); + //interface.properties.set("brace-if-single-indent", "true"); etk::String outRef = "action_A;if(true)action_B;action_D;"; etk::String output = interface.process(sourceIf1Action); EXPECT_EQ(output, outRef); @@ -320,44 +1545,47 @@ TEST(testIf, brace_single_00) { EXPECT_EQ(output, outRef); } -TEST(testIf, brace_single_10) { +TEST(testIf, brace_single_100) { estyle::Generator interface; - //interface.properties.set("brace-if-single-one-line-size-max", "40"); + //interface.properties.set("brace-if-one-line-size-max", "40"); interface.properties.set("brace-if-single", "true"); interface.properties.set("brace-if-single-in-new-line", "true"); //interface.properties.set("brace-if-single-in-space", "true"); interface.properties.set("brace-if-single-out-new-line", "true"); //interface.properties.set("brace-if-single-out-space", "true"); - etk::String outRef = "action_A;if(true)\n\taction_B;\naction_D;"; + //interface.properties.set("brace-if-single-indent", "true"); + etk::String outRef = "action_A;if(true)\naction_B;\naction_D;"; etk::String output = interface.process(sourceIf1Action); EXPECT_EQ(output, outRef); output = interface.process(sourceIf1ActionNoBrace); EXPECT_EQ(output, outRef); } -TEST(testIf, brace_single_01) { +TEST(testIf, brace_single_010) { estyle::Generator interface; - //interface.properties.set("brace-if-single-one-line-size-max", "40"); + //interface.properties.set("brace-if-one-line-size-max", "40"); interface.properties.set("brace-if-single", "true"); //interface.properties.set("brace-if-single-in-new-line", "true"); interface.properties.set("brace-if-single-in-space", "true"); //interface.properties.set("brace-if-single-out-new-line", "true"); interface.properties.set("brace-if-single-out-space", "true"); + //interface.properties.set("brace-if-single-indent", "true"); etk::String outRef = "action_A;if(true) action_B; action_D;"; etk::String output = interface.process(sourceIf1Action); EXPECT_EQ(output, outRef); output = interface.process(sourceIf1ActionNoBrace); EXPECT_EQ(output, outRef); } -TEST(testIf, brace_single_11) { +TEST(testIf, brace_single_110) { estyle::Generator interface; - //interface.properties.set("brace-if-single-one-line-size-max", "40"); + //interface.properties.set("brace-if-one-line-size-max", "40"); interface.properties.set("brace-if-single", "true"); interface.properties.set("brace-if-single-in-new-line", "true"); interface.properties.set("brace-if-single-in-space", "true"); interface.properties.set("brace-if-single-out-new-line", "true"); interface.properties.set("brace-if-single-out-space", "true"); - etk::String outRef = "action_A;if(true)\n\taction_B;\naction_D;"; + //interface.properties.set("brace-if-single-indent", "true"); + etk::String outRef = "action_A;if(true)\naction_B;\naction_D;"; etk::String output = interface.process(sourceIf1Action); EXPECT_EQ(output, outRef); output = interface.process(sourceIf1ActionNoBrace); @@ -366,3 +1594,192 @@ TEST(testIf, brace_single_11) { +TEST(testIf, brace_single_001) { + estyle::Generator interface; + //interface.properties.set("brace-if-one-line-size-max", "40"); + interface.properties.set("brace-if-single", "true"); + //interface.properties.set("brace-if-single-in-new-line", "true"); + //interface.properties.set("brace-if-single-in-space", "true"); + //interface.properties.set("brace-if-single-out-new-line", "true"); + //interface.properties.set("brace-if-single-out-space", "true"); + interface.properties.set("brace-if-single-indent", "true"); + etk::String outRef = "action_A;if(true)action_B;action_D;"; + etk::String output = interface.process(sourceIf1Action); + EXPECT_EQ(output, outRef); + output = interface.process(sourceIf1ActionNoBrace); + EXPECT_EQ(output, outRef); +} + +TEST(testIf, brace_single_101) { + estyle::Generator interface; + //interface.properties.set("brace-if-one-line-size-max", "40"); + interface.properties.set("brace-if-single", "true"); + interface.properties.set("brace-if-single-in-new-line", "true"); + //interface.properties.set("brace-if-single-in-space", "true"); + interface.properties.set("brace-if-single-out-new-line", "true"); + //interface.properties.set("brace-if-single-out-space", "true"); + interface.properties.set("brace-if-single-indent", "true"); + etk::String outRef = "action_A;if(true)\n\taction_B;\naction_D;"; + etk::String output = interface.process(sourceIf1Action); + EXPECT_EQ(output, outRef); + output = interface.process(sourceIf1ActionNoBrace); + EXPECT_EQ(output, outRef); +} + +TEST(testIf, brace_single_011) { + estyle::Generator interface; + //interface.properties.set("brace-if-one-line-size-max", "40"); + interface.properties.set("brace-if-single", "true"); + //interface.properties.set("brace-if-single-in-new-line", "true"); + interface.properties.set("brace-if-single-in-space", "true"); + //interface.properties.set("brace-if-single-out-new-line", "true"); + interface.properties.set("brace-if-single-out-space", "true"); + interface.properties.set("brace-if-single-indent", "true"); + etk::String outRef = "action_A;if(true) action_B; action_D;"; + etk::String output = interface.process(sourceIf1Action); + EXPECT_EQ(output, outRef); + output = interface.process(sourceIf1ActionNoBrace); + EXPECT_EQ(output, outRef); +} +TEST(testIf, brace_single_111) { + estyle::Generator interface; + //interface.properties.set("brace-if-one-line-size-max", "40"); + interface.properties.set("brace-if-single", "true"); + interface.properties.set("brace-if-single-in-new-line", "true"); + interface.properties.set("brace-if-single-in-space", "true"); + interface.properties.set("brace-if-single-out-new-line", "true"); + interface.properties.set("brace-if-single-out-space", "true"); + interface.properties.set("brace-if-single-indent", "true"); + etk::String outRef = "action_A;if(true)\n\taction_B;\naction_D;"; + etk::String output = interface.process(sourceIf1Action); + EXPECT_EQ(output, outRef); + output = interface.process(sourceIf1ActionNoBrace); + EXPECT_EQ(output, outRef); +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// + +TEST(testIf, brace_empty_000) { + estyle::Generator interface; + // in out for specific empty change: + 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-in-indent-before", "true"); + interface.properties.set("brace-if-in-indent-after", "true"); + // out: + 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-out-unindent-after", "true"); + interface.properties.set("brace-if-out-unindent-before", "true"); + // empty + //interface.properties.set("brace-if-one-line-size-max", "0"); + //interface.properties.set("brace-empty-space", "true"); + //interface.properties.set("brace-empty-indent", "true"); + etk::String outRef = "action_A;if(true)\n\t{\n\t}\naction_D;"; + etk::String output = interface.process(sourceIf0Action); + EXPECT_EQ(output, outRef); +} + +TEST(testIf, brace_empty_100) { + estyle::Generator interface; + // in out for specific empty change: + 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-in-indent-before", "true"); + interface.properties.set("brace-if-in-indent-after", "true"); + // out: + 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-out-unindent-after", "true"); + interface.properties.set("brace-if-out-unindent-before", "true"); + // empty + interface.properties.set("brace-if-one-line-size-max", "0"); + //interface.properties.set("brace-if-empty-space", "true"); + //interface.properties.set("brace-if-empty-indent", "true"); + etk::String outRef = "action_A;if(true) {}\naction_D;"; + etk::String output = interface.process(sourceIf0Action); + EXPECT_EQ(output, outRef); +} + +TEST(testIf, brace_empty_110) { + estyle::Generator interface; + // in out for specific empty change: + 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-in-indent-before", "true"); + interface.properties.set("brace-if-in-indent-after", "true"); + // out: + 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-out-unindent-after", "true"); + interface.properties.set("brace-if-out-unindent-before", "true"); + // empty + interface.properties.set("brace-if-one-line-size-max", "0"); + interface.properties.set("brace-if-empty-space", "true"); + //interface.properties.set("brace-if-empty-indent", "true"); + etk::String outRef = "action_A;if(true) { }\naction_D;"; + etk::String output = interface.process(sourceIf0Action); + EXPECT_EQ(output, outRef); +} + +TEST(testIf, brace_empty_111) { + estyle::Generator interface; + // in out for specific empty change: + 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-in-indent-before", "true"); + interface.properties.set("brace-if-in-indent-after", "true"); + // out: + 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-out-unindent-after", "true"); + interface.properties.set("brace-if-out-unindent-before", "true"); + // empty + interface.properties.set("brace-if-one-line-size-max", "0"); + interface.properties.set("brace-if-empty-space", "true"); + interface.properties.set("brace-if-empty-indent", "true"); + etk::String outRef = "action_A;if(true) { }\naction_D;"; + etk::String output = interface.process(sourceIf0Action); + EXPECT_EQ(output, outRef); +} + +TEST(testIf, brace_empty_001) { + estyle::Generator interface; + // in out for specific empty change: + 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-in-indent-before", "true"); + interface.properties.set("brace-if-in-indent-after", "true"); + // out: + 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-out-unindent-after", "true"); + interface.properties.set("brace-if-out-unindent-before", "true"); + // empty + //interface.properties.set("brace-if-one-line-size-max", "0"); + //interface.properties.set("brace-if-empty-space", "true"); + interface.properties.set("brace-if-empty-indent", "true"); + etk::String outRef = "action_A;if(true)\n\t{\n\t\t\n\t}\naction_D;"; + etk::String output = interface.process(sourceIf0Action); + EXPECT_EQ(output, outRef); +}