Back to index

salome-kernel  6.5.0
SALOMEDSImplTest.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 #include "SALOMEDSImplTest.hxx"
00024 
00025 #include <iostream>
00026 #include <fstream>
00027 #include <string>
00028 #include <vector>
00029 #include <cstdlib>
00030 #include "utilities.h"
00031 
00032 #include "SALOMEDSImpl_AttributeParameter.hxx"
00033 #include "SALOMEDSImpl_StudyManager.hxx"
00034 #include "SALOMEDSImpl_Study.hxx"
00035 #include "SALOMEDSImpl_StudyBuilder.hxx"
00036 #include "SALOMEDSImpl_GenericAttribute.hxx"
00037 
00038 
00039 // ============================================================================
00043 // ============================================================================
00044 
00045 void SALOMEDSImplTest::setUp()
00046 {
00047 }
00048 
00049 // ============================================================================
00053 // ============================================================================
00054 
00055 void 
00056 SALOMEDSImplTest::tearDown()
00057 {
00058 }
00059 
00060 // ============================================================================
00064 // ============================================================================
00065 void SALOMEDSImplTest::testAttributeParameter()
00066 {
00067   SALOMEDSImpl_StudyManager* sm = new SALOMEDSImpl_StudyManager();
00068   SALOMEDSImpl_Study* study = sm->NewStudy("Test");
00069   SALOMEDSImpl_AttributeParameter* _ap = study->GetCommonParameters("TestComp", 0);
00070 
00071   CPPUNIT_ASSERT(_ap);
00072 
00073   _ap->SetInt("IntValue", 1);
00074   CPPUNIT_ASSERT(_ap->IsSet("IntValue", PT_INTEGER));
00075   CPPUNIT_ASSERT(_ap->GetInt("IntValue") == 1);
00076 
00077   _ap->SetReal("RealValue", 1.2);
00078   CPPUNIT_ASSERT(_ap->IsSet("RealValue", PT_REAL));
00079   CPPUNIT_ASSERT(_ap->GetReal("RealValue") == 1.2);
00080 
00081   _ap->SetString("StringValue", "hello");
00082   CPPUNIT_ASSERT(_ap->IsSet("StringValue", PT_STRING));
00083   CPPUNIT_ASSERT(_ap->GetString("StringValue") == "hello");
00084 
00085   _ap->SetBool("BoolValue", 0);
00086   CPPUNIT_ASSERT(_ap->IsSet("BoolValue", PT_BOOLEAN));
00087   CPPUNIT_ASSERT(!_ap->GetBool("BoolValue"));
00088 
00089   _ap->SetBool("BoolValue", 0);
00090   CPPUNIT_ASSERT(_ap->IsSet("BoolValue", PT_BOOLEAN));
00091   CPPUNIT_ASSERT(!_ap->GetBool("BoolValue"));
00092 
00093   std::vector<int> intArray;
00094   intArray.push_back(0);
00095   intArray.push_back(1);
00096 
00097   _ap->SetIntArray("IntArray", intArray);
00098   CPPUNIT_ASSERT(_ap->IsSet("IntArray", PT_INTARRAY));
00099   CPPUNIT_ASSERT(_ap->GetIntArray("IntArray")[0] == 0);
00100   CPPUNIT_ASSERT(_ap->GetIntArray("IntArray")[1] == 1); 
00101 
00102   std::vector<double> realArray;
00103   realArray.push_back(0.0);
00104   realArray.push_back(1.1);
00105   
00106   _ap->SetRealArray("RealArray", realArray);
00107   CPPUNIT_ASSERT(_ap->IsSet("RealArray", PT_REALARRAY));
00108   CPPUNIT_ASSERT(_ap->GetRealArray("RealArray")[0] == 0.0);
00109   CPPUNIT_ASSERT(_ap->GetRealArray("RealArray")[1] == 1.1); 
00110 
00111   std::vector<std::string> strArray;
00112   strArray.push_back("hello");
00113   strArray.push_back("world");
00114   
00115   _ap->SetStrArray("StrArray", strArray);
00116   CPPUNIT_ASSERT(_ap->IsSet("StrArray", PT_STRARRAY));
00117   CPPUNIT_ASSERT(_ap->GetStrArray("StrArray")[0] == "hello");
00118   CPPUNIT_ASSERT(_ap->GetStrArray("StrArray")[1] == "world"); 
00119 
00120 }
00121 
00122 
00123