1 // Copyright (C) 2006 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 #include "SALOMEDSImplTest.hxx"
28 #include "utilities.h"
30 #include "SALOMEDSImpl_AttributeParameter.hxx"
31 #include "SALOMEDSImpl_StudyManager.hxx"
32 #include "SALOMEDSImpl_Study.hxx"
33 #include "SALOMEDSImpl_StudyBuilder.hxx"
34 #include "SALOMEDSImpl_GenericAttribute.hxx"
36 #include <TCollection_AsciiString.hxx>
40 // ============================================================================
42 * Set up the environment
44 // ============================================================================
46 void SALOMEDSImplTest::setUp()
48 TCollection_AsciiString kernel(getenv("KERNEL_ROOT_DIR"));
49 TCollection_AsciiString subPath("/share/salome/resources");
50 TCollection_AsciiString csf_var = (kernel+subPath);
51 setenv("CSF_PluginDefaults", csf_var.ToCString(), 0);
52 setenv("CSF_SALOMEDS_ResourcesDefaults", csf_var.ToCString(), 0);
55 // ============================================================================
57 * - delete trace classes
59 // ============================================================================
62 SALOMEDSImplTest::tearDown()
66 // ============================================================================
68 * Check setting int value
70 // ============================================================================
71 void SALOMEDSImplTest::testAttributeParameter()
73 Handle(SALOMEDSImpl_StudyManager) sm = new SALOMEDSImpl_StudyManager();
74 Handle(SALOMEDSImpl_Study) study = sm->NewStudy("Test");
75 Handle(SALOMEDSImpl_AttributeParameter) _ap = study->GetCommonParameters("TestComp", 0);
77 CPPUNIT_ASSERT(!_ap.IsNull());
79 _ap->SetInt("IntValue", 1);
80 CPPUNIT_ASSERT(_ap->IsSet("IntValue", PT_INTEGER));
81 CPPUNIT_ASSERT(_ap->GetInt("IntValue") == 1);
83 _ap->SetReal("RealValue", 1.2);
84 CPPUNIT_ASSERT(_ap->IsSet("RealValue", PT_REAL));
85 CPPUNIT_ASSERT(_ap->GetReal("RealValue") == 1.2);
87 _ap->SetString("StringValue", "hello");
88 CPPUNIT_ASSERT(_ap->IsSet("StringValue", PT_STRING));
89 CPPUNIT_ASSERT(_ap->GetString("StringValue") == "hello");
91 _ap->SetBool("BoolValue", 0);
92 CPPUNIT_ASSERT(_ap->IsSet("BoolValue", PT_BOOLEAN));
93 CPPUNIT_ASSERT(!_ap->GetBool("BoolValue"));
95 _ap->SetBool("BoolValue", 0);
96 CPPUNIT_ASSERT(_ap->IsSet("BoolValue", PT_BOOLEAN));
97 CPPUNIT_ASSERT(!_ap->GetBool("BoolValue"));
100 intArray.push_back(0);
101 intArray.push_back(1);
103 _ap->SetIntArray("IntArray", intArray);
104 CPPUNIT_ASSERT(_ap->IsSet("IntArray", PT_INTARRAY));
105 CPPUNIT_ASSERT(_ap->GetIntArray("IntArray")[0] == 0);
106 CPPUNIT_ASSERT(_ap->GetIntArray("IntArray")[1] == 1);
108 vector<double> realArray;
109 realArray.push_back(0.0);
110 realArray.push_back(1.1);
112 _ap->SetRealArray("RealArray", realArray);
113 CPPUNIT_ASSERT(_ap->IsSet("RealArray", PT_REALARRAY));
114 CPPUNIT_ASSERT(_ap->GetRealArray("RealArray")[0] == 0.0);
115 CPPUNIT_ASSERT(_ap->GetRealArray("RealArray")[1] == 1.1);
117 vector<string> strArray;
118 strArray.push_back("hello");
119 strArray.push_back("world");
121 _ap->SetStrArray("StrArray", strArray);
122 CPPUNIT_ASSERT(_ap->IsSet("StrArray", PT_STRARRAY));
123 CPPUNIT_ASSERT(_ap->GetStrArray("StrArray")[0] == "hello");
124 CPPUNIT_ASSERT(_ap->GetStrArray("StrArray")[1] == "world");