1 // Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include "SALOMEDSImplTest.hxx"
30 #include "utilities.h"
32 #include "SALOMEDSImpl_AttributeParameter.hxx"
33 #include "SALOMEDSImpl_Study.hxx"
34 #include "SALOMEDSImpl_StudyBuilder.hxx"
35 #include "SALOMEDSImpl_GenericAttribute.hxx"
38 // ============================================================================
40 * Set up the environment
42 // ============================================================================
44 void SALOMEDSImplTest::setUp()
48 // ============================================================================
50 * - delete trace classes
52 // ============================================================================
55 SALOMEDSImplTest::tearDown()
59 // ============================================================================
61 * Check setting int value
63 // ============================================================================
64 void SALOMEDSImplTest::testAttributeParameter()
66 SALOMEDSImpl_Study* study = new SALOMEDSImpl_Study();
67 SALOMEDSImpl_AttributeParameter* _ap = study->GetCommonParameters("TestComp", 0);
71 _ap->SetInt("IntValue", 1);
72 CPPUNIT_ASSERT(_ap->IsSet("IntValue", PT_INTEGER));
73 CPPUNIT_ASSERT(_ap->GetInt("IntValue") == 1);
75 _ap->SetReal("RealValue", 1.2);
76 CPPUNIT_ASSERT(_ap->IsSet("RealValue", PT_REAL));
77 CPPUNIT_ASSERT(_ap->GetReal("RealValue") == 1.2);
79 _ap->SetString("StringValue", "hello");
80 CPPUNIT_ASSERT(_ap->IsSet("StringValue", PT_STRING));
81 CPPUNIT_ASSERT(_ap->GetString("StringValue") == "hello");
83 _ap->SetBool("BoolValue", 0);
84 CPPUNIT_ASSERT(_ap->IsSet("BoolValue", PT_BOOLEAN));
85 CPPUNIT_ASSERT(!_ap->GetBool("BoolValue"));
87 _ap->SetBool("BoolValue", 0);
88 CPPUNIT_ASSERT(_ap->IsSet("BoolValue", PT_BOOLEAN));
89 CPPUNIT_ASSERT(!_ap->GetBool("BoolValue"));
91 std::vector<int> intArray;
92 intArray.push_back(0);
93 intArray.push_back(1);
95 _ap->SetIntArray("IntArray", intArray);
96 CPPUNIT_ASSERT(_ap->IsSet("IntArray", PT_INTARRAY));
97 CPPUNIT_ASSERT(_ap->GetIntArray("IntArray")[0] == 0);
98 CPPUNIT_ASSERT(_ap->GetIntArray("IntArray")[1] == 1);
100 std::vector<double> realArray;
101 realArray.push_back(0.0);
102 realArray.push_back(1.1);
104 _ap->SetRealArray("RealArray", realArray);
105 CPPUNIT_ASSERT(_ap->IsSet("RealArray", PT_REALARRAY));
106 CPPUNIT_ASSERT(_ap->GetRealArray("RealArray")[0] == 0.0);
107 CPPUNIT_ASSERT(_ap->GetRealArray("RealArray")[1] == 1.1);
109 std::vector<std::string> strArray;
110 strArray.push_back("hello");
111 strArray.push_back("world");
113 _ap->SetStrArray("StrArray", strArray);
114 CPPUNIT_ASSERT(_ap->IsSet("StrArray", PT_STRARRAY));
115 CPPUNIT_ASSERT(_ap->GetStrArray("StrArray")[0] == "hello");
116 CPPUNIT_ASSERT(_ap->GetStrArray("StrArray")[1] == "world");