[DEV] add namespace brace test
This commit is contained in:
parent
6e7c65fadb
commit
16b9c3f17e
@ -197,20 +197,22 @@ estyle::Generator::Generator():
|
||||
propertyIndentSize(this, "indent-size", 4, "default 4 sapce in one tabulation indentation"),
|
||||
propertyDoxygenOneLine(this, "doxygen-1-line-type", true, "true: single line doxygen comment is done with '//!', false '///'"),
|
||||
propertyDoxygenMultipleLine(this, "doxygen-N-line-type", DOXYGEN_MULTI_LINE__NORMAL, "0: /** */ ..."),
|
||||
propertyForConditionMultiLineBigSize(this, "for-condition-multi-line-big-size", 80, "If the condition inside for (...;...;...) if bigger than XX char"),
|
||||
propertyIfConditionMultiLineBigSize(this, "if-condition-multi-line-big-size", 80, "If the condition inside if (...&&...) if bigger than XX char"),
|
||||
propertyWhileConditionMultiLineBigSize(this, "while-condition-multi-line-big-size", 80, "If the condition inside while (...&&...) if bigger than XX char"),
|
||||
propertyDoWhileConditionMultiLineBigSize(this, "do-while-condition-multi-line-big-size", 80, "If the condition inside do ... while (...&&...) if bigger than XX char") {
|
||||
|
||||
propertyForConditionMultiLineBigSize(this, "condition-for-multi-line-big-size", 80, "If the condition inside for (...;...;...) if bigger than XX char"),
|
||||
propertyIfConditionMultiLineBigSize(this, "condition-if-multi-line-big-size", 80, "If the condition inside if (...&&...) if bigger than XX char"),
|
||||
propertyWhileConditionMultiLineBigSize(this, "condition-while-multi-line-big-size", 80, "If the condition inside while (...&&...) if bigger than XX char"),
|
||||
propertyDoWhileConditionMultiLineBigSize(this, "condition-do-while-multi-line-big-size", 80, "If the condition inside do ... while (...&&...) if bigger than XX char")
|
||||
{
|
||||
setPropertyDoxygenMultiLine(propertyDoxygenMultipleLine);
|
||||
propertyBrace.set("if", etk::move(estyle::BraceProperty(this, "if")));
|
||||
propertyBrace.set("else", etk::move(estyle::BraceProperty(this, "else")));
|
||||
propertyBrace.set("function", etk::move(estyle::BraceProperty(this, "function", false)));
|
||||
propertyBrace.set("for", etk::move(estyle::BraceProperty(this, "for")));
|
||||
propertyBrace.set("while", etk::move(estyle::BraceProperty(this, "while")));
|
||||
|
||||
propertyBrace.set("do", etk::move(estyle::BraceProperty(this, "do")));
|
||||
propertyBrace.set("switch", etk::move(estyle::BraceProperty(this, "switch", false)));
|
||||
propertyBrace.set("namespace", etk::move(estyle::BraceProperty(this, "namespace", false)));
|
||||
|
||||
propertyBrace.set("do-while", etk::move(estyle::BraceProperty(this, "do-while")));
|
||||
propertyBrace.set("switch", etk::move(estyle::BraceProperty(this, "switch", false)));
|
||||
propertyBrace.set("class", etk::move(estyle::BraceProperty(this, "class", false)));
|
||||
propertyBrace.set("struct", etk::move(estyle::BraceProperty(this, "struct", false)));
|
||||
propertyBrace.set("block", etk::move(estyle::BraceProperty(this, "block", false)));
|
||||
@ -776,6 +778,50 @@ int32_t estyle::Generator::process(int32_t _startId,
|
||||
typePop();
|
||||
continue;
|
||||
}
|
||||
if (elem == estyle::lexer::RESERVED_NAMESPACE) {
|
||||
addNewLineIfSemiColon();
|
||||
typePush("namespace");
|
||||
addSpace();
|
||||
m_output += "namespace";
|
||||
// special case ==> nothing special to do for the else element...
|
||||
if (nextIs(iii+1, estyle::lexer::BRACE_IN) == false) {
|
||||
if (nextIs(iii+1, estyle::lexer::ID) == true) {
|
||||
// normal case ==> empty namespace
|
||||
addSpace();
|
||||
iii++;
|
||||
m_output += m_lexer.getData(iii);
|
||||
} else {
|
||||
ESTYLE_ERROR("mamespace must be followed by an ID or a brace");
|
||||
typePop();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
bool needBrace = false;
|
||||
bool haveBrace = false;
|
||||
int32_t subGenerationStart = iii+1;
|
||||
int32_t subGenerationStop = iii+1;
|
||||
if (nextIs(iii+1, estyle::lexer::BRACE_IN) == true) {
|
||||
haveBrace = true;
|
||||
int32_t countAction = countCurrent(iii+1, m_lexer.size(), estyle::lexer::tocken::SEMICOLON);
|
||||
if (countAction != 1) {
|
||||
needBrace = true;
|
||||
}
|
||||
subGenerationStart = iii+2;
|
||||
subGenerationStop = endOfSection(iii+1);
|
||||
} else {
|
||||
ESTYLE_ERROR("Missing { in namespace");
|
||||
typePop();
|
||||
continue;
|
||||
}
|
||||
iii = generateBrace(subGenerationStart, subGenerationStop, needBrace, true);
|
||||
if (haveBrace == true) {
|
||||
iii--;
|
||||
} else {
|
||||
iii -= 2;
|
||||
}
|
||||
typePop();
|
||||
continue;
|
||||
}
|
||||
if ( elem == estyle::lexer::ELEMENT_FUNCTION
|
||||
|| elem == estyle::lexer::ELEMENT_FUNCTION_DECLARATION) {
|
||||
addNewLineIfSemiColon();
|
||||
|
@ -21,10 +21,21 @@ def configure(target, my_module):
|
||||
# add sources files
|
||||
my_module.add_src_file([
|
||||
'test/main.cpp',
|
||||
'test/testIf.cpp',
|
||||
'test/testBlock.cpp',
|
||||
'test/testClass.cpp',
|
||||
'test/testComment.cpp',
|
||||
'test/testDoWhile.cpp',
|
||||
'test/testElse.cpp',
|
||||
'test/testFunction.cpp',
|
||||
'test/testFor.cpp',
|
||||
'test/testFunction.cpp',
|
||||
'test/testIf.cpp',
|
||||
'test/testNamespace.cpp',
|
||||
'test/testPreprocessor.cpp',
|
||||
'test/testStruct.cpp',
|
||||
'test/testSwitch.cpp',
|
||||
'test/testTemplate.cpp',
|
||||
'test/testType.cpp',
|
||||
'test/testVariable.cpp',
|
||||
'test/testWhile.cpp',
|
||||
])
|
||||
my_module.add_path("test")
|
||||
|
@ -1,44 +0,0 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2017, Edouard DUPIN, all right reserved
|
||||
* @license MPL-2 (see license file)
|
||||
*/
|
||||
#include <test-debug/debug.hpp>
|
||||
#include <etest/etest.hpp>
|
||||
#include "testInterface.hpp"
|
||||
|
||||
|
||||
TEST(testComment, singleLine) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("// result = true; \n variable hello=9;");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), false);
|
||||
}
|
||||
|
||||
|
||||
TEST(testComment, multipleLine) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("var result2 = false; \n /* var result \n = \n true; \n result = 8; \n */ var result = 118;");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result2"), true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.getBoolean("result2"), false);
|
||||
EXPECT_EQ(system.getInteger32("result"), 118);
|
||||
}
|
||||
|
||||
TEST(testDocumentation, singleLine) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("//! result = true; \n variable hello=9;");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), false);
|
||||
}
|
||||
|
||||
TEST(testDocumentation, multipleLine) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("var result2 = false; \n /** var result \n = \n true; \n result = 8; \n */ var result = 118;");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result2"), true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.getBoolean("result2"), false);
|
||||
EXPECT_EQ(system.getInteger32("result"), 118);
|
||||
}
|
@ -1,142 +0,0 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2017, Edouard DUPIN, all right reserved
|
||||
* @license MPL-2 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <kikou/kikou.hpp>
|
||||
|
||||
class testInterface {
|
||||
public:
|
||||
kikou::Interpreter m_system;
|
||||
public:
|
||||
testInterface() {
|
||||
m_system.import("core");
|
||||
m_system.import("Math");
|
||||
}
|
||||
bool execute(const etk::String& _data) {
|
||||
// TODO : ... m_system.trace();
|
||||
//m_system.addChild("result", new kikou::Var("0", kikou::Var::type::INTEGER));
|
||||
try {
|
||||
m_system.compile(_data);
|
||||
m_system.execute();
|
||||
} catch (etk::exception::RuntimeError& eee) {
|
||||
ETEST_ERROR(eee.what());
|
||||
return false;
|
||||
}
|
||||
// TODO : ... m_system.trace();
|
||||
return true;
|
||||
}
|
||||
bool exist(const etk::String& _value) {
|
||||
return m_system.exist(_value);
|
||||
}
|
||||
bool isBoolean(const etk::String& _value) {
|
||||
if (m_system.exist(_value) == false) {
|
||||
return false;
|
||||
}
|
||||
return m_system.getScriptVariable(_value)->isBoolean();
|
||||
}
|
||||
bool isInteger32(const etk::String& _value) {
|
||||
if (m_system.exist(_value) == false) {
|
||||
return false;
|
||||
}
|
||||
return m_system.getScriptVariable(_value)->isInteger32();
|
||||
}
|
||||
bool isInteger64(const etk::String& _value) {
|
||||
if (m_system.exist(_value) == false) {
|
||||
return false;
|
||||
}
|
||||
return m_system.getScriptVariable(_value)->isInteger64();
|
||||
}
|
||||
bool isFloat(const etk::String& _value) {
|
||||
if (m_system.exist(_value) == false) {
|
||||
return false;
|
||||
}
|
||||
return m_system.getScriptVariable(_value)->isFloat32();
|
||||
}
|
||||
bool isDouble(const etk::String& _value) {
|
||||
if (m_system.exist(_value) == false) {
|
||||
return false;
|
||||
}
|
||||
return m_system.getScriptVariable(_value)->isFloat64();
|
||||
}
|
||||
bool isString(const etk::String& _value) {
|
||||
if (m_system.exist(_value) == false) {
|
||||
return false;
|
||||
}
|
||||
return m_system.getScriptVariable(_value)->isString();
|
||||
}
|
||||
bool isFunction(const etk::String& _value) {
|
||||
if (m_system.exist(_value) == false) {
|
||||
return false;
|
||||
}
|
||||
return m_system.getScriptVariable(_value)->isFunction();
|
||||
}
|
||||
bool isObject(const etk::String& _value) {
|
||||
if (m_system.exist(_value) == false) {
|
||||
return false;
|
||||
}
|
||||
return m_system.getScriptVariable(_value)->isObject();
|
||||
}
|
||||
bool isArray(const etk::String& _value) {
|
||||
if (m_system.exist(_value) == false) {
|
||||
return false;
|
||||
}
|
||||
return m_system.getScriptVariable(_value)->isArray();
|
||||
}
|
||||
bool isFunionNative(const etk::String& _value) {
|
||||
if (m_system.exist(_value) == false) {
|
||||
return false;
|
||||
}
|
||||
return m_system.getScriptVariable(_value)->isFunctionNative();
|
||||
}
|
||||
bool isUndefined(const etk::String& _value) {
|
||||
if (m_system.exist(_value) == false) {
|
||||
return false;
|
||||
}
|
||||
return m_system.getScriptVariable(_value)->isUndefined();
|
||||
}
|
||||
bool isNull(const etk::String& _value) {
|
||||
if (m_system.exist(_value) == false) {
|
||||
return false;
|
||||
}
|
||||
return m_system.getScriptVariable(_value)->isNull();
|
||||
}
|
||||
bool getBoolean(const etk::String& _value) {
|
||||
if (m_system.exist(_value) == false) {
|
||||
return false;
|
||||
}
|
||||
return m_system.getScriptVariable(_value)->toBoolean()->get();
|
||||
}
|
||||
int getInteger32(const etk::String& _value) {
|
||||
if (m_system.exist(_value) == false) {
|
||||
return 0;
|
||||
}
|
||||
return m_system.getScriptVariable(_value)->toInteger32()->get();
|
||||
}
|
||||
int getInteger64(const etk::String& _value) {
|
||||
if (m_system.exist(_value) == false) {
|
||||
return 0;
|
||||
}
|
||||
return m_system.getScriptVariable(_value)->toInteger64()->get();
|
||||
}
|
||||
double getFloat(const etk::String& _value) {
|
||||
if (m_system.exist(_value) == false) {
|
||||
return 0;
|
||||
}
|
||||
return m_system.getScriptVariable(_value)->toFloat32()->get();
|
||||
}
|
||||
double getDouble(const etk::String& _value) {
|
||||
if (m_system.exist(_value) == false) {
|
||||
return 0;
|
||||
}
|
||||
return m_system.getScriptVariable(_value)->toFloat64()->get();
|
||||
}
|
||||
etk::String getString(const etk::String& _value) {
|
||||
if (m_system.exist(_value) == false) {
|
||||
return "ERROR";
|
||||
}
|
||||
return m_system.getScriptVariable(_value)->toString()->get();
|
||||
}
|
||||
};
|
257
test/testNamespace.cpp
Normal file
257
test/testNamespace.cpp
Normal file
@ -0,0 +1,257 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2017, Edouard DUPIN, all right reserved
|
||||
* @license MPL-2 (see license file)
|
||||
*/
|
||||
#include <estyle/estyle.hpp>
|
||||
#include <estyle/Generator.hpp>
|
||||
#include <etk/etk.hpp>
|
||||
#include <etk/os/FSNode.hpp>
|
||||
#include <test-debug/debug.hpp>
|
||||
#include <etest/etest.hpp>
|
||||
|
||||
static etk::String sourceNamespace = "action_A;namespace myNamespace{action_B;}action_D;";
|
||||
|
||||
|
||||
TEST(testNamespace, brace_0000) {
|
||||
estyle::Generator interface;
|
||||
//interface.properties.set("brace-namespace-in-new-line-before", "true");
|
||||
//interface.properties.set("brace-namespace-in-new-line-after", "true");
|
||||
//interface.properties.set("brace-namespace-in-space-before", "true");
|
||||
//interface.properties.set("brace-namespace-in-space-after", "true");
|
||||
//interface.properties.set("brace-namespace-out-new-line-before", "true");
|
||||
//interface.properties.set("brace-namespace-out-new-line-after", "true");
|
||||
//interface.properties.set("brace-namespace-out-space-before", "true");
|
||||
//interface.properties.set("brace-namespace-out-space-after", "true");
|
||||
etk::String outputRef = "action_A;\nnamespace myNamespace{action_B;}action_D;";
|
||||
etk::String output = interface.process(sourceNamespace);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
}
|
||||
|
||||
TEST(testNamespace, brace_1000) {
|
||||
estyle::Generator interface;
|
||||
interface.properties.set("brace-namespace-in-new-line-before", "true");
|
||||
//interface.properties.set("brace-namespace-in-new-line-after", "true");
|
||||
//interface.properties.set("brace-namespace-in-space-before", "true");
|
||||
//interface.properties.set("brace-namespace-in-space-after", "true");
|
||||
interface.properties.set("brace-namespace-out-new-line-before", "true");
|
||||
//interface.properties.set("brace-namespace-out-new-line-after", "true");
|
||||
//interface.properties.set("brace-namespace-out-space-before", "true");
|
||||
//interface.properties.set("brace-namespace-out-space-after", "true");
|
||||
etk::String outputRef = "action_A;\nnamespace myNamespace\n{action_B;\n}action_D;";
|
||||
etk::String output = interface.process(sourceNamespace);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
}
|
||||
|
||||
TEST(testNamespace, brace_1010) {
|
||||
estyle::Generator interface;
|
||||
interface.properties.set("brace-namespace-in-new-line-before", "true");
|
||||
//interface.properties.set("brace-namespace-in-new-line-after", "true");
|
||||
interface.properties.set("brace-namespace-in-space-before", "true");
|
||||
//interface.properties.set("brace-namespace-in-space-after", "true");
|
||||
interface.properties.set("brace-namespace-out-new-line-before", "true");
|
||||
//interface.properties.set("brace-namespace-out-new-line-after", "true");
|
||||
interface.properties.set("brace-namespace-out-space-before", "true");
|
||||
//interface.properties.set("brace-namespace-out-space-after", "true");
|
||||
etk::String outputRef = "action_A;\nnamespace myNamespace\n{action_B;\n}action_D;";
|
||||
etk::String output = interface.process(sourceNamespace);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
}
|
||||
|
||||
TEST(testNamespace, brace_1011) {
|
||||
estyle::Generator interface;
|
||||
interface.properties.set("brace-namespace-in-new-line-before", "true");
|
||||
//interface.properties.set("brace-namespace-in-new-line-after", "true");
|
||||
interface.properties.set("brace-namespace-in-space-before", "true");
|
||||
interface.properties.set("brace-namespace-in-space-after", "true");
|
||||
interface.properties.set("brace-namespace-out-new-line-before", "true");
|
||||
//interface.properties.set("brace-namespace-out-new-line-after", "true");
|
||||
interface.properties.set("brace-namespace-out-space-before", "true");
|
||||
interface.properties.set("brace-namespace-out-space-after", "true");
|
||||
etk::String outputRef = "action_A;\nnamespace myNamespace\n{ action_B;\n} action_D;";
|
||||
etk::String output = interface.process(sourceNamespace);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
}
|
||||
|
||||
TEST(testNamespace, brace_1100) {
|
||||
estyle::Generator interface;
|
||||
interface.properties.set("brace-namespace-in-new-line-before", "true");
|
||||
interface.properties.set("brace-namespace-in-new-line-after", "true");
|
||||
//interface.properties.set("brace-namespace-in-space-before", "true");
|
||||
//interface.properties.set("brace-namespace-in-space-after", "true");
|
||||
interface.properties.set("brace-namespace-out-new-line-before", "true");
|
||||
interface.properties.set("brace-namespace-out-new-line-after", "true");
|
||||
//interface.properties.set("brace-namespace-out-space-before", "true");
|
||||
//interface.properties.set("brace-namespace-out-space-after", "true");
|
||||
etk::String outputRef = "action_A;\nnamespace myNamespace\n{\n\taction_B;\n}\naction_D;";
|
||||
etk::String output = interface.process(sourceNamespace);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
}
|
||||
|
||||
TEST(testNamespace, brace_1101) {
|
||||
estyle::Generator interface;
|
||||
interface.properties.set("brace-namespace-in-new-line-before", "true");
|
||||
interface.properties.set("brace-namespace-in-new-line-after", "true");
|
||||
//interface.properties.set("brace-namespace-in-space-before", "true");
|
||||
interface.properties.set("brace-namespace-in-space-after", "true");
|
||||
interface.properties.set("brace-namespace-out-new-line-before", "true");
|
||||
interface.properties.set("brace-namespace-out-new-line-after", "true");
|
||||
//interface.properties.set("brace-namespace-out-space-before", "true");
|
||||
interface.properties.set("brace-namespace-out-space-after", "true");
|
||||
etk::String outputRef = "action_A;\nnamespace myNamespace\n{\n\taction_B;\n}\naction_D;";
|
||||
etk::String output = interface.process(sourceNamespace);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
}
|
||||
|
||||
TEST(testNamespace, brace_1110) {
|
||||
estyle::Generator interface;
|
||||
interface.properties.set("brace-namespace-in-new-line-before", "true");
|
||||
interface.properties.set("brace-namespace-in-new-line-after", "true");
|
||||
interface.properties.set("brace-namespace-in-space-before", "true");
|
||||
//interface.properties.set("brace-namespace-in-space-after", "true");
|
||||
interface.properties.set("brace-namespace-out-new-line-before", "true");
|
||||
interface.properties.set("brace-namespace-out-new-line-after", "true");
|
||||
interface.properties.set("brace-namespace-out-space-before", "true");
|
||||
//interface.properties.set("brace-namespace-out-space-after", "true");
|
||||
etk::String outputRef = "action_A;\nnamespace myNamespace\n{\n\taction_B;\n}\naction_D;";
|
||||
etk::String output = interface.process(sourceNamespace);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
}
|
||||
|
||||
TEST(testNamespace, brace_1111) {
|
||||
estyle::Generator interface;
|
||||
interface.properties.set("brace-namespace-in-new-line-before", "true");
|
||||
interface.properties.set("brace-namespace-in-new-line-after", "true");
|
||||
interface.properties.set("brace-namespace-in-space-before", "true");
|
||||
interface.properties.set("brace-namespace-in-space-after", "true");
|
||||
interface.properties.set("brace-namespace-out-new-line-before", "true");
|
||||
interface.properties.set("brace-namespace-out-new-line-after", "true");
|
||||
interface.properties.set("brace-namespace-out-space-before", "true");
|
||||
interface.properties.set("brace-namespace-out-space-after", "true");
|
||||
etk::String outputRef = "action_A;\nnamespace myNamespace\n{\n\taction_B;\n}\naction_D;";
|
||||
etk::String output = interface.process(sourceNamespace);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
}
|
||||
|
||||
TEST(testNamespace, brace_1001) {
|
||||
estyle::Generator interface;
|
||||
interface.properties.set("brace-namespace-in-new-line-before", "true");
|
||||
//interface.properties.set("brace-namespace-in-new-line-after", "true");
|
||||
//interface.properties.set("brace-namespace-in-space-before", "true");
|
||||
interface.properties.set("brace-namespace-in-space-after", "true");
|
||||
interface.properties.set("brace-namespace-out-new-line-before", "true");
|
||||
//interface.properties.set("brace-namespace-out-new-line-after", "true");
|
||||
//interface.properties.set("brace-namespace-out-space-before", "true");
|
||||
interface.properties.set("brace-namespace-out-space-after", "true");
|
||||
etk::String outputRef = "action_A;\nnamespace myNamespace\n{ action_B;\n} action_D;";
|
||||
etk::String output = interface.process(sourceNamespace);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
}
|
||||
|
||||
|
||||
TEST(testNamespace, brace_0100) {
|
||||
estyle::Generator interface;
|
||||
//interface.properties.set("brace-namespace-in-new-line-before", "true");
|
||||
interface.properties.set("brace-namespace-in-new-line-after", "true");
|
||||
//interface.properties.set("brace-namespace-in-space-before", "true");
|
||||
//interface.properties.set("brace-namespace-in-space-after", "true");
|
||||
//interface.properties.set("brace-namespace-out-new-line-before", "true");
|
||||
interface.properties.set("brace-namespace-out-new-line-after", "true");
|
||||
//interface.properties.set("brace-namespace-out-space-before", "true");
|
||||
//interface.properties.set("brace-namespace-out-space-after", "true");
|
||||
etk::String outputRef = "action_A;\nnamespace myNamespace{\n\taction_B;}\naction_D;";
|
||||
etk::String output = interface.process(sourceNamespace);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
}
|
||||
|
||||
TEST(testNamespace, brace_0101) {
|
||||
estyle::Generator interface;
|
||||
//interface.properties.set("brace-namespace-in-new-line-before", "true");
|
||||
interface.properties.set("brace-namespace-in-new-line-after", "true");
|
||||
//interface.properties.set("brace-namespace-in-space-before", "true");
|
||||
interface.properties.set("brace-namespace-in-space-after", "true");
|
||||
//interface.properties.set("brace-namespace-out-new-line-before", "true");
|
||||
interface.properties.set("brace-namespace-out-new-line-after", "true");
|
||||
//interface.properties.set("brace-namespace-out-space-before", "true");
|
||||
interface.properties.set("brace-namespace-out-space-after", "true");
|
||||
etk::String outputRef = "action_A;\nnamespace myNamespace{\n\taction_B;}\naction_D;";
|
||||
etk::String output = interface.process(sourceNamespace);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
}
|
||||
|
||||
TEST(testNamespace, brace_0110) {
|
||||
estyle::Generator interface;
|
||||
//interface.properties.set("brace-namespace-in-new-line-before", "true");
|
||||
interface.properties.set("brace-namespace-in-new-line-after", "true");
|
||||
interface.properties.set("brace-namespace-in-space-before", "true");
|
||||
//interface.properties.set("brace-namespace-in-space-after", "true");
|
||||
//interface.properties.set("brace-namespace-out-new-line-before", "true");
|
||||
interface.properties.set("brace-namespace-out-new-line-after", "true");
|
||||
interface.properties.set("brace-namespace-out-space-before", "true");
|
||||
//interface.properties.set("brace-namespace-out-space-after", "true");
|
||||
etk::String outputRef = "action_A;\nnamespace myNamespace {\n\taction_B; }\naction_D;";
|
||||
etk::String output = interface.process(sourceNamespace);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
}
|
||||
|
||||
TEST(testNamespace, brace_0010) {
|
||||
estyle::Generator interface;
|
||||
//interface.properties.set("brace-namespace-in-new-line-before", "true");
|
||||
//interface.properties.set("brace-namespace-in-new-line-after", "true");
|
||||
interface.properties.set("brace-namespace-in-space-before", "true");
|
||||
//interface.properties.set("brace-namespace-in-space-after", "true");
|
||||
//interface.properties.set("brace-namespace-out-new-line-before", "true");
|
||||
//interface.properties.set("brace-namespace-out-new-line-after", "true");
|
||||
interface.properties.set("brace-namespace-out-space-before", "true");
|
||||
//interface.properties.set("brace-namespace-out-space-after", "true");
|
||||
etk::String outputRef = "action_A;\nnamespace myNamespace {action_B; }action_D;";
|
||||
etk::String output = interface.process(sourceNamespace);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
}
|
||||
|
||||
TEST(testNamespace, brace_0011) {
|
||||
estyle::Generator interface;
|
||||
//interface.properties.set("brace-namespace-in-new-line-before", "true");
|
||||
//interface.properties.set("brace-namespace-in-new-line-after", "true");
|
||||
interface.properties.set("brace-namespace-in-space-before", "true");
|
||||
interface.properties.set("brace-namespace-in-space-after", "true");
|
||||
//interface.properties.set("brace-namespace-out-new-line-before", "true");
|
||||
//interface.properties.set("brace-namespace-out-new-line-after", "true");
|
||||
interface.properties.set("brace-namespace-out-space-before", "true");
|
||||
interface.properties.set("brace-namespace-out-space-after", "true");
|
||||
etk::String outputRef = "action_A;\nnamespace myNamespace { action_B; } action_D;";
|
||||
etk::String output = interface.process(sourceNamespace);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
}
|
||||
|
||||
TEST(testNamespace, brace_0111) {
|
||||
estyle::Generator interface;
|
||||
//interface.properties.set("brace-namespace-in-new-line-before", "true");
|
||||
interface.properties.set("brace-namespace-in-new-line-after", "true");
|
||||
interface.properties.set("brace-namespace-in-space-before", "true");
|
||||
interface.properties.set("brace-namespace-in-space-after", "true");
|
||||
//interface.properties.set("brace-namespace-out-new-line-before", "true");
|
||||
interface.properties.set("brace-namespace-out-new-line-after", "true");
|
||||
interface.properties.set("brace-namespace-out-space-before", "true");
|
||||
interface.properties.set("brace-namespace-out-space-after", "true");
|
||||
etk::String outputRef = "action_A;\nnamespace myNamespace {\n\taction_B; }\naction_D;";
|
||||
etk::String output = interface.process(sourceNamespace);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
}
|
||||
|
||||
TEST(testNamespace, brace_0001) {
|
||||
estyle::Generator interface;
|
||||
//interface.properties.set("brace-namespace-in-new-line-before", "true");
|
||||
//interface.properties.set("brace-namespace-in-new-line-after", "true");
|
||||
//interface.properties.set("brace-namespace-in-space-before", "true");
|
||||
interface.properties.set("brace-namespace-in-space-after", "true");
|
||||
//interface.properties.set("brace-namespace-out-new-line-before", "true");
|
||||
//interface.properties.set("brace-namespace-out-new-line-after", "true");
|
||||
//interface.properties.set("brace-namespace-out-space-before", "true");
|
||||
interface.properties.set("brace-namespace-out-space-after", "true");
|
||||
etk::String outputRef = "action_A;\nnamespace myNamespace{ action_B;} action_D;";
|
||||
etk::String output = interface.process(sourceNamespace);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
}
|
||||
|
||||
|
0
test/testPreprocessor.cpp
Normal file
0
test/testPreprocessor.cpp
Normal file
0
test/testStruct.cpp
Normal file
0
test/testStruct.cpp
Normal file
0
test/testSwitch.cpp
Normal file
0
test/testSwitch.cpp
Normal file
0
test/testTemplate.cpp
Normal file
0
test/testTemplate.cpp
Normal file
0
test/testType.cpp
Normal file
0
test/testType.cpp
Normal file
@ -1,486 +1 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2017, Edouard DUPIN, all right reserved
|
||||
* @license MPL-2 (see license file)
|
||||
*/
|
||||
#include <test-debug/debug.hpp>
|
||||
#include <etest/etest.hpp>
|
||||
#include "testInterface.hpp"
|
||||
|
||||
|
||||
TEST(testVariable, noVariable) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("// plop");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), false);
|
||||
}
|
||||
|
||||
TEST(testVariable, declare_int) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable int result;");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isInteger32("result"), true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
TEST(testVariable, declare_int_init_1) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable int result(55);");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isInteger32("result"), true);
|
||||
EXPECT_EQ(system.getInteger32("result"), 55);
|
||||
}
|
||||
|
||||
TEST(testVariable, declare_int_init_2) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable int result = 55;");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isInteger32("result"), true);
|
||||
EXPECT_EQ(system.getInteger32("result"), 55);
|
||||
}
|
||||
|
||||
TEST(testVariable, declare_int32_init_1) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable int32 result(55);");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isInteger32("result"), true);
|
||||
EXPECT_EQ(system.getInteger32("result"), 55);
|
||||
}
|
||||
|
||||
TEST(testVariable, declare_int32_init_2) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable int32 result = 55;");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isInteger32("result"), true);
|
||||
EXPECT_EQ(system.getInteger32("result"), 55);
|
||||
}
|
||||
|
||||
TEST(testVariable, declare_int64_init_1) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable int64 result(55);");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isInteger64("result"), true);
|
||||
EXPECT_EQ(system.getInteger64("result"), 55);
|
||||
}
|
||||
|
||||
TEST(testVariable, declare_int64_init_2) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable int64 result = 55;");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isInteger64("result"), true);
|
||||
EXPECT_EQ(system.getInteger64("result"), 55);
|
||||
}
|
||||
|
||||
|
||||
TEST(testVariable, boolean_true_init_1) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable bool result(true);");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isBoolean("result"), true);
|
||||
EXPECT_EQ(system.getBoolean("result"), true);
|
||||
}
|
||||
TEST(testVariable, boolean_true_init_2) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable bool result = true;");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isBoolean("result"), true);
|
||||
EXPECT_EQ(system.getBoolean("result"), true);
|
||||
}
|
||||
|
||||
TEST(testVariable, boolean_false_init_1) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable bool result(false);");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isBoolean("result"), true);
|
||||
EXPECT_EQ(system.getBoolean("result"), false);
|
||||
}
|
||||
|
||||
TEST(testVariable, boolean_false_init_2) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable bool result = false;");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isBoolean("result"), true);
|
||||
EXPECT_EQ(system.getBoolean("result"), false);
|
||||
}
|
||||
|
||||
TEST(testVariable, integer_min_int32) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable int32 result = -2147483648;");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isInteger32("result"), true);
|
||||
EXPECT_EQ(system.getInteger32("result"), -2147483648);
|
||||
}
|
||||
|
||||
TEST(testVariable, integer_max_int32) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable int32 result = 2147483647;");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isInteger32("result"), true);
|
||||
EXPECT_EQ(system.getInteger32("result"), 2147483647);
|
||||
}
|
||||
|
||||
TEST(testVariable, integer_hexadecmal_1) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable int32 result = 0x12345678;");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isInteger32("result"), true);
|
||||
EXPECT_EQ(system.getInteger32("result"), 0x12345678);
|
||||
}
|
||||
|
||||
TEST(testVariable, integer_hexadecmal_2) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable int32 result = 0xABCDEF00;");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isInteger32("result"), true);
|
||||
EXPECT_EQ(system.getInteger32("result"), 0xABCDEF00);
|
||||
}
|
||||
|
||||
TEST(testVariable, integer_hexadecmal_3) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable int32 result = -0x5;");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isInteger32("result"), true);
|
||||
EXPECT_EQ(system.getInteger32("result"), -5);
|
||||
}
|
||||
TEST(testVariable, integer_hexadecmal_4) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable int32 result = 0xFFFFFFFF;");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isInteger32("result"), true);
|
||||
EXPECT_EQ(system.getInteger32("result"), -1);
|
||||
}
|
||||
|
||||
|
||||
TEST(testVariable, integer_float32_0) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable float32 result(0.32452);");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isFloat("result"), true);
|
||||
EXPECT_EQ(system.getFloat("result"), 0.32452);
|
||||
}
|
||||
|
||||
TEST(testVariable, integer_float32_1) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable float32 result = 0.32452;");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isFloat("result"), true);
|
||||
EXPECT_EQ(system.getFloat("result"), 0.32452);
|
||||
}
|
||||
|
||||
TEST(testVariable, integer_float32_2) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable float32 result = -992345.23;");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isDouble("result"), true);
|
||||
EXPECT_EQ(system.getDouble("result"), -992345.23);
|
||||
}
|
||||
|
||||
TEST(testVariable, integer_float32_3) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable float32 result = 3.45e2;");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isDouble("result"), true);
|
||||
EXPECT_EQ(system.getDouble("result"), 3.45e2);
|
||||
}
|
||||
|
||||
TEST(testVariable, integer_float_1) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable float result = 3.45e2;");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isDouble("result"), true);
|
||||
EXPECT_EQ(system.getDouble("result"), 3.45e2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
TEST(testVariable, integer_float64_0) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable float64 result(0.32452);");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isDouble("result"), true);
|
||||
EXPECT_EQ(system.getDouble("result"), 0.32452);
|
||||
}
|
||||
TEST(testVariable, integer_float64_1) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable float64 result = 0.32452;");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isDouble("result"), true);
|
||||
EXPECT_EQ(system.getDouble("result"), 0.32452);
|
||||
}
|
||||
|
||||
TEST(testVariable, integer_float64_2) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable float64 result = -992345.23;");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isDouble("result"), true);
|
||||
EXPECT_EQ(system.getDouble("result"), -992345.23);
|
||||
}
|
||||
|
||||
TEST(testVariable, integer_float64_3) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable float64 result = 3.45e2;");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isDouble("result"), true);
|
||||
EXPECT_EQ(system.getDouble("result"), 3.45e2);
|
||||
}
|
||||
|
||||
TEST(testVariable, integer_octal_1) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable int32 result = 0377;");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isInteger32("result"), true);
|
||||
EXPECT_EQ(system.getInteger32("result"), 255);
|
||||
}
|
||||
/*
|
||||
TEST(testVariable, null_element) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable int32 result = null;");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isNull("result"), true);
|
||||
}
|
||||
*/
|
||||
|
||||
TEST(testVariable, string_0) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable string result(\"hello\");");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isString("result"), true);
|
||||
EXPECT_EQ(system.getString("result"), "hello");
|
||||
}
|
||||
TEST(testVariable, string_1) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable string result = \"hello\";");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isString("result"), true);
|
||||
EXPECT_EQ(system.getString("result"), "hello");
|
||||
}
|
||||
|
||||
TEST(testVariable, string_2) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable string result = 'hello';");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isString("result"), true);
|
||||
EXPECT_EQ(system.getString("result"), "hello");
|
||||
}
|
||||
|
||||
TEST(testVariable, string_1_special_element) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable string result = \"h\\\\n\\\\r\\\"'ello\";");
|
||||
//TEST_INFO(" '" << system.getString("result") << "'");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isString("result"), true);
|
||||
EXPECT_EQ(system.getString("result"), "h\\n\\r\"'ello");
|
||||
}
|
||||
|
||||
TEST(testVariable, string_2_special_element) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable string result = 'h\\\\n\\\\r\"\\\'ello';");
|
||||
//TEST_INFO(" '" << system.getString("result") << "'");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isString("result"), true);
|
||||
EXPECT_EQ(system.getString("result"), "h\\n\\r\"'ello");
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
// undefined
|
||||
//////////////////////////////////////////////////////
|
||||
/*
|
||||
TEST(testVariable, undef_1) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable result;");
|
||||
//TEST_INFO(" '" << system.getString("result") << "'");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isUndefined("result"), true);
|
||||
}
|
||||
TEST(testVariable, undef_2) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable result; if ((\"\"+result) != \"undefined\") result=1;");
|
||||
//TEST_INFO(" '" << system.getString("result") << "'");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isUndefined("result"), true);
|
||||
}
|
||||
|
||||
TEST(testVariable, undef_property) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable result={}; if ((\"\"+result.noProperty) != \"undefined\") result=1;");
|
||||
//TEST_INFO(" '" << system.getString("result") << "'");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isInteger32("result"), false);
|
||||
}
|
||||
|
||||
TEST(testVariable, undef_to_null) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable result; if (result == null) result=1;");
|
||||
//TEST_INFO(" '" << system.getString("result") << "'");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isInteger32("result"), true);
|
||||
}
|
||||
|
||||
TEST(testVariable, undef_to_null_type) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable result; if (result === null) result=1;");
|
||||
//TEST_INFO(" '" << system.getString("result") << "'");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isInteger32("result"), false);
|
||||
}
|
||||
*/
|
||||
//////////////////////////////////////////////////////
|
||||
// null
|
||||
//////////////////////////////////////////////////////
|
||||
/*
|
||||
TEST(testVariable, undefined_and_null_1) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable result = 0; if (undefined == null) result=1;");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isInteger32("result"), true);
|
||||
EXPECT_EQ(system.getInteger32("result"), 1);
|
||||
}
|
||||
TEST(testVariable, undefined_and_null_2) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable result = 0; if (undefined === null) result=1;");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isInteger32("result"), true);
|
||||
EXPECT_EQ(system.getInteger32("result"), 0);
|
||||
}
|
||||
TEST(testVariable, undefined_and_null_3) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable result = 0; if (null != undefined) result=1;");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isInteger32("result"), true);
|
||||
EXPECT_EQ(system.getInteger32("result"), 0);
|
||||
}
|
||||
|
||||
TEST(testVariable, undefined_and_null_4) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable result = 0; if (null === undefined) result=1;");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isInteger32("result"), true);
|
||||
EXPECT_EQ(system.getInteger32("result"), 0);
|
||||
}
|
||||
*/
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
// array
|
||||
//////////////////////////////////////////////////////
|
||||
/*
|
||||
TEST(testVariable, array_declare_1) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable result = [];");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isArray("result"), true);
|
||||
}
|
||||
|
||||
TEST(testVariable, array_declare_2) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable result = [10,11,12]; variable a=result[0]; variable b=result[2];");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isArray("result"), true);
|
||||
EXPECT_EQ(system.exist("a"), true);
|
||||
EXPECT_EQ(system.isInteger32("a"), true);
|
||||
EXPECT_EQ(system.getInteger32("a"), 10);
|
||||
EXPECT_EQ(system.exist("b"), true);
|
||||
EXPECT_EQ(system.isInteger32("b"), true);
|
||||
EXPECT_EQ(system.getInteger32("b"), 12);
|
||||
}
|
||||
|
||||
TEST(testVariable, array_declare_polymorph) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable result = [10,11.55,\"hello\"]; variable a=result[0]; variable b=result[1]; variable c=result[2];");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isArray("result"), true);
|
||||
EXPECT_EQ(system.exist("a"), true);
|
||||
EXPECT_EQ(system.isInteger32("a"), true);
|
||||
EXPECT_EQ(system.getInteger32("a"), 10);
|
||||
EXPECT_EQ(system.exist("b"), true);
|
||||
EXPECT_EQ(system.isDouble("b"), true);
|
||||
EXPECT_EQ(system.getDouble("b"), 11.55);
|
||||
EXPECT_EQ(system.exist("c"), true);
|
||||
EXPECT_EQ(system.isString("c"), true);
|
||||
EXPECT_EQ(system.getString("c"), "hello");
|
||||
}
|
||||
|
||||
|
||||
|
||||
TEST(testVariable, array_asign) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable result = [10,11]; result[0] = 5; result[5] = 99; variable a=result[0]; variable b=result[5]; variable c=result[1]; result[1] = 4;");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isArray("result"), true);
|
||||
EXPECT_EQ(system.exist("a"), true);
|
||||
EXPECT_EQ(system.isInteger32("a"), true);
|
||||
EXPECT_EQ(system.getInteger32("a"), 5);
|
||||
EXPECT_EQ(system.exist("b"), true);
|
||||
EXPECT_EQ(system.isInteger32("b"), true);
|
||||
EXPECT_EQ(system.getInteger32("b"), 99);
|
||||
EXPECT_EQ(system.exist("c"), true);
|
||||
EXPECT_EQ(system.isInteger32("c"), true);
|
||||
EXPECT_EQ(system.getInteger32("c"), 11);
|
||||
}
|
||||
|
||||
|
||||
TEST(testVariable, array_asign_reference) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable result = [10,11]; variable result2=result; result2[0] = 5; variable a=result[0];");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isArray("result"), true);
|
||||
EXPECT_EQ(system.exist("a"), true);
|
||||
EXPECT_EQ(system.isInteger32("a"), true);
|
||||
EXPECT_EQ(system.getInteger32("a"), 5);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,230 +0,0 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2017, Edouard DUPIN, all right reserved
|
||||
* @license MPL-2 (see license file)
|
||||
*/
|
||||
#include <test-debug/debug.hpp>
|
||||
#include <etest/etest.hpp>
|
||||
#include "testInterface.hpp"
|
||||
|
||||
|
||||
///////////////////////////////////////////////
|
||||
// BOOLEAN
|
||||
///////////////////////////////////////////////
|
||||
|
||||
TEST(testVariableCompare, boolean_equal_1) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable a = true;\nvariable b = false;\nvariable result = a == b;");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isBoolean("result"), true);
|
||||
EXPECT_EQ(system.getBoolean("result"), false);
|
||||
}
|
||||
|
||||
TEST(testVariableCompare, boolean_equal_2) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable a = true;\nvariable b = true;\nvariable result = a == b;");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isBoolean("result"), true);
|
||||
EXPECT_EQ(system.getBoolean("result"), true);
|
||||
}
|
||||
|
||||
TEST(testVariableCompare, boolean_not_equal_1) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable a = true;\nvariable b = false;\nvariable result = a != b;");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isBoolean("result"), true);
|
||||
EXPECT_EQ(system.getBoolean("result"), true);
|
||||
}
|
||||
|
||||
TEST(testVariableCompare, boolean_not_equal_2) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable a = true;\nvariable b = true;\nvariable result = a != b;");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isBoolean("result"), true);
|
||||
EXPECT_EQ(system.getBoolean("result"), false);
|
||||
}
|
||||
|
||||
TEST(testVariableCompare, boolean_equal_unexisting) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable a = true;\nvariable result = a == b;");
|
||||
TEST_TODO("NOT implemented");
|
||||
EXPECT_EQ(ret, false); // ==> must have an error on the parsing/execution
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isBoolean("result"), true);
|
||||
EXPECT_EQ(system.getBoolean("result"), false);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////
|
||||
// INTEGER
|
||||
///////////////////////////////////////////////
|
||||
|
||||
// ==
|
||||
|
||||
TEST(testVariableCompare, integer_equal_1) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable a = 45;\nvariable b = 55;\nvariable result = a == b;");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isBoolean("result"), true);
|
||||
EXPECT_EQ(system.getBoolean("result"), false);
|
||||
}
|
||||
|
||||
TEST(testVariableCompare, integer_equal_2) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable a = 45;\nvariable b = 45;\nvariable result = a == b;");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isBoolean("result"), true);
|
||||
EXPECT_EQ(system.getBoolean("result"), true);
|
||||
}
|
||||
|
||||
// !=
|
||||
|
||||
TEST(testVariableCompare, integer_not_equal_1) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable a = 234;\nvariable b = 345;\nvariable result = a != b;");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isBoolean("result"), true);
|
||||
EXPECT_EQ(system.getBoolean("result"), true);
|
||||
}
|
||||
|
||||
TEST(testVariableCompare, integer_not_equal_2) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable a = 567;\nvariable b = 567;\nvariable result = a != b;");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isBoolean("result"), true);
|
||||
EXPECT_EQ(system.getBoolean("result"), false);
|
||||
}
|
||||
|
||||
TEST(testVariableCompare, integer_not_equal_3) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable a = 567;\nvariable b = 567;\nvariable result = !(a == b);");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isBoolean("result"), true);
|
||||
EXPECT_EQ(system.getBoolean("result"), false);
|
||||
}
|
||||
|
||||
// <
|
||||
|
||||
TEST(testVariableCompare, integer_less_1) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable a = 45;\nvariable b = 55;\nvariable result = a < b;");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isBoolean("result"), true);
|
||||
EXPECT_EQ(system.getBoolean("result"), true);
|
||||
}
|
||||
|
||||
TEST(testVariableCompare, integer_less_2) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable a = 45;\nvariable b = -5;\nvariable result = a < b;");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isBoolean("result"), true);
|
||||
EXPECT_EQ(system.getBoolean("result"), false);
|
||||
}
|
||||
|
||||
TEST(testVariableCompare, integer_less_3) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable a = 45;\nvariable b = 45;\nvariable result = a < b;");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isBoolean("result"), true);
|
||||
EXPECT_EQ(system.getBoolean("result"), false);
|
||||
}
|
||||
|
||||
// <=
|
||||
|
||||
TEST(testVariableCompare, integer_less_equal_1) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable a = 45;\nvariable b = 55;\nvariable result = a <= b;");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isBoolean("result"), true);
|
||||
EXPECT_EQ(system.getBoolean("result"), true);
|
||||
}
|
||||
|
||||
TEST(testVariableCompare, integer_less_equal_2) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable a = 45;\nvariable b = -5;\nvariable result = a <= b;");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isBoolean("result"), true);
|
||||
EXPECT_EQ(system.getBoolean("result"), false);
|
||||
}
|
||||
|
||||
TEST(testVariableCompare, integer_less_equal_3) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable a = 45;\nvariable b = 45;\nvariable result = a <= b;");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isBoolean("result"), true);
|
||||
EXPECT_EQ(system.getBoolean("result"), true);
|
||||
}
|
||||
|
||||
|
||||
// >
|
||||
|
||||
TEST(testVariableCompare, integer_greater_1) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable a = 45;\nvariable b = 55;\nvariable result = a > b;");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isBoolean("result"), true);
|
||||
EXPECT_EQ(system.getBoolean("result"), false);
|
||||
}
|
||||
|
||||
TEST(testVariableCompare, integer_greater_2) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable a = 45;\nvariable b = -5;\nvariable result = a > b;");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isBoolean("result"), true);
|
||||
EXPECT_EQ(system.getBoolean("result"), true);
|
||||
}
|
||||
|
||||
TEST(testVariableCompare, integer_greater_3) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable a = 45;\nvariable b = 45;\nvariable result = a > b;");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isBoolean("result"), true);
|
||||
EXPECT_EQ(system.getBoolean("result"), false);
|
||||
}
|
||||
|
||||
// >=
|
||||
|
||||
TEST(testVariableCompare, integer_greater_equal_1) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable a = 45;\nvariable b = 55;\nvariable result = a >= b;");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isBoolean("result"), true);
|
||||
EXPECT_EQ(system.getBoolean("result"), false);
|
||||
}
|
||||
|
||||
TEST(testVariableCompare, integer_greater_equal_2) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable a = 45;\nvariable b = -5;\nvariable result = a >= b;");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isBoolean("result"), true);
|
||||
EXPECT_EQ(system.getBoolean("result"), true);
|
||||
}
|
||||
|
||||
TEST(testVariableCompare, integer_greater_equal_3) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable a = 45;\nvariable b = 45;\nvariable result = a >= b;");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isBoolean("result"), true);
|
||||
EXPECT_EQ(system.getBoolean("result"), true);
|
||||
}
|
||||
|
@ -1,45 +0,0 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2017, Edouard DUPIN, all right reserved
|
||||
* @license MPL-2 (see license file)
|
||||
*/
|
||||
#include <test-debug/debug.hpp>
|
||||
#include <etest/etest.hpp>
|
||||
#include "testInterface.hpp"
|
||||
|
||||
|
||||
TEST(testVariableScope, solo_block_local) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable result = true; { variable result = false; };");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isBoolean("result"), true);
|
||||
EXPECT_EQ(system.getBoolean("result"), true);
|
||||
}
|
||||
|
||||
TEST(testVariableScope, solo_block_global) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable result = true; { result = false; };");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isBoolean("result"), true);
|
||||
EXPECT_EQ(system.getBoolean("result"), false);
|
||||
}
|
||||
|
||||
TEST(testVariableScope, function_block_global) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable result = true; variable call = function () { result = false; }; call();");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isBoolean("result"), true);
|
||||
EXPECT_EQ(system.getBoolean("result"), false);
|
||||
}
|
||||
|
||||
TEST(testVariableScope, function_block_local) {
|
||||
testInterface system;
|
||||
bool ret = system.execute("variable result = true; variable call = function () { variable result = false; }; call();");
|
||||
EXPECT_EQ(ret, true);
|
||||
EXPECT_EQ(system.exist("result"), true);
|
||||
EXPECT_EQ(system.isBoolean("result"), true);
|
||||
EXPECT_EQ(system.getBoolean("result"), true);
|
||||
}
|
442
test/testWhile.cpp
Normal file
442
test/testWhile.cpp
Normal file
@ -0,0 +1,442 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2017, Edouard DUPIN, all right reserved
|
||||
* @license MPL-2 (see license file)
|
||||
*/
|
||||
#include <estyle/estyle.hpp>
|
||||
#include <estyle/Generator.hpp>
|
||||
#include <etk/etk.hpp>
|
||||
#include <etk/os/FSNode.hpp>
|
||||
#include <test-debug/debug.hpp>
|
||||
#include <etest/etest.hpp>
|
||||
|
||||
static etk::String sourceWhile1Action = "action_A;while(true){action_B;}action_D;";
|
||||
static etk::String sourceWhile1ActionNoBrace = "action_A;while(true)action_B;action_D;";
|
||||
static etk::String sourceWhile2Action = "action_A;while(true){action_B;action_C;}action_D;";
|
||||
|
||||
|
||||
TEST(testWhile, brace_while_0000) {
|
||||
estyle::Generator interface;
|
||||
//interface.properties.set("brace-while-in-new-line-before", "true");
|
||||
//interface.properties.set("brace-while-in-new-line-after", "true");
|
||||
//interface.properties.set("brace-while-in-space-before", "true");
|
||||
//interface.properties.set("brace-while-in-space-after", "true");
|
||||
//interface.properties.set("brace-while-out-new-line-before", "true");
|
||||
//interface.properties.set("brace-while-out-new-line-after", "true");
|
||||
//interface.properties.set("brace-while-out-space-before", "true");
|
||||
//interface.properties.set("brace-while-out-space-after", "true");
|
||||
//interface.properties.set("brace-while-single", "true");
|
||||
etk::String outputRef = "action_A;\nwhile (true ){action_B;}action_D;";
|
||||
etk::String output = interface.process(sourceWhile1Action);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
output = interface.process(sourceWhile1ActionNoBrace);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
}
|
||||
|
||||
TEST(testWhile, brace_while_1000) {
|
||||
estyle::Generator interface;
|
||||
interface.properties.set("brace-while-in-new-line-before", "true");
|
||||
//interface.properties.set("brace-while-in-new-line-after", "true");
|
||||
//interface.properties.set("brace-while-in-space-before", "true");
|
||||
//interface.properties.set("brace-while-in-space-after", "true");
|
||||
interface.properties.set("brace-while-out-new-line-before", "true");
|
||||
//interface.properties.set("brace-while-out-new-line-after", "true");
|
||||
//interface.properties.set("brace-while-out-space-before", "true");
|
||||
//interface.properties.set("brace-while-out-space-after", "true");
|
||||
//interface.properties.set("brace-while-single", "true");
|
||||
etk::String outputRef = "action_A;\nwhile (true )\n{action_B;\n}action_D;";
|
||||
etk::String output = interface.process(sourceWhile1Action);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
output = interface.process(sourceWhile1ActionNoBrace);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
}
|
||||
|
||||
TEST(testWhile, brace_while_1010) {
|
||||
estyle::Generator interface;
|
||||
interface.properties.set("brace-while-in-new-line-before", "true");
|
||||
//interface.properties.set("brace-while-in-new-line-after", "true");
|
||||
interface.properties.set("brace-while-in-space-before", "true");
|
||||
//interface.properties.set("brace-while-in-space-after", "true");
|
||||
interface.properties.set("brace-while-out-new-line-before", "true");
|
||||
//interface.properties.set("brace-while-out-new-line-after", "true");
|
||||
interface.properties.set("brace-while-out-space-before", "true");
|
||||
//interface.properties.set("brace-while-out-space-after", "true");
|
||||
//interface.properties.set("brace-while-single", "true");
|
||||
etk::String outputRef = "action_A;\nwhile (true )\n{action_B;\n}action_D;";
|
||||
etk::String output = interface.process(sourceWhile1Action);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
output = interface.process(sourceWhile1ActionNoBrace);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
}
|
||||
|
||||
TEST(testWhile, brace_while_1011) {
|
||||
estyle::Generator interface;
|
||||
interface.properties.set("brace-while-in-new-line-before", "true");
|
||||
//interface.properties.set("brace-while-in-new-line-after", "true");
|
||||
interface.properties.set("brace-while-in-space-before", "true");
|
||||
interface.properties.set("brace-while-in-space-after", "true");
|
||||
interface.properties.set("brace-while-out-new-line-before", "true");
|
||||
//interface.properties.set("brace-while-out-new-line-after", "true");
|
||||
interface.properties.set("brace-while-out-space-before", "true");
|
||||
interface.properties.set("brace-while-out-space-after", "true");
|
||||
//interface.properties.set("brace-while-single", "true");
|
||||
etk::String outputRef = "action_A;\nwhile (true )\n{ action_B;\n} action_D;";
|
||||
etk::String output = interface.process(sourceWhile1Action);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
output = interface.process(sourceWhile1ActionNoBrace);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
}
|
||||
|
||||
TEST(testWhile, brace_while_1100) {
|
||||
estyle::Generator interface;
|
||||
interface.properties.set("brace-while-in-new-line-before", "true");
|
||||
interface.properties.set("brace-while-in-new-line-after", "true");
|
||||
//interface.properties.set("brace-while-in-space-before", "true");
|
||||
//interface.properties.set("brace-while-in-space-after", "true");
|
||||
interface.properties.set("brace-while-out-new-line-before", "true");
|
||||
interface.properties.set("brace-while-out-new-line-after", "true");
|
||||
//interface.properties.set("brace-while-out-space-before", "true");
|
||||
//interface.properties.set("brace-while-out-space-after", "true");
|
||||
//interface.properties.set("brace-while-single", "true");
|
||||
etk::String outputRef = "action_A;\nwhile (true )\n{\n\taction_B;\n}\naction_D;";
|
||||
etk::String output = interface.process(sourceWhile1Action);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
output = interface.process(sourceWhile1ActionNoBrace);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
}
|
||||
|
||||
TEST(testWhile, brace_while_1101) {
|
||||
estyle::Generator interface;
|
||||
interface.properties.set("brace-while-in-new-line-before", "true");
|
||||
interface.properties.set("brace-while-in-new-line-after", "true");
|
||||
//interface.properties.set("brace-while-in-space-before", "true");
|
||||
interface.properties.set("brace-while-in-space-after", "true");
|
||||
interface.properties.set("brace-while-out-new-line-before", "true");
|
||||
interface.properties.set("brace-while-out-new-line-after", "true");
|
||||
//interface.properties.set("brace-while-out-space-before", "true");
|
||||
interface.properties.set("brace-while-out-space-after", "true");
|
||||
//interface.properties.set("brace-while-single", "true");
|
||||
etk::String outputRef = "action_A;\nwhile (true )\n{\n\taction_B;\n}\naction_D;";
|
||||
etk::String output = interface.process(sourceWhile1Action);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
output = interface.process(sourceWhile1ActionNoBrace);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
}
|
||||
|
||||
TEST(testWhile, brace_while_1110) {
|
||||
estyle::Generator interface;
|
||||
interface.properties.set("brace-while-in-new-line-before", "true");
|
||||
interface.properties.set("brace-while-in-new-line-after", "true");
|
||||
interface.properties.set("brace-while-in-space-before", "true");
|
||||
//interface.properties.set("brace-while-in-space-after", "true");
|
||||
interface.properties.set("brace-while-out-new-line-before", "true");
|
||||
interface.properties.set("brace-while-out-new-line-after", "true");
|
||||
interface.properties.set("brace-while-out-space-before", "true");
|
||||
//interface.properties.set("brace-while-out-space-after", "true");
|
||||
//interface.properties.set("brace-while-single", "true");
|
||||
etk::String outputRef = "action_A;\nwhile (true )\n{\n\taction_B;\n}\naction_D;";
|
||||
etk::String output = interface.process(sourceWhile1Action);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
output = interface.process(sourceWhile1ActionNoBrace);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
}
|
||||
|
||||
TEST(testWhile, brace_while_1111) {
|
||||
estyle::Generator interface;
|
||||
interface.properties.set("brace-while-in-new-line-before", "true");
|
||||
interface.properties.set("brace-while-in-new-line-after", "true");
|
||||
interface.properties.set("brace-while-in-space-before", "true");
|
||||
interface.properties.set("brace-while-in-space-after", "true");
|
||||
interface.properties.set("brace-while-out-new-line-before", "true");
|
||||
interface.properties.set("brace-while-out-new-line-after", "true");
|
||||
interface.properties.set("brace-while-out-space-before", "true");
|
||||
interface.properties.set("brace-while-out-space-after", "true");
|
||||
//interface.properties.set("brace-while-single", "true");
|
||||
etk::String outputRef = "action_A;\nwhile (true )\n{\n\taction_B;\n}\naction_D;";
|
||||
etk::String output = interface.process(sourceWhile1Action);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
output = interface.process(sourceWhile1ActionNoBrace);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
}
|
||||
|
||||
TEST(testWhile, brace_while_1001) {
|
||||
estyle::Generator interface;
|
||||
interface.properties.set("brace-while-in-new-line-before", "true");
|
||||
//interface.properties.set("brace-while-in-new-line-after", "true");
|
||||
//interface.properties.set("brace-while-in-space-before", "true");
|
||||
interface.properties.set("brace-while-in-space-after", "true");
|
||||
interface.properties.set("brace-while-out-new-line-before", "true");
|
||||
//interface.properties.set("brace-while-out-new-line-after", "true");
|
||||
//interface.properties.set("brace-while-out-space-before", "true");
|
||||
interface.properties.set("brace-while-out-space-after", "true");
|
||||
//interface.properties.set("brace-while-single", "true");
|
||||
etk::String outputRef = "action_A;\nwhile (true )\n{ action_B;\n} action_D;";
|
||||
etk::String output = interface.process(sourceWhile1Action);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
output = interface.process(sourceWhile1ActionNoBrace);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
}
|
||||
|
||||
|
||||
TEST(testWhile, brace_while_0100) {
|
||||
estyle::Generator interface;
|
||||
//interface.properties.set("brace-while-in-new-line-before", "true");
|
||||
interface.properties.set("brace-while-in-new-line-after", "true");
|
||||
//interface.properties.set("brace-while-in-space-before", "true");
|
||||
//interface.properties.set("brace-while-in-space-after", "true");
|
||||
//interface.properties.set("brace-while-out-new-line-before", "true");
|
||||
interface.properties.set("brace-while-out-new-line-after", "true");
|
||||
//interface.properties.set("brace-while-out-space-before", "true");
|
||||
//interface.properties.set("brace-while-out-space-after", "true");
|
||||
//interface.properties.set("brace-while-single", "true");
|
||||
etk::String outputRef = "action_A;\nwhile (true ){\n\taction_B;}\naction_D;";
|
||||
etk::String output = interface.process(sourceWhile1Action);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
output = interface.process(sourceWhile1ActionNoBrace);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
}
|
||||
|
||||
TEST(testWhile, brace_while_0101) {
|
||||
estyle::Generator interface;
|
||||
//interface.properties.set("brace-while-in-new-line-before", "true");
|
||||
interface.properties.set("brace-while-in-new-line-after", "true");
|
||||
//interface.properties.set("brace-while-in-space-before", "true");
|
||||
interface.properties.set("brace-while-in-space-after", "true");
|
||||
//interface.properties.set("brace-while-out-new-line-before", "true");
|
||||
interface.properties.set("brace-while-out-new-line-after", "true");
|
||||
//interface.properties.set("brace-while-out-space-before", "true");
|
||||
interface.properties.set("brace-while-out-space-after", "true");
|
||||
//interface.properties.set("brace-while-single", "true");
|
||||
etk::String outputRef = "action_A;\nwhile (true ){\n\taction_B;}\naction_D;";
|
||||
etk::String output = interface.process(sourceWhile1Action);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
output = interface.process(sourceWhile1ActionNoBrace);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
}
|
||||
|
||||
TEST(testWhile, brace_while_0110) {
|
||||
estyle::Generator interface;
|
||||
//interface.properties.set("brace-while-in-new-line-before", "true");
|
||||
interface.properties.set("brace-while-in-new-line-after", "true");
|
||||
interface.properties.set("brace-while-in-space-before", "true");
|
||||
//interface.properties.set("brace-while-in-space-after", "true");
|
||||
//interface.properties.set("brace-while-out-new-line-before", "true");
|
||||
interface.properties.set("brace-while-out-new-line-after", "true");
|
||||
interface.properties.set("brace-while-out-space-before", "true");
|
||||
//interface.properties.set("brace-while-out-space-after", "true");
|
||||
//interface.properties.set("brace-while-single", "true");
|
||||
etk::String outputRef = "action_A;\nwhile (true ) {\n\taction_B; }\naction_D;";
|
||||
etk::String output = interface.process(sourceWhile1Action);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
output = interface.process(sourceWhile1ActionNoBrace);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
}
|
||||
|
||||
TEST(testWhile, brace_while_0010) {
|
||||
estyle::Generator interface;
|
||||
//interface.properties.set("brace-while-in-new-line-before", "true");
|
||||
//interface.properties.set("brace-while-in-new-line-after", "true");
|
||||
interface.properties.set("brace-while-in-space-before", "true");
|
||||
//interface.properties.set("brace-while-in-space-after", "true");
|
||||
//interface.properties.set("brace-while-out-new-line-before", "true");
|
||||
//interface.properties.set("brace-while-out-new-line-after", "true");
|
||||
interface.properties.set("brace-while-out-space-before", "true");
|
||||
//interface.properties.set("brace-while-out-space-after", "true");
|
||||
//interface.properties.set("brace-while-single", "true");
|
||||
etk::String outputRef = "action_A;\nwhile (true ) {action_B; }action_D;";
|
||||
etk::String output = interface.process(sourceWhile1Action);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
output = interface.process(sourceWhile1ActionNoBrace);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
}
|
||||
|
||||
TEST(testWhile, brace_while_0011) {
|
||||
estyle::Generator interface;
|
||||
//interface.properties.set("brace-while-in-new-line-before", "true");
|
||||
//interface.properties.set("brace-while-in-new-line-after", "true");
|
||||
interface.properties.set("brace-while-in-space-before", "true");
|
||||
interface.properties.set("brace-while-in-space-after", "true");
|
||||
//interface.properties.set("brace-while-out-new-line-before", "true");
|
||||
//interface.properties.set("brace-while-out-new-line-after", "true");
|
||||
interface.properties.set("brace-while-out-space-before", "true");
|
||||
interface.properties.set("brace-while-out-space-after", "true");
|
||||
//interface.properties.set("brace-while-single", "true");
|
||||
etk::String outputRef = "action_A;\nwhile (true ) { action_B; } action_D;";
|
||||
etk::String output = interface.process(sourceWhile1Action);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
output = interface.process(sourceWhile1ActionNoBrace);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
}
|
||||
|
||||
TEST(testWhile, brace_while_0111) {
|
||||
estyle::Generator interface;
|
||||
//interface.properties.set("brace-while-in-new-line-before", "true");
|
||||
interface.properties.set("brace-while-in-new-line-after", "true");
|
||||
interface.properties.set("brace-while-in-space-before", "true");
|
||||
interface.properties.set("brace-while-in-space-after", "true");
|
||||
//interface.properties.set("brace-while-out-new-line-before", "true");
|
||||
interface.properties.set("brace-while-out-new-line-after", "true");
|
||||
interface.properties.set("brace-while-out-space-before", "true");
|
||||
interface.properties.set("brace-while-out-space-after", "true");
|
||||
//interface.properties.set("brace-while-single", "true");
|
||||
etk::String outputRef = "action_A;\nwhile (true ) {\n\taction_B; }\naction_D;";
|
||||
etk::String output = interface.process(sourceWhile1Action);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
output = interface.process(sourceWhile1ActionNoBrace);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
}
|
||||
|
||||
TEST(testWhile, brace_while_0001) {
|
||||
estyle::Generator interface;
|
||||
//interface.properties.set("brace-while-in-new-line-before", "true");
|
||||
//interface.properties.set("brace-while-in-new-line-after", "true");
|
||||
//interface.properties.set("brace-while-in-space-before", "true");
|
||||
interface.properties.set("brace-while-in-space-after", "true");
|
||||
//interface.properties.set("brace-while-out-new-line-before", "true");
|
||||
//interface.properties.set("brace-while-out-new-line-after", "true");
|
||||
//interface.properties.set("brace-while-out-space-before", "true");
|
||||
interface.properties.set("brace-while-out-space-after", "true");
|
||||
//interface.properties.set("brace-while-single", "true");
|
||||
etk::String outputRef = "action_A;\nwhile (true ){ action_B;} action_D;";
|
||||
etk::String output = interface.process(sourceWhile1Action);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
output = interface.process(sourceWhile1ActionNoBrace);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
TEST(testWhile, brace_while_single_00) {
|
||||
estyle::Generator interface;
|
||||
//interface.properties.set("brace-while-single-one-line-size-max", "40");
|
||||
interface.properties.set("brace-while-single", "true");
|
||||
//interface.properties.set("brace-while-single-in-new-line", "true");
|
||||
//interface.properties.set("brace-while-single-in-space", "true");
|
||||
//interface.properties.set("brace-while-single-out-new-line", "true");
|
||||
//interface.properties.set("brace-while-single-out-space", "true");
|
||||
etk::String outputRef = "action_A;\nwhile (true )action_B;\naction_D;";
|
||||
etk::String output = interface.process(sourceWhile1Action);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
output = interface.process(sourceWhile1ActionNoBrace);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
}
|
||||
|
||||
TEST(testWhile, brace_while_single_10) {
|
||||
estyle::Generator interface;
|
||||
//interface.properties.set("brace-while-single-one-line-size-max", "40");
|
||||
interface.properties.set("brace-while-single", "true");
|
||||
interface.properties.set("brace-while-single-in-new-line", "true");
|
||||
//interface.properties.set("brace-while-single-in-space", "true");
|
||||
interface.properties.set("brace-while-single-out-new-line", "true");
|
||||
//interface.properties.set("brace-while-single-out-space", "true");
|
||||
etk::String outputRef = "action_A;\nwhile (true )\n\taction_B;\naction_D;";
|
||||
etk::String output = interface.process(sourceWhile1Action);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
output = interface.process(sourceWhile1ActionNoBrace);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
}
|
||||
|
||||
TEST(testWhile, brace_while_single_01) {
|
||||
estyle::Generator interface;
|
||||
//interface.properties.set("brace-while-single-one-line-size-max", "40");
|
||||
interface.properties.set("brace-while-single", "true");
|
||||
//interface.properties.set("brace-while-single-in-new-line", "true");
|
||||
interface.properties.set("brace-while-single-in-space", "true");
|
||||
//interface.properties.set("brace-while-single-out-new-line", "true");
|
||||
interface.properties.set("brace-while-single-out-space", "true");
|
||||
etk::String outputRef = "action_A;\nwhile (true ) action_B; action_D;";
|
||||
etk::String output = interface.process(sourceWhile1Action);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
output = interface.process(sourceWhile1ActionNoBrace);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
}
|
||||
TEST(testWhile, brace_while_single_11) {
|
||||
estyle::Generator interface;
|
||||
//interface.properties.set("brace-while-single-one-line-size-max", "40");
|
||||
interface.properties.set("brace-while-single", "true");
|
||||
interface.properties.set("brace-while-single-in-new-line", "true");
|
||||
interface.properties.set("brace-while-single-in-space", "true");
|
||||
interface.properties.set("brace-while-single-out-new-line", "true");
|
||||
interface.properties.set("brace-while-single-out-space", "true");
|
||||
etk::String outputRef = "action_A;\nwhile (true )\n\taction_B;\naction_D;";
|
||||
etk::String output = interface.process(sourceWhile1Action);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
output = interface.process(sourceWhile1ActionNoBrace);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
TEST(testWhile, brace_while_oneLine_0) {
|
||||
estyle::Generator interface;
|
||||
interface.properties.set("brace-while-in-new-line-before", "true");
|
||||
interface.properties.set("brace-while-in-new-line-after", "true");
|
||||
interface.properties.set("brace-while-in-space-before", "true");
|
||||
interface.properties.set("brace-while-in-space-after", "true");
|
||||
interface.properties.set("brace-while-out-new-line-before", "true");
|
||||
interface.properties.set("brace-while-out-new-line-after", "true");
|
||||
interface.properties.set("brace-while-out-space-before", "true");
|
||||
//interface.properties.set("brace-while-out-space-after", "true");
|
||||
interface.properties.set("brace-while-single-one-line-size-max", "40");
|
||||
//interface.properties.set("brace-while-single", "true");
|
||||
etk::String outputRef = "action_A;\nwhile (true ) { action_B; }\naction_D;";
|
||||
etk::String output = interface.process(sourceWhile1Action);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
output = interface.process(sourceWhile1ActionNoBrace);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
|
||||
}
|
||||
|
||||
TEST(testWhile, brace_while_oneLine_1) {
|
||||
estyle::Generator interface;
|
||||
interface.properties.set("brace-while-single-one-line-size-max", "40");
|
||||
interface.properties.set("brace-while-single", "true");
|
||||
interface.properties.set("brace-while-single-in-new-line", "true");
|
||||
interface.properties.set("brace-while-single-in-space", "true");
|
||||
interface.properties.set("brace-while-single-out-new-line", "true");
|
||||
interface.properties.set("brace-while-single-out-space", "true");
|
||||
etk::String outputRef = "action_A;\nwhile (true ) action_B;\naction_D;";
|
||||
etk::String output = interface.process(sourceWhile1Action);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
output = interface.process(sourceWhile1ActionNoBrace);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
TEST(testWhile, condition_0) {
|
||||
estyle::Generator interface;
|
||||
//interface.properties.set("brace-while-in-new-line-before", "true");
|
||||
//interface.properties.set("brace-while-in-new-line-after", "true");
|
||||
//interface.properties.set("brace-while-in-space-before", "true");
|
||||
etk::String outputRef = "action_A;\nwhile (true ){action_B;}action_D;";
|
||||
etk::String output = interface.process(sourceWhile1Action);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
//output = interface.process(sourceWhile1ActionNoBrace);
|
||||
//EXPECT_EQ(output, outputRef);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
TEST(testWhile, condition_1) {
|
||||
estyle::Generator interface;
|
||||
//interface.properties.set("brace-while-in-new-line-before", "true");
|
||||
//interface.properties.set("brace-while-in-new-line-after", "true");
|
||||
//interface.properties.set("brace-while-in-space-before", "true");
|
||||
etk::String outputRef = "action_A;\nwhile (condition<6 && my_stupid_variable == 77){action_B;}action_D;";
|
||||
etk::String base = "action_A;while(condition<6 && my_stupid_variable == 77){action_B;}action_D;";
|
||||
etk::String output = interface.process(base);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
interface.properties.set("condition-while-multi-line-big-size", "20");
|
||||
output = interface.process(base);
|
||||
outputRef = "action_A;\nwhile ( condition<6\n && my_stupid_variable==77 ){action_B;}action_D;";
|
||||
EXPECT_EQ(output, outputRef);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user