Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions parameter/ConfigurableDomain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -686,8 +686,6 @@ bool CConfigurableDomain::deleteConfiguration(const string &strName, string &str

void CConfigurableDomain::listAssociatedToElements(string &strResult) const
{
strResult = "\n";

ConfigurableElementListIterator it;

// Browse all configurable elements
Expand Down
6 changes: 0 additions & 6 deletions parameter/ConfigurableDomains.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,6 @@ bool CConfigurableDomains::split(const string &domainName, CConfigurableElement

void CConfigurableDomains::listAssociatedElements(string &strResult) const
{
strResult = "\n";

std::set<const CConfigurableElement *> configurableElementSet;

// Get all owned configurable elements
Expand All @@ -341,8 +339,6 @@ void CConfigurableDomains::listAssociatedElements(string &strResult) const

void CConfigurableDomains::listConflictingElements(string &strResult) const
{
strResult = "\n";

std::set<const CConfigurableElement *> configurableElementSet;

// Get all owned configurable elements
Expand All @@ -369,8 +365,6 @@ void CConfigurableDomains::listConflictingElements(string &strResult) const

void CConfigurableDomains::listDomains(string &strResult) const
{
strResult = "\n";

// List domains
size_t uiNbConfigurableDomains = getNbChildren();

Expand Down
7 changes: 0 additions & 7 deletions parameter/ConfigurableElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -468,8 +468,6 @@ void CConfigurableElement::listBelongingDomains(std::string &strResult, bool bVe
// Elements with no domains
void CConfigurableElement::listRogueElements(std::string &strResult) const
{
strResult = "\n";

// Get rogue element aggregate list (no associated domain)
std::list<const CConfigurableElement *> rogueElementList;

Expand Down Expand Up @@ -568,11 +566,6 @@ void CConfigurableElement::listDomains(
const std::list<const CConfigurableDomain *> &configurableDomainList, std::string &strResult,
bool bVertical) const
{
if (bVertical && configurableDomainList.empty()) {

strResult = "\n";
}

// Fill list
ConfigurableDomainListConstIterator it;
bool bFirst = true;
Expand Down
3 changes: 0 additions & 3 deletions parameter/Element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ string CElement::dumpContent(utility::ErrorContext &errorContext, const size_t d
// Element properties
void CElement::showProperties(string &strResult) const
{
strResult = "\n";
strResult += "Kind: " + getKind() + "\n";
showDescriptionProperty(strResult);
}
Expand Down Expand Up @@ -330,8 +329,6 @@ bool CElement::removeChild(CElement *pChild)

void CElement::listChildren(string &strChildList) const
{
strChildList = "\n";

// Get list of children names
for (CElement *pChild : _childArray) {

Expand Down
2 changes: 1 addition & 1 deletion parameter/MappingData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ bool CMappingData::init(const std::string &rawMapping, std::string &error)

std::string strMappingElement;

while (!(strMappingElement = mappingTok.next()).empty()) {
for (const auto &strMappingElement : mappingTok.split()) {

std::string::size_type iFistDelimiterOccurrence = strMappingElement.find_first_of(':');

Expand Down
4 changes: 0 additions & 4 deletions parameter/ParameterMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1370,8 +1370,6 @@ CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listElementsCommand
return CCommandHandler::EFailed;
}

strResult = string("\n");

if (!pLocatedElement) {

// List from root folder
Expand Down Expand Up @@ -1399,8 +1397,6 @@ CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listParametersComma
return CCommandHandler::EFailed;
}

strResult = string("\n");

if (!pLocatedElement) {

// List from root folder
Expand Down
2 changes: 0 additions & 2 deletions remote-processor/RemoteCommandHandlerTemplate.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,6 @@ class TRemoteCommandHandlerTemplate : public IRemoteCommandHandler
{
initMaxCommandUsageLength();

strResult = "\n";

// Show usages
for (const auto *pRemoteCommandParserItem : _remoteCommandParserVector) {

Expand Down
78 changes: 38 additions & 40 deletions test/tokenizer/Test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,76 +39,74 @@
using std::string;
using std::vector;

using Expected = vector<string>;

SCENARIO("Tokenizer tests")
{
GIVEN ("A default tokenizer") {

GIVEN ("A trivial string") {
Tokenizer tokenizer("a bcd ef");
Expected expected{"a", "bcd", "ef"};

THEN ("next() api should work") {
CHECK(tokenizer.next() == "a");
CHECK(tokenizer.next() == "bcd");
CHECK(tokenizer.next() == "ef");
CHECK(tokenizer.next() == "");
}
THEN ("split() api should work") {
vector<string> expected;
expected.push_back("a");
expected.push_back("bcd");
expected.push_back("ef");

CHECK(tokenizer.split() == expected);
}
}

GIVEN ("An empty string") {
Tokenizer tokenizer("");
Expected expected{};

THEN ("next() api should work") {
CHECK(tokenizer.next() == "");
THEN ("split() should be empty") {
CHECK(tokenizer.split() == expected);
}
THEN ("split() api should work") {
vector<string> expected;
}

CHECK(tokenizer.split().empty());
GIVEN ("Multiple separators in a row") {
Tokenizer tokenizer(" a \n\t bc ");
Expected expected{"a", "bc"};

THEN ("split() api should work") {
CHECK(tokenizer.split() == expected);
}
}
}

GIVEN ("A slash-separated string and tokenizer") {
Tokenizer tokenizer("/a/bcd/ef g/h/", "/");
GIVEN ("A slash-separated string and tokenizer") {
Tokenizer tokenizer("/a/bcd/ef g/h/", "/");
Expected expected{"a", "bcd", "ef g", "h"};

THEN ("next() api should work") {
CHECK(tokenizer.next() == "a");
CHECK(tokenizer.next() == "bcd");
CHECK(tokenizer.next() == "ef g");
CHECK(tokenizer.next() == "h");
CHECK(tokenizer.next() == "");
THEN ("split() api should work") {
CHECK(tokenizer.split() == expected);
}
}

GIVEN ("A tokenizer that doesn't merge consecutive separators") {

GIVEN ("An empty string") {
Tokenizer tokenizer("", Tokenizer::defaultDelimiters, false);
Expected expected{};

THEN ("split() should be empty") {
CHECK(tokenizer.split() == expected);
}
THEN ("split() api should work") {
vector<string> expected;
expected.push_back("a");
expected.push_back("bcd");
expected.push_back("ef g");
expected.push_back("h");
}

GIVEN ("A string consisting only of a delimiter") {
Tokenizer tokenizer(",", ",", false);
Expected expected{"", ""};

THEN ("split() should return two empty tokens") {
CHECK(tokenizer.split() == expected);
}
}

GIVEN ("Multiple separators in a row") {
Tokenizer tokenizer(" a \n\t bc ");
Tokenizer tokenizer(" a b \nc d ", Tokenizer::defaultDelimiters, false);
Expected expected{"", "a", "", "b", "", "c", "d", ""};

THEN ("next() api should work") {
CHECK(tokenizer.next() == "a");
CHECK(tokenizer.next() == "bc");
CHECK(tokenizer.next() == "");
}
THEN ("split() api should work") {
vector<string> expected;
expected.push_back("a");
expected.push_back("bc");

CHECK(tokenizer.split() == expected);
}
}
Expand Down
1 change: 1 addition & 0 deletions test/xml-generator/PFConfig/duplicate_criterion_value.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
InclusiveCriterion Duplicate : Foo Foo
3 changes: 3 additions & 0 deletions test/xml-generator/PFConfig/structure.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
<InstanceDefinition>

<Component Name="included" Type="Included"/>
<ParameterBlock Name="inline">
<BooleanParameter Name="bool"/>
</ParameterBlock>

<ParameterBlock Name="block" ArrayLength="5">
<FixedPointParameter Name="q2.5" Size="8" Integral="2" Fractional="5"/>
Expand Down
41 changes: 28 additions & 13 deletions test/xml-generator/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,27 +90,42 @@ def check(self, reference=None, expectedErrors=0):
config_dir = os.path.join(basedir, "PFConfig")
vector_dir = os.path.join(basedir, "testVector")
class TestCase(unittest.TestCase):
nominal_reference = open(os.path.join(vector_dir, "reference.xml")).read().splitlines()
nominal_pfconfig = PfConfig(os.path.join(config_dir, "configuration.xml"),
os.path.join(config_dir, "criteria.txt"),
os.path.join(basedir, "../../schemas"))
nominal_vector = TestVector(os.path.join(vector_dir, "initialSettings.xml"),
[os.path.join(vector_dir, "first.pfw"),
os.path.join(vector_dir, "second.pfw"),
os.path.join(vector_dir, "complex.pfw")],
[os.path.join(vector_dir, "third.xml"),
os.path.join(vector_dir, "fourth.xml")])
def setUp(self):
self.nominal_reference = open(os.path.join(vector_dir, "reference.xml")).read().splitlines()
self.nominal_pfconfig = PfConfig(os.path.join(config_dir, "configuration.xml"),
os.path.join(config_dir, "criteria.txt"),
os.path.join(basedir, "../../schemas"))
self.nominal_vector = TestVector(os.path.join(vector_dir, "initialSettings.xml"),
[os.path.join(vector_dir, "first.pfw"),
os.path.join(vector_dir, "second.pfw"),
os.path.join(vector_dir, "complex.pfw")],
[os.path.join(vector_dir, "third.xml"),
os.path.join(vector_dir, "fourth.xml")])

def test_nominal(self):
tester = Tester(self.nominal_pfconfig, self.nominal_vector)
tester.check(self.nominal_reference)

def test_nonfatalError(self):
vector = copy.copy(self.nominal_vector)
vector.edds.append(os.path.join(vector_dir, "duplicate.pfw"))
self.nominal_vector.edds.append(os.path.join(vector_dir, "duplicate.pfw"))

tester = Tester(self.nominal_pfconfig, vector)
tester = Tester(self.nominal_pfconfig, self.nominal_vector)
tester.check(self.nominal_reference, expectedErrors=1)

def test_conflicting(self):
vector = TestVector(edds=[os.path.join(vector_dir, "conflicting.pfw")])

tester = Tester(self.nominal_pfconfig, vector)
tester.check(expectedErrors=1)

def test_fail_criteria(self):
self.nominal_pfconfig.criteria = os.path.join(config_dir, "duplicate_criterion_value.txt")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line 2 long

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope: it is 98 chars long.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

# Empty test vector: we want to make sure that the erroneous criterion
# is the only source of error
empty_vector = TestVector()

tester = Tester(self.nominal_pfconfig, empty_vector)
tester.check(expectedErrors=1)

if __name__ == "__main__":
unittest.main()
4 changes: 2 additions & 2 deletions test/xml-generator/testVector/complex.pfw
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ domainGroup: Red sequenceAware
Colors Includes Blue

component: /Test/test
component: block/3
component: block/0
q2.5 = 1.18750
string = 12 ab @ <![CDATA[ < > \n \0 ✔ "'\
component: included
component: inline
bool = 1
7 changes: 7 additions & 0 deletions test/xml-generator/testVector/conflicting.pfw
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Causes a conflicting-element error
domain: First
conf: Default
/Test/test/included/bool = 1
domain: Second
conf: Default
/Test/test/included/bool = 0
3 changes: 2 additions & 1 deletion test/xml-generator/testVector/first.pfw
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ domainGroup: EddGroup

component: /Test/test/block/1
q2.5 = 1.2
string = some string
# set to an empty string
string =

# Inherits from "EddGroup" domainGroup, "First" domain
# and from "Green" confGroup
Expand Down
14 changes: 7 additions & 7 deletions test/xml-generator/testVector/reference.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
<FixedPointParameter Name="q2.5">1.18750</FixedPointParameter>
</ConfigurableElement>
<ConfigurableElement Path="/Test/test/block/1/string">
<StringParameter Name="string">some string</StringParameter>
<StringParameter Name="string"></StringParameter>
</ConfigurableElement>
</Configuration>
<Configuration Name="Green.Off">
Expand Down Expand Up @@ -200,19 +200,19 @@
</Configuration>
</Configurations>
<ConfigurableElements>
<ConfigurableElement Path="/Test/test/block/3/q2.5"/>
<ConfigurableElement Path="/Test/test/block/3/string"/>
<ConfigurableElement Path="/Test/test/included/bool"/>
<ConfigurableElement Path="/Test/test/block/0/q2.5"/>
<ConfigurableElement Path="/Test/test/block/0/string"/>
<ConfigurableElement Path="/Test/test/inline/bool"/>
</ConfigurableElements>
<Settings>
<Configuration Name="green.confGroup..On.Blue.dot">
<ConfigurableElement Path="/Test/test/block/3/q2.5">
<ConfigurableElement Path="/Test/test/block/0/q2.5">
<FixedPointParameter Name="q2.5">1.18750</FixedPointParameter>
</ConfigurableElement>
<ConfigurableElement Path="/Test/test/block/3/string">
<ConfigurableElement Path="/Test/test/block/0/string">
<StringParameter Name="string">12 ab @ &lt;![CDATA[ &lt; &gt; \n \0 ✔ "'\</StringParameter>
</ConfigurableElement>
<ConfigurableElement Path="/Test/test/included/bool">
<ConfigurableElement Path="/Test/test/inline/bool">
<BooleanParameter Name="bool">1</BooleanParameter>
</ConfigurableElement>
</Configuration>
Expand Down
Loading