From f552e9aa9d43aa3d9d0c9fedb12d7f5995b30aaf Mon Sep 17 00:00:00 2001 From: fps Date: Wed, 18 Sep 2013 09:37:11 +0000 Subject: [PATCH] rename setElements to setElement and setComponents to setComponent --- src/XAO/XAO_BooleanStep.cxx | 4 +-- src/XAO/XAO_BooleanStep.hxx | 4 +-- src/XAO/XAO_DoubleStep.cxx | 4 +-- src/XAO/XAO_DoubleStep.hxx | 4 +-- src/XAO/XAO_IntegerStep.cxx | 4 +-- src/XAO/XAO_IntegerStep.hxx | 4 +-- src/XAO/XAO_StringStep.cxx | 4 +-- src/XAO/XAO_StringStep.hxx | 4 +-- src/XAO/tests/FieldTest.cxx | 65 +++++++++++++++++++++++++++---------- 9 files changed, 63 insertions(+), 34 deletions(-) diff --git a/src/XAO/XAO_BooleanStep.cxx b/src/XAO/XAO_BooleanStep.cxx index 8d93c1d44..7a0d81ade 100644 --- a/src/XAO/XAO_BooleanStep.cxx +++ b/src/XAO/XAO_BooleanStep.cxx @@ -112,7 +112,7 @@ throw (XAO_Exception) } } -void BooleanStep::setElements(const int& element, const std::vector& elements) +void BooleanStep::setElement(const int& element, const std::vector& elements) throw (XAO_Exception) { checkElementIndex(element); @@ -122,7 +122,7 @@ throw (XAO_Exception) m_values[element][i] = elements[i]; } -void BooleanStep::setComponents(const int& component, const std::vector& components) +void BooleanStep::setComponent(const int& component, const std::vector& components) throw (XAO_Exception) { checkComponentIndex(component); diff --git a/src/XAO/XAO_BooleanStep.hxx b/src/XAO/XAO_BooleanStep.hxx index c6ceb3e60..9986a069a 100644 --- a/src/XAO/XAO_BooleanStep.hxx +++ b/src/XAO/XAO_BooleanStep.hxx @@ -85,14 +85,14 @@ namespace XAO * @param element the index of the element to set. * @param elements the values to set. */ - void setElements(const int& element, const std::vector& elements) throw (XAO_Exception); + void setElement(const int& element, const std::vector& elements) throw (XAO_Exception); /** * Sets the values for a component. * @param component the index of the component to set. * @param components the values to set. */ - void setComponents(const int& component, const std::vector& components) throw (XAO_Exception); + void setComponent(const int& component, const std::vector& components) throw (XAO_Exception); /** * Sets the value for an element and a component. diff --git a/src/XAO/XAO_DoubleStep.cxx b/src/XAO/XAO_DoubleStep.cxx index f4e5bf9ba..aa5aa3cd3 100644 --- a/src/XAO/XAO_DoubleStep.cxx +++ b/src/XAO/XAO_DoubleStep.cxx @@ -112,7 +112,7 @@ throw (XAO_Exception) } } -void DoubleStep::setElements(const int& element, const std::vector& elements) +void DoubleStep::setElement(const int& element, const std::vector& elements) throw (XAO_Exception) { checkElementIndex(element); @@ -122,7 +122,7 @@ throw (XAO_Exception) m_values[element][i] = elements[i]; } -void DoubleStep::setComponents(const int& component, const std::vector& components) +void DoubleStep::setComponent(const int& component, const std::vector& components) throw (XAO_Exception) { checkElementIndex(component); diff --git a/src/XAO/XAO_DoubleStep.hxx b/src/XAO/XAO_DoubleStep.hxx index 72a92c5a5..5f4f3e34a 100644 --- a/src/XAO/XAO_DoubleStep.hxx +++ b/src/XAO/XAO_DoubleStep.hxx @@ -85,14 +85,14 @@ namespace XAO * @param element the index of the element to set. * @param elements the values to set. */ - void setElements(const int& element, const std::vector& elements) throw (XAO_Exception); + void setElement(const int& element, const std::vector& elements) throw (XAO_Exception); /** * Sets the values for a component. * @param component the index of the component to set. * @param components the values to set. */ - void setComponents(const int& component, const std::vector& components) throw (XAO_Exception); + void setComponent(const int& component, const std::vector& components) throw (XAO_Exception); /** * Sets the value for an element and a component. diff --git a/src/XAO/XAO_IntegerStep.cxx b/src/XAO/XAO_IntegerStep.cxx index ecd4fa077..89d2b7983 100644 --- a/src/XAO/XAO_IntegerStep.cxx +++ b/src/XAO/XAO_IntegerStep.cxx @@ -112,7 +112,7 @@ throw (XAO_Exception) } } -void IntegerStep::setElements(const int& element, const std::vector& elements) +void IntegerStep::setElement(const int& element, const std::vector& elements) throw (XAO_Exception) { checkElementIndex(element); @@ -122,7 +122,7 @@ throw (XAO_Exception) m_values[element][i] = elements[i]; } -void IntegerStep::setComponents(const int& component, const std::vector& components) +void IntegerStep::setComponent(const int& component, const std::vector& components) throw (XAO_Exception) { checkElementIndex(component); diff --git a/src/XAO/XAO_IntegerStep.hxx b/src/XAO/XAO_IntegerStep.hxx index 10d50a5bf..09673466a 100644 --- a/src/XAO/XAO_IntegerStep.hxx +++ b/src/XAO/XAO_IntegerStep.hxx @@ -85,14 +85,14 @@ namespace XAO * @param element the index of the element to set. * @param elements the values to set. */ - void setElements(const int& element, const std::vector& elements) throw (XAO_Exception); + void setElement(const int& element, const std::vector& elements) throw (XAO_Exception); /** * Sets the values for a component. * @param component the index of the component to set. * @param components the values to set. */ - void setComponents(const int& component, const std::vector& components) throw (XAO_Exception); + void setComponent(const int& component, const std::vector& components) throw (XAO_Exception); /** * Sets the value for an element and a component. diff --git a/src/XAO/XAO_StringStep.cxx b/src/XAO/XAO_StringStep.cxx index 8ab3cbb1f..b04da1568 100644 --- a/src/XAO/XAO_StringStep.cxx +++ b/src/XAO/XAO_StringStep.cxx @@ -111,7 +111,7 @@ throw (XAO_Exception) } } -void StringStep::setElements(const int& element, const std::vector& elements) +void StringStep::setElement(const int& element, const std::vector& elements) throw (XAO_Exception) { checkElementIndex(element); @@ -121,7 +121,7 @@ throw (XAO_Exception) m_values[element][i] = elements[i]; } -void StringStep::setComponents(const int& component, const std::vector& components) +void StringStep::setComponent(const int& component, const std::vector& components) throw (XAO_Exception) { checkElementIndex(component); diff --git a/src/XAO/XAO_StringStep.hxx b/src/XAO/XAO_StringStep.hxx index a623bb580..b0eb2f615 100644 --- a/src/XAO/XAO_StringStep.hxx +++ b/src/XAO/XAO_StringStep.hxx @@ -86,14 +86,14 @@ namespace XAO * @param element the index of the element to set. * @param elements the values to set. */ - void setElements(const int& element, const std::vector& elements) throw (XAO_Exception); + void setElement(const int& element, const std::vector& elements) throw (XAO_Exception); /** * Sets the values for a component. * @param component the index of the component to set. * @param components the values to set. */ - void setComponents(const int& component, const std::vector& components) throw (XAO_Exception); + void setComponent(const int& component, const std::vector& components) throw (XAO_Exception); /** * Sets the value for an element and a component. diff --git a/src/XAO/tests/FieldTest.cxx b/src/XAO/tests/FieldTest.cxx index f5e9be000..d4e3dd313 100644 --- a/src/XAO/tests/FieldTest.cxx +++ b/src/XAO/tests/FieldTest.cxx @@ -210,21 +210,21 @@ void FieldTest::testBooleanStepValues() std::vector newEltValues; // only one value newEltValues.push_back(true); - CPPUNIT_ASSERT_THROW(step->setElements(2, newEltValues), XAO_Exception); + CPPUNIT_ASSERT_THROW(step->setElement(2, newEltValues), XAO_Exception); // all values for (int i = 1; i < nbComponents; ++i) newEltValues.push_back(true); - step->setElements(2, newEltValues); + step->setElement(2, newEltValues); // set one component std::vector newCompValues; // only one value newCompValues.push_back(true); - CPPUNIT_ASSERT_THROW(step->setComponents(1, newCompValues), XAO_Exception); + CPPUNIT_ASSERT_THROW(step->setComponent(1, newCompValues), XAO_Exception); // all values for (int i = 1; i < nbElements; ++i) newCompValues.push_back(true); - step->setComponents(1, newCompValues); + step->setComponent(1, newCompValues); // set string value step->setStringValue(0, 0, "true"); @@ -284,18 +284,18 @@ void FieldTest::testIntegerStepValues() // set one element std::vector newEltValues; newEltValues.push_back(1); - CPPUNIT_ASSERT_THROW(step->setElements(2, newEltValues), XAO_Exception); + CPPUNIT_ASSERT_THROW(step->setElement(2, newEltValues), XAO_Exception); for (int i = 1; i < nbComponents; ++i) newEltValues.push_back(1); - step->setElements(2, newEltValues); + step->setElement(2, newEltValues); // set one component std::vector newCompValues; newCompValues.push_back(100); - CPPUNIT_ASSERT_THROW(step->setComponents(1, newCompValues), XAO_Exception); + CPPUNIT_ASSERT_THROW(step->setComponent(1, newCompValues), XAO_Exception); for (int i = 1; i < nbElements; ++i) newCompValues.push_back(100); - step->setComponents(1, newCompValues); + step->setComponent(1, newCompValues); // set string value step->setStringValue(0, 0, "0"); @@ -355,18 +355,18 @@ void FieldTest::testDoubleStepValues() // set one element std::vector newEltValues; newEltValues.push_back(1.); - CPPUNIT_ASSERT_THROW(step->setElements(2, newEltValues), XAO_Exception); + CPPUNIT_ASSERT_THROW(step->setElement(2, newEltValues), XAO_Exception); for (int i = 1; i < nbComponents; ++i) newEltValues.push_back(1.); - step->setElements(2, newEltValues); + step->setElement(2, newEltValues); // set one component std::vector newCompValues; newCompValues.push_back(100.0); - CPPUNIT_ASSERT_THROW(step->setComponents(1, newCompValues), XAO_Exception); + CPPUNIT_ASSERT_THROW(step->setComponent(1, newCompValues), XAO_Exception); for (int i = 1; i < nbElements; ++i) newCompValues.push_back(100.0); - step->setComponents(1, newCompValues); + step->setComponent(1, newCompValues); // set string value step->setStringValue(0, 0, "0.2"); @@ -424,21 +424,20 @@ void FieldTest::testStringStepValues() // set one element std::vector newEltValues; newEltValues.push_back("1"); - CPPUNIT_ASSERT_THROW(step->setElements(2, newEltValues), XAO_Exception); + CPPUNIT_ASSERT_THROW(step->setElement(2, newEltValues), XAO_Exception); for (int i = 1; i < nbComponents; ++i) newEltValues.push_back("1"); - step->setElements(2, newEltValues); + step->setElement(2, newEltValues); // set one component std::vector newCompValues; newCompValues.push_back("100"); - CPPUNIT_ASSERT_THROW(step->setComponents(1, newCompValues), XAO_Exception); + CPPUNIT_ASSERT_THROW(step->setComponent(1, newCompValues), XAO_Exception); for (int i = 1; i < nbElements; ++i) newCompValues.push_back("100"); - step->setComponents(1, newCompValues); + step->setComponent(1, newCompValues); // set string value - std::cout << "set string value" << std::endl; step->setStringValue(0, 0, "0"); std::vector allValues; @@ -448,4 +447,34 @@ void FieldTest::testStringStepValues() // all values for (int i = 1; i < nbElements*nbComponents; ++i) allValues.push_back("abc"); - step->setValues(allValues);} + step->setValues(allValues); +} + +void FieldTest::testSetComponents() +{ + // field with 3 components + Field* f = Field::createField(XAO::INTEGER, XAO::FACE, 6, 3); + CPPUNIT_ASSERT_EQUAL(std::string(""), f->getComponentName(0)); + CPPUNIT_ASSERT_EQUAL(std::string(""), f->getComponentName(1)); + CPPUNIT_ASSERT_EQUAL(std::string(""), f->getComponentName(2)); + + std::vector names; + names.push_back("vx"); + f->setComponentsNames(names); + CPPUNIT_ASSERT_EQUAL(std::string("vx"), f->getComponentName(0)); + CPPUNIT_ASSERT_EQUAL(std::string(""), f->getComponentName(1)); + CPPUNIT_ASSERT_EQUAL(std::string(""), f->getComponentName(2)); + + names.push_back("vy"); + f->setComponentsNames(names); + CPPUNIT_ASSERT_EQUAL(std::string("vx"), f->getComponentName(0)); + CPPUNIT_ASSERT_EQUAL(std::string("vy"), f->getComponentName(1)); + CPPUNIT_ASSERT_EQUAL(std::string(""), f->getComponentName(2)); + + names.push_back("vz"); + names.push_back("t"); + f->setComponentsNames(names); + CPPUNIT_ASSERT_EQUAL(std::string("vx"), f->getComponentName(0)); + CPPUNIT_ASSERT_EQUAL(std::string("vy"), f->getComponentName(1)); + CPPUNIT_ASSERT_EQUAL(std::string("vz"), f->getComponentName(2)); +} -- 2.39.2