Salome HOME
Revert "Synchronize adm files"
[modules/kernel.git] / src / SALOMEDSImpl / Test / SALOMEDSImplTest.cxx
1 // Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #include "SALOMEDSImplTest.hxx"
24
25 #include <iostream>
26 #include <fstream>
27 #include <string>
28 #include <vector>
29 #include <cstdlib>
30 #include "utilities.h"
31
32 #include "SALOMEDSImpl_AttributeParameter.hxx"
33 #include "SALOMEDSImpl_StudyManager.hxx"
34 #include "SALOMEDSImpl_Study.hxx"
35 #include "SALOMEDSImpl_StudyBuilder.hxx"
36 #include "SALOMEDSImpl_GenericAttribute.hxx"
37
38
39 // ============================================================================
40 /*!
41  * Set up the environment
42  */
43 // ============================================================================
44
45 void SALOMEDSImplTest::setUp()
46 {
47 }
48
49 // ============================================================================
50 /*!
51  *  - delete trace classes
52  */
53 // ============================================================================
54
55 void 
56 SALOMEDSImplTest::tearDown()
57 {
58 }
59
60 // ============================================================================
61 /*!
62  * Check setting int value
63  */
64 // ============================================================================
65 void SALOMEDSImplTest::testAttributeParameter()
66 {
67   SALOMEDSImpl_StudyManager* sm = new SALOMEDSImpl_StudyManager();
68   SALOMEDSImpl_Study* study = sm->NewStudy("Test");
69   SALOMEDSImpl_AttributeParameter* _ap = study->GetCommonParameters("TestComp", 0);
70
71   CPPUNIT_ASSERT(_ap);
72
73   _ap->SetInt("IntValue", 1);
74   CPPUNIT_ASSERT(_ap->IsSet("IntValue", PT_INTEGER));
75   CPPUNIT_ASSERT(_ap->GetInt("IntValue") == 1);
76
77   _ap->SetReal("RealValue", 1.2);
78   CPPUNIT_ASSERT(_ap->IsSet("RealValue", PT_REAL));
79   CPPUNIT_ASSERT(_ap->GetReal("RealValue") == 1.2);
80
81   _ap->SetString("StringValue", "hello");
82   CPPUNIT_ASSERT(_ap->IsSet("StringValue", PT_STRING));
83   CPPUNIT_ASSERT(_ap->GetString("StringValue") == "hello");
84
85   _ap->SetBool("BoolValue", 0);
86   CPPUNIT_ASSERT(_ap->IsSet("BoolValue", PT_BOOLEAN));
87   CPPUNIT_ASSERT(!_ap->GetBool("BoolValue"));
88
89   _ap->SetBool("BoolValue", 0);
90   CPPUNIT_ASSERT(_ap->IsSet("BoolValue", PT_BOOLEAN));
91   CPPUNIT_ASSERT(!_ap->GetBool("BoolValue"));
92
93   std::vector<int> intArray;
94   intArray.push_back(0);
95   intArray.push_back(1);
96
97   _ap->SetIntArray("IntArray", intArray);
98   CPPUNIT_ASSERT(_ap->IsSet("IntArray", PT_INTARRAY));
99   CPPUNIT_ASSERT(_ap->GetIntArray("IntArray")[0] == 0);
100   CPPUNIT_ASSERT(_ap->GetIntArray("IntArray")[1] == 1); 
101
102   std::vector<double> realArray;
103   realArray.push_back(0.0);
104   realArray.push_back(1.1);
105   
106   _ap->SetRealArray("RealArray", realArray);
107   CPPUNIT_ASSERT(_ap->IsSet("RealArray", PT_REALARRAY));
108   CPPUNIT_ASSERT(_ap->GetRealArray("RealArray")[0] == 0.0);
109   CPPUNIT_ASSERT(_ap->GetRealArray("RealArray")[1] == 1.1); 
110
111   std::vector<std::string> strArray;
112   strArray.push_back("hello");
113   strArray.push_back("world");
114   
115   _ap->SetStrArray("StrArray", strArray);
116   CPPUNIT_ASSERT(_ap->IsSet("StrArray", PT_STRARRAY));
117   CPPUNIT_ASSERT(_ap->GetStrArray("StrArray")[0] == "hello");
118   CPPUNIT_ASSERT(_ap->GetStrArray("StrArray")[1] == "world"); 
119
120 }
121
122
123