void TestFaultyInstanceProvider::initialize(CIMOMHandle& cimom) { // save cimom handle //_cimom = cimom; char namebuf[20]; char pathbuf[45]; memset(namebuf, 0x00, sizeof(namebuf)); memset(pathbuf, 0x00, sizeof(pathbuf)); // create default instances for (Uint32 i = 1; i <= 2; i++) { sprintf(namebuf, "%u", i); sprintf(pathbuf, "TST_FaultyInstanceInstance.Name=\"%u\"", i); { CIMInstance instance("TST_FaultyInstanceInstance"); instance.addProperty(CIMProperty("name", String(namebuf))); instance.addProperty(CIMProperty("s", String("specified"))); instance.addProperty(CIMProperty("n", Uint64(i))); instance.addProperty(CIMProperty("f", Real64(Real64(i)+0.001))); instance.addProperty( CIMProperty("d", CIMDateTime::getCurrentDateTime())); instance.setPath(CIMObjectPath(pathbuf)); _instances.append(instance); } } }
void DeepScanner::processFile(FIFile* pFile) { Error error; class SkipFile {}; try { Path path = pFile->getAbsolutePath(error, m_db.m_root); if (error) throw SkipFile(); m_fProgress = Real64(m_iCurItem) / Real64(m_db.m_pFIFiles.size()); progressReport(path); FileInputStream fis(error, path); if (error) throw SkipFile(); FIIndex* pIndex = vivFileIndex(error, fis); if (error) throw SkipFile(); pFile->setFIIndex(pIndex); pIndex->addFIFile(pFile); } catch (SkipFile&) { UTF16 sErrorMessage = (error ? UTF16(error) : L"Unknown Error"); skipWarning(pFile->getPath(), error); } }
Real64 ProgressReport::getProgress() const { if (m_eState == eInitial || m_eState == eStarted || m_fProgress < Real64(0)) return 0; else if (m_eState == eCompleted || m_fProgress > Real64(1)) return 1; else return m_fProgress; }
void ProgressReport::setProgress(Real64 fProgress) { if (fProgress <= Real64(0)) start(); else if (fProgress >= Real64(1)) complete(); else update(fProgress); }
Real64 FIDir::getMarkedState() { if (m_iNumMarkedFiles == m_iNumFiles) return 1; else if (m_iNumMarkedFiles == 0) return 0; else return (Real64(m_iNumMarkedFiles) / Real64(m_iNumFiles)); }
void drive_get_misc_functions() { try { // Get function tests CQLValue a1(Uint64(123)); CQLValue a2(Sint64(-123)); CQLValue a3(Real64(25.24)); CQLValue a4(String("Hellow")); CQLValue a5(Boolean(true)); String _date("20040811105625.000000-360"); CIMDateTime date(_date); CQLValue a6(date); String _date1("20040811105626.000000-360"); CIMDateTime date1(_date1); CQLValue a61(date1); String opStr("MyClass.z=true,y=1234,x=\"Hello World\""); CIMObjectPath op(opStr); CQLValue a7(op); const CIMName _cimName(String("CIM_OperatingSystem")); CIMInstance _i1(_cimName); CQLValue a8(_i1); PEGASUS_TEST_ASSERT(a1.getUint() == Uint64(123)); PEGASUS_TEST_ASSERT(a2.getSint() == Sint64(-123)); PEGASUS_TEST_ASSERT(a3.getReal() == Real64(25.24)); PEGASUS_TEST_ASSERT(a4.getString() == String("Hellow")); PEGASUS_TEST_ASSERT(a5.getBool() == Boolean(true)); PEGASUS_TEST_ASSERT(a6.getDateTime() == CIMDateTime(_date)); PEGASUS_TEST_ASSERT(a6 != a61); PEGASUS_TEST_ASSERT(a6 < a61); PEGASUS_TEST_ASSERT(a7.getReference() == CIMObjectPath(opStr)); try { a1.getSint(); PEGASUS_TEST_ASSERT(0); } catch(...) { PEGASUS_TEST_ASSERT(1); } } catch(Exception & e) { cout << e.getMessage() << endl; PEGASUS_TEST_ASSERT(0); } return; }
void runTests(bool write,BinaryDataHandler &pMem) { runTest (write,pMem, std::string("Hallo") ); runTest1 (write,pMem, Time(222.22) ); runTest (write,pMem, Color3f(1.1,2.2,3.3) ); runTest (write,pMem, Color4f(1.1,2.2,3.3,4.4) ); runTest (write,pMem, Color3ub(1,2,3) ); runTest (write,pMem, Color4ub(1,2,3,4) ); runTest (write,pMem, DynamicVolume(DynamicVolume::BOX_VOLUME) ); runTest (write,pMem, DynamicVolume(DynamicVolume::SPHERE_VOLUME) ); runTest1 (write,pMem, BitVector(0xabcd) ); runTest (write,pMem, Plane(Vec3f(1.0,0),0.222) ); runTest (write,pMem, Matrix(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16) ); runTest (write,pMem, Quaternion(Vec3f(1,2,3),22) ); runTest2<bool>(write,pMem, true ); runTest (write,pMem, Int8(-22) ); runTest (write,pMem, UInt8(11) ); runTest (write,pMem, Int16(-10233) ); runTest (write,pMem, UInt16(20233) ); runTest (write,pMem, Int32(-222320233) ); runTest (write,pMem, UInt32(522320233) ); runTest<Int64> (write,pMem, Int64(-522323334) ); runTest (write,pMem, UInt64(44523423) ); runTest (write,pMem, Real32(22.333224) ); runTest (write,pMem, Real64(52.334534533224) ); runTest (write,pMem, Vec2f(1.1,2.2) ); runTest (write,pMem, Vec3f(1.1,2.2,3.3) ); runTest (write,pMem, Vec4f(1.1,2.2,3.3,4.4) ); runTest (write,pMem, Pnt2f(1.1,2.2) ); runTest (write,pMem, Pnt2d(1.1,2.2) ); runTest (write,pMem, Pnt3f(1.1,2.2,3.3) ); runTest (write,pMem, Pnt3d(1.1,2.2,3.3) ); runTest (write,pMem, Pnt4f(1.1,2.2,3.3,4.4) ); runTest (write,pMem, Pnt4d(1.1,2.2,3.3,4.4) ); }
FishEyeProjectorBase::FishEyeProjectorBase(void) : Inherited(), _sfMode (UInt32(0x0001)), _mfGeometries (), _sfShowDomeIntensity (bool(true)), _sfResolution (UInt32(512)), _sfMeshRefinementLevel (UInt32(5)), _sfBufferFormat (GLenum(GL_RGB)), _sfDomeRadius (Real64(2.5)), _sfMirrorRadius (Real64(0.3)), _sfMirrorPos (Vec3d(2.4, 0.0, 0.0)), _sfProjectorPos (Vec3d(1.85, 0.0, 0.0)), _sfAspectRatio (Real64(4.0/3.0)), _sfThrowDist (Real64(1.5)), _sfShowMesh (bool(true)) { }
Real64 JSON::as_real() const { switch (m_type) { case e_null: return 0; case e_bool: return (m_bool ? 1 : 0); case e_integer: return Real64(m_integer); case e_real: return m_real; case e_string: return stringToNumber(m_string).as_real(); case e_array: return arrayToNumber(m_array).as_real(); case e_object: return objectToNumber(m_object).as_real(); } return 0; }
bool JSON::as_bool() const { switch (m_type) { case e_null: return false; case e_bool: return m_bool; case e_integer: return as_integer() != 0; case e_real: return as_real() != Real64(0); case e_string: return stringToNumber(m_string).as_bool(); case e_array: return arrayToNumber(m_array).as_bool(); case e_object: return objectToNumber(m_object).as_bool(); } return 0; }
void TimeSensor::frame(Time tTime, UInt32 uiFrame) { Real64 dFraction; bool bDoTimeRange = bool(_sfStartTime.getValue() < _sfStopTime .getValue()); bool bDoCycle = false; if(bDoTimeRange) { dFraction = Real64( tTime - _sfStartTime.getValue()) / Real64(_sfStopTime.getValue() - _sfStartTime.getValue()); } else { if(_sfCycleTime.getValue() > 0.0) { dFraction = Real64(tTime - _sfCycleTime.getValue()) / Real64(_sfCycleInterval.getValue()); bDoCycle = true; } else { dFraction = Real64(tTime - _sfStartTime.getValue()) / Real64(_sfCycleInterval.getValue()); } } if(_sfEnabled.getValue() == false) { if(_sfIsActive.getValue() == true) { setTime (tTime); setIsActive(false); setFraction(Real32(dFraction)); } } else { if(dFraction < 0.0) // before start { if(bDoCycle == true) { if(_sfIsActive.getValue() == true) { if(_sfLoop.getValue() == false) { setIsActive (false); setTime (tTime); setFraction (1.0 ); setCycleTime(tTime); } else { setCycleTime(_sfCycleTime .getValue() - _sfCycleInterval.getValue()); setTime (tTime); setFraction (dFraction + 1.0); } } else { } } } else if(dFraction > 1.0) // after end time { if(_sfIsActive.getValue() == true) { if(_sfLoop.getValue() == false) { setIsActive (false); setTime (0.f ); setFraction (1.0 ); setCycleTime(0.f ); setEnabled (false); } else { setCycleTime(_sfCycleTime .getValue() + _sfCycleInterval.getValue()); setTime (tTime); setFraction (dFraction - 1.0); } } else { if(bDoTimeRange == false) { setFraction (0.f); setCycleTime(tTime - (_sfFraction .getValue() * _sfCycleInterval.getValue() )); setIsActive (true); setTime (tTime); } } } else // within cycle { if (_sfIsActive.getValue() == false) { if(bDoTimeRange == true) { setCycleTime(_sfStartTime.getValue()); setIsActive (true); setTime (tTime); setFraction (dFraction); } else { setCycleTime(tTime - (_sfFraction .getValue() * _sfCycleInterval.getValue() )); if(_sfCycleTime.getValue() > TypeTraits<Time>::getDefaultEps()) { setIsActive(true); } setTime(tTime); } } else { if(tTime >= _sfStopTime.getValue() && bDoTimeRange == true ) { setIsActive(false); } else { if(tTime >= _sfStartTime.getValue()) { setTime (tTime ); setFraction(dFraction); } } } } } }
static UTF16 getNotesOnLogicalDrive(Error& error, const UTF16& sLogicalDrive) { UTF16Buffer sbVolName(MAX_PATH+1); UTF16Buffer sbFSType(MAX_PATH+1); if (!GetVolumeInformation(sLogicalDrive.ptr(), sbVolName.ptr(), sbVolName.flength(), NULL, NULL, NULL, sbFSType.ptr(), sbFSType.flength())) { error.what(WindowsError::getLastError()); error.who(L"GetVolumeInformation"); return UTF16(); } UTF16 sVolName = sbVolName; UTF16 sFSType = sbFSType; if (!sVolName.empty()) sVolName = sVolName + " "; if (!sFSType.empty()) sFSType = sFSType + " "; UTF16 sDriveType; switch (GetDriveType(sLogicalDrive.ptr())) { case DRIVE_NO_ROOT_DIR: sDriveType = L"No Root Dir "; break; case DRIVE_REMOVABLE: sDriveType = L"Removable "; break; case DRIVE_FIXED: sDriveType = L"Fixed "; break; case DRIVE_CDROM: sDriveType = L"CDROM "; break; case DRIVE_RAMDISK: sDriveType = L"RAM Disk "; break; default: sDriveType = L"Unknown "; } UTF16 sSizeInfo; UInt64 iBytesFree, iTotalBytes; ULARGE_INTEGER ulgFreeBytesAvailable, ulgTotalNumberOfBytes; if (GetDiskFreeSpaceEx(sLogicalDrive.ptr(), &ulgFreeBytesAvailable, &ulgTotalNumberOfBytes, NULL)) { iBytesFree = ulgFreeBytesAvailable.QuadPart; iTotalBytes = ulgTotalNumberOfBytes.QuadPart; int iUnit = 0; for (UInt64 i = iTotalBytes; i > 0; i >>= 10) iUnit++; UTF16 sUnit; switch (iUnit) { case 0: iUnit = 1; sUnit = L"B"; break; case 1: sUnit = L"B"; break; case 2: sUnit = L"KB"; break; case 3: sUnit = L"MB"; break; case 4: sUnit = L"GB"; break; case 5: sUnit = L"TB"; break; case 6: sUnit = L"PB"; break; case 7: sUnit = L"EB"; break; case 8: sUnit = L"ZB"; break; case 9: sUnit = L"YB"; break; default: sUnit = L"??"; break; } Real64 fBytesFree = Real64(iBytesFree) / Real64(1ULL << (10*(iUnit-1))); Real64 fTotalBytes = Real64(iTotalBytes) / Real64(1ULL << (10*(iUnit-1))); Real64 fBytesUsed = fTotalBytes - fBytesFree; sSizeInfo = UTF16::format(L"%d/%d%s ", UInt32(fBytesUsed), UInt32(fTotalBytes), sUnit.ptr()); }
LLSDValue Parser::Parse(ticpp::Node * node, bool returnEmpty) { if(!node) { boost::throw_exception(SyntaxException("LLSD XML ERROR")); } if(node->Type() != TiXmlNode::ELEMENT || node->Type() == TiXmlNode::TEXT) { if(returnEmpty) { return LLSDValue(); } return Parse(node->NextSibling()); } std::string nodeN = node->Value(); if(LookupTable.count(nodeN) > 0) { LLSDValue result; ticpp::Node * tmp = node->FirstChild(false); switch(LookupTable[nodeN]) { case LLSDValue::VT_INTEGER: if(tmp && tmp->Type() == TiXmlNode::TEXT) { result.xml_decode(LLSDValue::VT_INTEGER, tmp->Value()); } else { result = Int32(0); } return result; case LLSDValue::VT_REAL: if(tmp && tmp->Type() == TiXmlNode::TEXT) { result.xml_decode(LLSDValue::VT_REAL, tmp->Value()); } else { result = Real64(0); } return result; case LLSDValue::VT_STRING: if(tmp && tmp->Type() == TiXmlNode::TEXT) { result.xml_decode(LLSDValue::VT_STRING, tmp->Value()); } else { result = ""; } return result; case LLSDValue::VT_DATE: if(tmp && tmp->Type() == TiXmlNode::TEXT) { result.xml_decode(LLSDValue::VT_DATE, tmp->Value()); } else { result = LLDate(); } return result; case LLSDValue::VT_UUID: if(tmp && tmp->Type() == TiXmlNode::TEXT) { result.xml_decode(LLSDValue::VT_UUID, tmp->Value()); } else { result = LLUUID::Zero; } return result; case LLSDValue::VT_BOOLEAN: if(tmp && tmp->Type() == TiXmlNode::TEXT) { result.xml_decode(LLSDValue::VT_BOOLEAN, tmp->Value()); } else { result = false; } return result; case LLSDValue::VT_BINARY: if(tmp && tmp->Type() == TiXmlNode::TEXT) { result = base64_decode<LLSDValue::Binary>(tmp->Value()); } else { result = LLSDValue::Binary(); } return result; case LLSDValue::VT_URI: if(tmp && tmp->Type() == TiXmlNode::TEXT) { result = LLURI(tmp->Value()); } else { result = LLURI(); } return result; case LLSDValue::VT_MAP: return ParseMap(node); case LLSDValue::VT_ARRAY: return ParseArray(node); case LLSDValue::VT_UNDEF: default: return result; } } ticpp::Iterator<ticpp::Node> elems; for(elems = elems.begin(node); elems != elems.end(); ++elems) { return Parse(elems.Get()); } return LLSDValue(); }
static void _testValues(void) { WsmToCimRequestMapper mapper((CIMRepository*) 0); // Test simple data types testSimpleType(Boolean(true)); testSimpleType(Boolean(false)); testSimpleType((Sint8)-4); testSimpleType((Sint16)-44); testSimpleType((Sint32)-444); testSimpleType((Sint64)-4444); testSimpleType((Uint8)4); testSimpleType((Uint16)44); testSimpleType((Uint32)444); testSimpleType((Uint64)4444); testSimpleType(Char16('Z')); testSimpleType(Real32(1.5)); testSimpleType(Real64(55.5)); testSimpleType(Uint64(123456789)); testSimpleType(Sint64(-123456789)); testSimpleType(String("Hello world")); // Test special floating point values: NaN, INF, -INF WsmValue wsmf1("NaN"); CIMValue cimf1((Real32)0.0); mapper.convertWsmToCimValue(wsmf1, CIMNamespaceName(), cimf1); PEGASUS_TEST_ASSERT(cimf1.toString() == PEGASUS_NAN); WsmValue wsmf2("INF"); CIMValue cimf2((Real32)0.0); mapper.convertWsmToCimValue(wsmf2, CIMNamespaceName(), cimf2); PEGASUS_TEST_ASSERT(cimf2.toString() == PEGASUS_INF); WsmValue wsmf3("-INF"); CIMValue cimf3((Real32)0.0); mapper.convertWsmToCimValue(wsmf3, CIMNamespaceName(), cimf3); PEGASUS_TEST_ASSERT(cimf3.toString() == PEGASUS_NEG_INF); WsmValue wsmd1("NaN"); CIMValue cimd1((Real64)0.0); mapper.convertWsmToCimValue(wsmd1, CIMNamespaceName(), cimd1); PEGASUS_TEST_ASSERT(cimd1.toString() == PEGASUS_NAN); WsmValue wsmd2("INF"); CIMValue cimd2((Real64)0.0); mapper.convertWsmToCimValue(wsmd2, CIMNamespaceName(), cimd2); PEGASUS_TEST_ASSERT(cimd2.toString() == PEGASUS_INF); WsmValue wsmd3("-INF"); CIMValue cimd3((Real64)0.0); mapper.convertWsmToCimValue(wsmd3, CIMNamespaceName(), cimd3); PEGASUS_TEST_ASSERT(cimd3.toString() == PEGASUS_NEG_INF); // Test datetime CIMDateTime cimDT; mapper.convertWsmToCimDatetime("P1Y1M1DT10H5M44.0012345678901234S", cimDT); PEGASUS_TEST_ASSERT(cimDT == CIMDateTime("00000396100544.001234:000")); mapper.convertWsmToCimDatetime("P1Y1M1DT10H5M44.12345678901234S", cimDT); PEGASUS_TEST_ASSERT(cimDT == CIMDateTime("00000396100544.123456:000")); mapper.convertWsmToCimDatetime("P1Y1M1DT10H5M44.0055555555S", cimDT); PEGASUS_TEST_ASSERT(cimDT == CIMDateTime("00000396100544.005555:000")); mapper.convertWsmToCimDatetime("P1Y1M1DT10H5M44.00500000S", cimDT); PEGASUS_TEST_ASSERT(cimDT == CIMDateTime("00000396100544.005000:000")); mapper.convertWsmToCimDatetime("P1Y1M1DT10H5M44.9999999S", cimDT); PEGASUS_TEST_ASSERT(cimDT == CIMDateTime("00000396100544.999999:000")); mapper.convertWsmToCimDatetime("P1Y1M1DT10H5M44S", cimDT); PEGASUS_TEST_ASSERT(cimDT == CIMDateTime("00000396100544.000000:000")); mapper.convertWsmToCimDatetime("P1Y1M1DT10H5M44.0055S", cimDT); PEGASUS_TEST_ASSERT(cimDT == CIMDateTime("00000396100544.005500:000")); mapper.convertWsmToCimDatetime("PT10H5M44.0055S", cimDT); PEGASUS_TEST_ASSERT(cimDT == CIMDateTime("00000000100544.005500:000")); mapper.convertWsmToCimDatetime("P10Y", cimDT); PEGASUS_TEST_ASSERT(cimDT == CIMDateTime("00003652000000.000000:000")); mapper.convertWsmToCimDatetime("P10Y18M", cimDT); PEGASUS_TEST_ASSERT(cimDT == CIMDateTime("00004201000000.000000:000")); mapper.convertWsmToCimDatetime("P10Y18M40D", cimDT); PEGASUS_TEST_ASSERT(cimDT == CIMDateTime("00004241000000.000000:000")); mapper.convertWsmToCimDatetime("P10Y18M40DT34H", cimDT); PEGASUS_TEST_ASSERT(cimDT == CIMDateTime("00004242100000.000000:000")); mapper.convertWsmToCimDatetime("P10Y18M40DT34H70M", cimDT); PEGASUS_TEST_ASSERT(cimDT == CIMDateTime("00004242111000.000000:000")); mapper.convertWsmToCimDatetime("P10Y18M40DT34H70M140S", cimDT); PEGASUS_TEST_ASSERT(cimDT == CIMDateTime("00004242111220.000000:000")); mapper.convertWsmToCimDatetime("PT70M140S", cimDT); PEGASUS_TEST_ASSERT(cimDT == CIMDateTime("00000000011220.000000:000")); mapper.convertWsmToCimDatetime("PT140S", cimDT); PEGASUS_TEST_ASSERT(cimDT == CIMDateTime("00000000000220.000000:000")); mapper.convertWsmToCimDatetime("PT5M44.0055S", cimDT); PEGASUS_TEST_ASSERT(cimDT == CIMDateTime("00000000000544.005500:000")); mapper.convertWsmToCimDatetime("2004-12-01", cimDT); PEGASUS_TEST_ASSERT(cimDT == CIMDateTime("20041201******.******+000")); mapper.convertWsmToCimDatetime("2004-12-01Z", cimDT); PEGASUS_TEST_ASSERT(cimDT == CIMDateTime("20041201******.******+000")); mapper.convertWsmToCimDatetime("2004-12-01+02:00", cimDT); PEGASUS_TEST_ASSERT(cimDT == CIMDateTime("20041201******.******+120")); mapper.convertWsmToCimDatetime("2004-12-01-11:30", cimDT); PEGASUS_TEST_ASSERT(cimDT == CIMDateTime("20041201******.******-690")); mapper.convertWsmToCimDatetime("2004-12-01T12:23:34+02:00", cimDT); PEGASUS_TEST_ASSERT(cimDT == CIMDateTime("20041201122334.000000+120")); mapper.convertWsmToCimDatetime("2004-12-01T12:23:34.0012+02:00", cimDT); PEGASUS_TEST_ASSERT(cimDT == CIMDateTime("20041201122334.001200+120")); mapper.convertWsmToCimDatetime("2004-12-01T12:23:34.0012-04:15", cimDT); PEGASUS_TEST_ASSERT(cimDT == CIMDateTime("20041201122334.001200-255")); mapper.convertWsmToCimDatetime("2004-12-01T12:23:34Z", cimDT); PEGASUS_TEST_ASSERT(cimDT == CIMDateTime("20041201122334.000000+000")); mapper.convertWsmToCimDatetime("2004-12-01T12:23:34.0012Z", cimDT); PEGASUS_TEST_ASSERT(cimDT == CIMDateTime("20041201122334.001200+000")); mapper.convertWsmToCimDatetime("2004-12-01T12:23:34.00+02:00", cimDT); PEGASUS_TEST_ASSERT(cimDT == CIMDateTime("20041201122334.000000+120")); mapper.convertWsmToCimDatetime("2004-12-01T12:23:34.0000000+02:00", cimDT); PEGASUS_TEST_ASSERT(cimDT == CIMDateTime("20041201122334.000000+120")); mapper.convertWsmToCimDatetime("2004-12-01T12:23:34.0000009+02:00", cimDT); PEGASUS_TEST_ASSERT(cimDT == CIMDateTime("20041201122334.000000+120")); mapper.convertWsmToCimDatetime("2004-12-01T12:23:34.000001+02:00", cimDT); PEGASUS_TEST_ASSERT(cimDT == CIMDateTime("20041201122334.000001+120")); mapper.convertWsmToCimDatetime("2004-12-01T12:23:34.1+02:00", cimDT); PEGASUS_TEST_ASSERT(cimDT == CIMDateTime("20041201122334.100000+120")); mapper.convertWsmToCimDatetime("20041201122334.001200+360", cimDT); PEGASUS_TEST_ASSERT(cimDT == CIMDateTime("20041201122334.001200+360")); // Test arrays of simple types Array<Sint8> s8_arr; s8_arr.append(-11); s8_arr.append(-22); testArrayType(s8_arr); Array<Sint16> s16_arr; s16_arr.append(-111); s16_arr.append(-222); testArrayType(s16_arr); Array<Sint32> s32_arr; s32_arr.append(-1111); s32_arr.append(-2222); testArrayType(s32_arr); Array<Sint64> s64_arr; s64_arr.append(-11111); s64_arr.append(-22222); testArrayType(s64_arr); Array<Uint8> u8_arr; u8_arr.append(11); u8_arr.append(22); testArrayType(u8_arr); Array<Uint16> u16_arr; u16_arr.append(111); u16_arr.append(222); testArrayType(u16_arr); Array<Uint32> u32_arr; u32_arr.append(1111); u32_arr.append(2222); testArrayType(u32_arr); Array<Uint64> u64_arr; u64_arr.append(11111); u64_arr.append(22222); testArrayType(u64_arr); Array<Boolean> b_arr; b_arr.append(true); b_arr.append(false); testArrayType(b_arr); Array<Real32> r32_arr; r32_arr.append(Real32(1.5)); r32_arr.append(Real32(2.5)); testArrayType(r32_arr); Array<Real64> r64_arr; r64_arr.append(Real64(11.5)); r64_arr.append(Real64(12.5)); testArrayType(r64_arr); Array<Char16> c16_arr; c16_arr.append(Char16('Z')); c16_arr.append(Char16('X')); testArrayType(c16_arr); Array<CIMDateTime> dt_arr; dt_arr.append(CIMDateTime("19991224120000.000000+360")); dt_arr.append(CIMDateTime("20001224120000.000000+360")); testArrayType(dt_arr); Array<String> str_arr; str_arr.append("Test string 1"); str_arr.append("Test string 2"); testArrayType(str_arr); // Test class URI to class name conversion String classURI = String(WSM_RESOURCEURI_CIMSCHEMAV2) + "/MyClass"; CIMName cimName = mapper.convertResourceUriToClassName(classURI); PEGASUS_TEST_ASSERT(cimName.getString() == "MyClass"); }
void Format::put(long double t, const FormatFlags& flags) { // FIXME! Floating point precision... oss.append(align(String(Real64(t)), flags)); }
int main(int argc, char** argv) { #ifdef IO verbose = getenv("PEGASUS_TEST_VERBOSE") ? true : false; if (verbose) cout << "Test CIMValue. To turn off display, compile with IO undefined\n"; #endif // Test the primitive CIMValue types with test01 test01(Boolean(true)); test01(Boolean(false)); test01(Char16('Z')); test01(Uint8(77)); test01(Sint8(-77)); test01(Sint16(77)); test01(Uint16(-77)); test01(Sint32(77)); test01(Uint32(-77)); test01(Sint64(77)); test01(Uint64(-77)); test01(Real32(1.5)); test01(Real64(55.5)); test01(Uint64(123456789)); test01(Sint64(-123456789)); test01(String("Hello world")); test01(CIMDateTime("19991224120000.000000+360")); test01(CIMObjectPath( "//host1:77/root/test:Class1.key1=\"key1Value\",key2=\"key2Value\"")); // Create and populate a declaration context: const CIMNamespaceName NAMESPACE = CIMNamespaceName ("/zzz"); SimpleDeclContext* context = new SimpleDeclContext; context->addQualifierDecl( NAMESPACE, CIMQualifierDecl(CIMName ("counter"), false, CIMScope::PROPERTY)); context->addQualifierDecl( NAMESPACE, CIMQualifierDecl(CIMName ("classcounter"), false, CIMScope::CLASS)); context->addQualifierDecl( NAMESPACE, CIMQualifierDecl(CIMName ("min"), String(), CIMScope::PROPERTY)); context->addQualifierDecl( NAMESPACE, CIMQualifierDecl(CIMName ("max"), String(), CIMScope::PROPERTY)); context->addQualifierDecl(NAMESPACE, CIMQualifierDecl(CIMName ("Description"), String(), CIMScope::PROPERTY)); CIMClass class1(CIMName ("MyClass")); class1 .addProperty(CIMProperty(CIMName ("count"), Uint32(55)) .addQualifier(CIMQualifier(CIMName ("counter"), true)) .addQualifier(CIMQualifier(CIMName ("min"), String("0"))) .addQualifier(CIMQualifier(CIMName ("max"), String("1")))) .addProperty(CIMProperty(CIMName ("message"), String("Hello")) .addQualifier(CIMQualifier(CIMName ("description"), String("My Message")))) .addProperty(CIMProperty(CIMName ("ratio"), Real32(1.5))); Resolver::resolveClass (class1, context, NAMESPACE); context->addClass(NAMESPACE, class1); // Test a CIMObject that is a CIMClass test01(CIMObject(class1)); // Test a CIMObject that is a CIMInstance CIMInstance instance1(CIMName ("MyClass")); instance1.addQualifier(CIMQualifier(CIMName ("classcounter"), true)); instance1.addProperty(CIMProperty(CIMName ("message"), String("Goodbye"))); Resolver::resolveInstance (instance1, context, NAMESPACE, true); test01(CIMObject(instance1)); testEmbeddedValue<CIMObject>(instance1); testEmbeddedValue<CIMInstance>(instance1); // Test CIMValue arrays Array<Uint8> arr1; arr1.append(11); arr1.append(22); arr1.append(23); test02(arr1); Array<Uint16> arr2; arr2.append(333); arr2.append(444); arr2.append(445); test02(arr2); Array<Uint32> arr3; arr3.append(5555); arr3.append(6666); arr3.append(6667); test02(arr3); Array<Uint64> arr4; arr4.append(123456789); arr4.append(987654321); arr4.append(987654322); test02(arr4); Array<Sint8> arr5; arr5.append(-11); arr5.append(-22); arr5.append(-23); test02(arr5); Array<Sint16> arr6; arr6.append(333); arr6.append(444); arr6.append(555); test02(arr6); Array<Sint32> arr7; arr7.append(555); arr7.append(666); arr7.append(777); test02(arr7); Array<Sint64> arr8; arr8.append(-123456789); arr8.append(-987654321); arr8.append(-987654321); test02(arr8); Array<Boolean> arr9; arr9.append(true); arr9.append(false); arr9.append(false); test02(arr9); Array<Real32> arr10; arr10.append(1.55F); arr10.append(2.66F); arr10.append(3.77F); test02(arr10); Array<Real64> arr11; arr11.append(55.55); arr11.append(66.66); arr11.append(77.77); test02(arr11); Array<Char16> arr12; arr12.append('X'); arr12.append('Y'); arr12.append('Z'); test02(arr12); Array<String> arr13; arr13.append("One"); arr13.append("Two"); arr13.append("Three"); test02(arr13); Array<CIMDateTime> arr14; arr14.append(CIMDateTime ("20020130120000.000000+360")); arr14.append(CIMDateTime ("20020201120000.000000+360")); arr14.append(CIMDateTime ("20020202120000.000000+360")); test02(arr14); Array<CIMObjectPath> arr15; arr15.append(CIMObjectPath( "//host1:77/root/test:Class1.key1=\"key1Value\",key2=\"key2Value\"")); arr15.append(CIMObjectPath( "//host2:88/root/static:Class2.keyA=\"keyAValue\",keyB=" "\"keyBValue\"")); arr15.append(CIMObjectPath( "//host3:99/root/test/static:Class3.keyX=\"keyXValue\"," "keyY=\"keyYValue\"")); test02(arr15); testEmbeddedValueArray<CIMObject>(instance1, NAMESPACE, context); testEmbeddedValueArray<CIMInstance>(instance1, NAMESPACE, context); // Calling remaining Array tests.. CIMDateTime D1("19991224120000.000000+100"); Array<CIMDateTime> arrD1(10,D1); CIMDateTime *D2 = new CIMDateTime("19991224120000.000000+100"); Array<CIMDateTime> arrD2(D2,1); test03(arrD1, arrD2, D2, CIMDateTime("19991224120000.000000+100"), CIMDateTime("29991224120000.000000+100")); delete D2; CIMName cimname1("yourName"); Array<CIMName> arrcimname1(10,cimname1); CIMName *cimname2 = new CIMName("yourName"); Array<CIMName> arrcimname2(cimname2,1); test03(arrcimname1, arrcimname2, cimname2, CIMName("yourName"), CIMName("myName")); delete cimname2; CIMKeyBinding cimbind1(cimname1, "myKey", CIMKeyBinding::STRING); CIMKeyBinding cimbind2(cimname1, "yourKey", CIMKeyBinding::STRING); Array<CIMKeyBinding> arrcimbind1(10,cimbind1); CIMKeyBinding *cimbind3 = new CIMKeyBinding(cimname1, "myKey", CIMKeyBinding::STRING); Array<CIMKeyBinding> arrcimbind2(cimbind3,1); test03(arrcimbind1, arrcimbind2, cimbind3, cimbind1, cimbind2 ); delete cimbind3; CIMNamespaceName cimnamespace1("root/SampleProvider"); Array<CIMNamespaceName> arrcimnamespace1(10,cimnamespace1); CIMNamespaceName *cimnamespace2 = new CIMNamespaceName( "root/SampleProvider"); Array<CIMNamespaceName> arrcimnamespace2(cimnamespace2,1); test03(arrcimnamespace1, arrcimnamespace2, cimnamespace2, CIMNamespaceName("root/SampleProvider"), CIMNamespaceName("root/SampleProvider2")); delete cimnamespace2; Array<Boolean> arrB1(10,true); Boolean *b = new Boolean(true); Array<Boolean> arrB2(b,1); Array<Boolean> arrB3(2); Boolean b1 = true, b2=false; test03(arrB1, arrB2, b, Boolean(true),Boolean(false)); delete b; Array<Real32> arrreal321(10); Real32 creal321(2.5); Array<Real32> arrreal322(10, creal321); Real32 *creal322 = new Real32(2.5); Array<Real32> arrreal323(creal322,1); Array<Real32> arrreal324(arrreal321); test03(arrreal322, arrreal323, creal322,Real32(2.5),Real32(3.5)); delete creal322; Array<Real64> arrreal641(10); Real64 creal641(20000.54321); Array<Real64> arrreal642(10, creal641); Real64 *creal642 = new Real64(20000.54321); Array<Real64> arrreal643(creal642,1); Array<Real64> arrreal644(arrreal641); test03(arrreal642, arrreal643, creal642,Real64(20000.54321), Real64(30000.54321)); delete creal642; Array<Sint16> arrSint161(10); Sint16 cSint161(-2000); Array<Sint16> arrSint162(10, cSint161); Sint16 *cSint162 = new Sint16(-2000); Array<Sint16> arrSint163(cSint162,1); Array<Sint16> arrSint164(arrSint161); test03(arrSint162, arrSint163, cSint162, Sint16(-2000), Sint16(-3000)); delete cSint162; Array<Sint32> arrSint321(10); Sint32 cSint321(-200000000); Array<Sint32> arrSint322(10, cSint321); Sint32 *cSint322 = new Sint32(-200000000); Array<Sint32> arrSint323(cSint322,1); Array<Sint32> arrSint324(arrSint321); test03(arrSint322, arrSint323, cSint322, Sint32(-200000000), Sint32(-300000000)); delete cSint322; Array<Sint64> arrSint641(10); Sint64 cSint641(Sint64(-2000000)*Sint64(10000000) ); Array<Sint64> arrSint642(10, cSint641); Sint64 *cSint642 = new Sint64(Sint64(-2000000)*Sint64(10000000)); Array<Sint64> arrSint643(cSint642,1); Array<Sint64> arrSint644(arrSint641); test03(arrSint642, arrSint643, cSint642,Sint64(-2000000)*Sint64(10000000), Sint64(-3000000)*Sint64(10000000)); delete cSint642; Array<Sint8> arrSint81(10); Sint8 cSint81(-20); Array<Sint8> arrSint82(10, cSint81); Sint8 *cSint82 = new Sint8(-20); Array<Sint8> arrSint83(cSint82,1); Array<Sint8> arrSint84(arrSint81); test03(arrSint82, arrSint83, cSint82, Sint8(-20), Sint8(-22)); delete cSint82; Array<Uint16> arrUint161(10); Uint16 cUint161(200); Array<Uint16> arrUint162(10, cUint161); Uint16 *cUint162 = new Uint16(200); Array<Uint16> arrUint163(cUint162,1); Array<Uint16> arrUint164(arrUint161); test03(arrUint162, arrUint163, cUint162, Uint16(200), Uint16(255)); delete cUint162; Array<Uint32> arrUint321(10); Uint32 cUint321(2000); Array<Uint32> arrUint322(10, cUint321); Uint32 *cUint322 = new Uint32(2000); Array<Uint32> arrUint323(cUint322,1); Array<Uint32> arrUint324(arrUint321); test03(arrUint322, arrUint323, cUint322, Uint32(2000), Uint32(3000)); delete cUint322; Array<Uint64> arrUint641(10); Uint64 cUint641(Uint64(2000000)*Uint64(10000000)); Array<Uint64> arrUint642(10, cUint641); Uint64 *cUint642 = new Uint64(Uint64(2000000)*Uint64(10000000)); Array<Uint64> arrUint643(cUint642,1); Array<Uint64> arrUint644(arrUint641); test03(arrUint642, arrUint643, cUint642,Uint64(2000000)*Uint64(10000000), Uint64(255000)*Uint64(10000000)); delete cUint642; Array<Uint8> arrUint81(10); Uint8 cUint81(200); Array<Uint8> arrUint82(10, cUint81); Uint8 *cUint82 = new Uint8(200); Array<Uint8> arrUint83(cUint82,1); Array<Uint8> arrUint84(arrUint81); test03(arrUint82, arrUint83, cUint82, Uint8(200), Uint8(255)); delete cUint82; Array<Char16> arrChar161(10); Char16 cChar161('Z'); Array<Char16> arrChar162(10, cChar161); Char16 *cChar162 = new Char16('Z'); Array<Char16> arrChar163(cChar162,1); Array<Char16> arrChar164(arrChar161); test03(arrChar162, arrChar163, cChar162, Char16('Z'), Char16('z')); delete cChar162; delete context; cout << argv[0] << " +++++ passed all tests" << endl; return 0; }
void drive_operation() { // Uint64 tests CQLValue a1(Uint64(10)); CQLValue a2(Uint64(15)); CQLValue a3(Uint64(25)); CQLValue a4(Uint64(30)); CQLValue a5(Uint64(150)); PEGASUS_TEST_ASSERT(a1 != a2); PEGASUS_TEST_ASSERT(a5 == a5); PEGASUS_TEST_ASSERT(a1 < a2); PEGASUS_TEST_ASSERT(a2 >= a1); PEGASUS_TEST_ASSERT(a1 <= a2); PEGASUS_TEST_ASSERT(a2 > a1); // Sint64 tests CQLValue b1(Sint64(10)); CQLValue b2(Sint64(15)); CQLValue b3(Sint64(25)); CQLValue b4(Sint64(30)); CQLValue b5(Sint64(150)); PEGASUS_TEST_ASSERT(b1 != b2); PEGASUS_TEST_ASSERT(b5 == b5); PEGASUS_TEST_ASSERT(b1 < b2); PEGASUS_TEST_ASSERT(b2 >= b1); PEGASUS_TEST_ASSERT(b1 <= b2); PEGASUS_TEST_ASSERT(b2 > b1); // Real64 tests CQLValue c1(Real64(10.00)); CQLValue c2(Real64(15.00)); CQLValue c3(Real64(25.00)); CQLValue c4(Real64(30.00)); CQLValue c5(Real64(150.00)); PEGASUS_TEST_ASSERT(c1 != c2); PEGASUS_TEST_ASSERT(c5 == c5); PEGASUS_TEST_ASSERT(c1 < c2); PEGASUS_TEST_ASSERT(c2 >= c1); PEGASUS_TEST_ASSERT(c1 <= c2); PEGASUS_TEST_ASSERT(c2 > c1); // Misc PEGASUS_TEST_ASSERT(a1 == b1); PEGASUS_TEST_ASSERT(a1 == c1); PEGASUS_TEST_ASSERT(b1 == a1); PEGASUS_TEST_ASSERT(b1 == c1); PEGASUS_TEST_ASSERT(c1 == a1); PEGASUS_TEST_ASSERT(c1 == b1); PEGASUS_TEST_ASSERT(a2 != b1); PEGASUS_TEST_ASSERT(a2 != c1); PEGASUS_TEST_ASSERT(b2 != a1); PEGASUS_TEST_ASSERT(b2 != c1); PEGASUS_TEST_ASSERT(c2 != a1); PEGASUS_TEST_ASSERT(c2 != b1); PEGASUS_TEST_ASSERT(a2 >= b1); PEGASUS_TEST_ASSERT(a2 >= c1); PEGASUS_TEST_ASSERT(b2 >= a1); PEGASUS_TEST_ASSERT(b2 >= c1); PEGASUS_TEST_ASSERT(c2 >= a1); PEGASUS_TEST_ASSERT(c2 >= b1); PEGASUS_TEST_ASSERT(a2 <= b3); PEGASUS_TEST_ASSERT(a2 <= c3); PEGASUS_TEST_ASSERT(b2 <= a3); PEGASUS_TEST_ASSERT(b2 <= c3); PEGASUS_TEST_ASSERT(c2 <= a3); PEGASUS_TEST_ASSERT(c2 <= b3); PEGASUS_TEST_ASSERT(a2 > b1); PEGASUS_TEST_ASSERT(a2 > c1); PEGASUS_TEST_ASSERT(b2 > a1); PEGASUS_TEST_ASSERT(b2 > c1); PEGASUS_TEST_ASSERT(c2 > a1); PEGASUS_TEST_ASSERT(c2 > b1); PEGASUS_TEST_ASSERT(a2 < b3); PEGASUS_TEST_ASSERT(a2 < c3); PEGASUS_TEST_ASSERT(b2 < a3); PEGASUS_TEST_ASSERT(b2 < c3); PEGASUS_TEST_ASSERT(c2 < a3); PEGASUS_TEST_ASSERT(c2 < b3); //Overflow testing CQLValue real1(Real64(0.00000001)); CQLValue sint1(Sint64(-1)); CQLValue uint1(Sint64(1)); CQLValue uint2(Uint64(0)); PEGASUS_TEST_ASSERT(uint1 > sint1); PEGASUS_TEST_ASSERT(real1 > sint1); PEGASUS_TEST_ASSERT(uint2 > sint1); PEGASUS_TEST_ASSERT(real1 > uint2); CQLValue real2(Real64(25.00000000000001)); CQLValue real3(Real64(24.99999999999999)); CQLValue sint2(Sint64(25)); CQLValue uint3(Uint64(25)); PEGASUS_TEST_ASSERT(real2 > real3); PEGASUS_TEST_ASSERT(real2 > sint2); PEGASUS_TEST_ASSERT(real2 > uint3); PEGASUS_TEST_ASSERT(real3 < sint2); PEGASUS_TEST_ASSERT(real3 < uint3); // String tests CQLValue d1(String("HELLO")); CQLValue d2(String("HEL")); CQLValue d3(String("LO")); CQLValue d4(String("AHELLO")); CQLValue d5(String("ZHELLO")); PEGASUS_TEST_ASSERT(d1 == d2 + d3); PEGASUS_TEST_ASSERT(d1 != d2 + d4); PEGASUS_TEST_ASSERT(d1 <= d5); PEGASUS_TEST_ASSERT(d1 < d5); PEGASUS_TEST_ASSERT(d1 >= d4); PEGASUS_TEST_ASSERT(d1 > d4); String str1("0x10"); String str2("10"); String str3("10B"); String str4("10.10"); CQLValue e1( str1, CQLValue::Hex); CQLValue e2( str2, CQLValue::Decimal); CQLValue e3( str3, CQLValue::Binary); CQLValue e4( str4, CQLValue::Real); CQLValue e5(Uint64(16)); CQLValue e6(Uint64(10)); CQLValue e7(Uint64(2)); CQLValue e8(Real64(10.10)); PEGASUS_TEST_ASSERT(e1 == e5); PEGASUS_TEST_ASSERT(e2 == e6); PEGASUS_TEST_ASSERT(e3 == e7); PEGASUS_TEST_ASSERT(e4 == e8); Array<Uint64> array1; array1.append(1); array1.append(2); array1.append(3); array1.append(4); array1.append(5); array1.append(6); array1.append(7); array1.append(8); array1.append(9); array1.append(10); Array<Sint64> array2; array2.append(1); array2.append(2); array2.append(3); array2.append(4); array2.append(5); array2.append(6); array2.append(7); array2.append(8); array2.append(9); array2.append(10); array2.append(3); Array<Real64> array3; array3.append(1.00); array3.append(2.00); array3.append(3.00); array3.append(9.00); array3.append(10.00); array3.append(3.00); array3.append(4.00); array3.append(5.00); array3.append(6.00); array3.append(7.00); array3.append(8.00); Array<Uint64> array4; array4.append(1); array4.append(23); array4.append(3); array4.append(4); array4.append(5); array4.append(6); array4.append(7); array4.append(88); array4.append(9); array4.append(10); Array<Sint64> array5; array5.append(-1); array5.append(2); array5.append(3); array5.append(4); array5.append(5); array5.append(-6); array5.append(7); array5.append(8); array5.append(9); array5.append(10); array5.append(-3); Array<Real64> array6; array6.append(1.23); array6.append(2.00); array6.append(3.00); array6.append(9.00); array6.append(10.00); array6.append(3.00); array6.append(4.14); array6.append(5.00); array6.append(6.00); array6.append(7.00); array6.append(8.00); CIMValue cv1(array1); CIMValue cv2(array2); CIMValue cv3(array3); CIMValue cv4(array4); CIMValue cv5(array5); CIMValue cv6(array6); CQLValue vr1(cv1); CQLValue vr2(cv1); CQLValue vr3(cv2); CQLValue vr4(cv3); CQLValue vr5(cv4); CQLValue vr6(cv5); CQLValue vr7(cv6); PEGASUS_TEST_ASSERT(vr1 == vr2); PEGASUS_TEST_ASSERT(vr1 == vr3); PEGASUS_TEST_ASSERT(vr1 == vr4); PEGASUS_TEST_ASSERT(vr4 == vr3); PEGASUS_TEST_ASSERT(vr1 != vr5); PEGASUS_TEST_ASSERT(vr3 != vr6); PEGASUS_TEST_ASSERT(vr4 != vr7); const CIMName _cimName(String("CIM_OperatingSystem")); CIMInstance _i1(_cimName); CIMProperty _p1(CIMName("Description"),CIMValue(String("Dave Rules"))); CIMProperty _p2(CIMName("EnabledState"),CIMValue(Uint16(2))); CIMProperty _p3(CIMName("CurrentTimeZone"),CIMValue(Sint16(-600))); CIMProperty _p4(CIMName("TimeOfLastStateChange"), CIMValue(CIMDateTime(String("20040811105625.000000-360")))); _i1.addProperty(_p1); _i1.addProperty(_p2); _i1.addProperty(_p3); _i1.addProperty(_p4); CIMInstance _i2(_cimName); CIMProperty _p5(CIMName("Description"), CIMValue(String("Dave Rules Everything"))); CIMProperty _p6(CIMName("EnabledState"),CIMValue(Uint16(2))); CIMProperty _p7(CIMName("CurrentTimeZone"),CIMValue(Sint16(-600))); CIMProperty _p8(CIMName("TimeOfLastStateChange"), CIMValue(CIMDateTime(String("20040811105625.000000-360")))); _i2.addProperty(_p5); _i2.addProperty(_p6); _i2.addProperty(_p7); _i2.addProperty(_p8); CQLValue cql1(_i1); CQLValue cql2(_i1); CQLValue cql3(_i2); CQLValue cql4(_i2); //PEGASUS_TEST_ASSERT(cql1 == cql1); return; }
void PG_TestPropertyTypes::initialize(CIMOMHandle& cimom) { // save cimom handle _cimom = cimom; // create default instances CIMInstance instance1("PG_TestPropertyTypes"); instance1.addProperty(CIMProperty( "CreationClassName", String("PG_TestPropertyTypes"))); // key instance1.addProperty(CIMProperty("InstanceId", Uint64(1))); //key instance1.addProperty(CIMProperty( "PropertyString", String("PG_TestPropertyTypes_Instance1"))); instance1.addProperty(CIMProperty("PropertyUint8", Uint8(120))); instance1.addProperty(CIMProperty("PropertyUint16", Uint16(1600))); instance1.addProperty(CIMProperty("PropertyUint32", Uint32(3200))); instance1.addProperty(CIMProperty("PropertyUint64", Uint64(6400))); instance1.addProperty(CIMProperty("PropertySint8", Sint8(-120))); instance1.addProperty(CIMProperty("PropertySint16", Sint16(-1600))); instance1.addProperty(CIMProperty("PropertySint32", Sint32(-3200))); instance1.addProperty(CIMProperty("PropertySint64", Sint64(-6400))); instance1.addProperty(CIMProperty("PropertyBoolean", Boolean(1))); instance1.addProperty(CIMProperty("PropertyReal32", Real32(1.12345670123))); instance1.addProperty(CIMProperty( "PropertyReal64", Real64(1.12345678906543210123))); instance1.addProperty(CIMProperty( "PropertyDatetime", CIMDateTime("20010515104354.000000:000"))); // update object path { CIMObjectPath objectPath = instance1.getPath(); Array<CIMKeyBinding> keys; { CIMProperty keyProperty = instance1.getProperty( instance1.findProperty("CreationClassName")); keys.append( CIMKeyBinding(keyProperty.getName(), keyProperty.getValue())); } { CIMProperty keyProperty = instance1.getProperty( instance1.findProperty("InstanceId")); keys.append( CIMKeyBinding(keyProperty.getName(), keyProperty.getValue())); } objectPath.setKeyBindings(keys); instance1.setPath(objectPath); } _instances.append(instance1); CIMInstance instance2("PG_TestPropertyTypes"); instance2.addProperty(CIMProperty( "CreationClassName", String("PG_TestPropertyTypes"))); // key instance2.addProperty(CIMProperty("InstanceId", Uint64(2))); //key instance2.addProperty(CIMProperty( "PropertyString", String("PG_TestPropertyTypes_Instance2"))); instance2.addProperty(CIMProperty("PropertyUint8", Uint8(122))); instance2.addProperty(CIMProperty("PropertyUint16", Uint16(1602))); instance2.addProperty(CIMProperty("PropertyUint32", Uint32(3202))); instance2.addProperty(CIMProperty("PropertyUint64", Uint64(6402))); instance2.addProperty(CIMProperty("PropertySint8", Sint8(-122))); instance2.addProperty(CIMProperty("PropertySint16", Sint16(-1602))); instance2.addProperty(CIMProperty("PropertySint32", Sint32(-3202))); instance2.addProperty(CIMProperty("PropertySint64", Sint64(-6402))); instance2.addProperty(CIMProperty("PropertyBoolean", Boolean(0))); instance2.addProperty(CIMProperty("PropertyReal32", Real32(2.12345670123))); instance2.addProperty(CIMProperty( "PropertyReal64", Real64(2.12345678906543210123))); instance2.addProperty(CIMProperty( "PropertyDatetime", CIMDateTime("20010515104354.000000:000"))); _instances.append(instance2); // update object path { CIMObjectPath objectPath = instance2.getPath(); Array<CIMKeyBinding> keys; { CIMProperty keyProperty = instance2.getProperty( instance2.findProperty("CreationClassName")); keys.append( CIMKeyBinding(keyProperty.getName(), keyProperty.getValue())); } { CIMProperty keyProperty = instance2.getProperty( instance2.findProperty("InstanceId")); keys.append( CIMKeyBinding(keyProperty.getName(), keyProperty.getValue())); } objectPath.setKeyBindings(keys); instance2.setPath(objectPath); } // instance3 to check for negative floating point and exponents CIMInstance instance3("PG_TestPropertyTypes"); instance3.addProperty(CIMProperty( "CreationClassName", String("PG_TestPropertyTypes"))); // key instance3.addProperty(CIMProperty("InstanceId", Uint64(3))); //key instance3.addProperty(CIMProperty( "PropertyString", String("PG_TestPropertyTypes_Instance3"))); instance3.addProperty(CIMProperty("PropertyUint8", Uint8(120))); instance3.addProperty(CIMProperty("PropertyUint16", Uint16(1600))); instance3.addProperty(CIMProperty("PropertyUint32", Uint32(3200))); instance3.addProperty(CIMProperty("PropertyUint64", Uint64(6400))); instance3.addProperty(CIMProperty("PropertySint8", Sint8(-120))); instance3.addProperty(CIMProperty("PropertySint16", Sint16(-1600))); instance3.addProperty(CIMProperty("PropertySint32", Sint32(-3200))); instance3.addProperty(CIMProperty("PropertySint64", Sint64(-6400))); instance3.addProperty(CIMProperty("PropertyBoolean", Boolean(0))); instance3.addProperty(CIMProperty( "PropertyReal32", Real32(-1.12345670123))); instance3.addProperty(CIMProperty( "PropertyReal64", Real64(0.000000012345))); instance3.addProperty(CIMProperty( "PropertyDatetime", CIMDateTime("20060301104354.000000:000"))); // update object path { CIMObjectPath objectPath = instance3.getPath(); Array<CIMKeyBinding> keys; { CIMProperty keyProperty = instance3.getProperty( instance3.findProperty("CreationClassName")); keys.append( CIMKeyBinding(keyProperty.getName(), keyProperty.getValue())); } { CIMProperty keyProperty = instance3.getProperty(instance3.findProperty("InstanceId")); keys.append( CIMKeyBinding(keyProperty.getName(), keyProperty.getValue())); } objectPath.setKeyBindings(keys); instance3.setPath(objectPath); } realValueTestInstance = instance3; }
CIMInstance buildCIMInstanceSourceObject(Boolean display) { // Build an instance of a class that will be embedded within // the instance of MyClass CIMInstance instembed(CIMName("EmbedClassClass")); instembed.addProperty(CIMProperty(CIMName("embedBool"), true)); instembed.addProperty(CIMProperty(CIMName("embedInt"), Uint32(5))); instembed.addProperty(CIMProperty(CIMName("embedStr"), String("Test"))); // Build an instance that will be the primary test instance CIMInstance inst(CIMName("MyClass")); inst.addProperty(CIMProperty(CIMName("BoolScal1"), true)); inst.addProperty(CIMProperty(CIMName("BoolScal2"), false)); inst.addProperty(CIMProperty(CIMName("IntScal1"), Uint32(5))); inst.addProperty(CIMProperty(CIMName("IntScal2"), Uint32(25))); inst.addProperty(CIMProperty(CIMName("IntScal3"), Sint32(-25123))); inst.addProperty(CIMProperty(CIMName("IntScal4"), Uint32(0))); inst.addProperty(CIMProperty(CIMName("Int64Scal5"), Uint64(0x6fffff))); inst.addProperty(CIMProperty(CIMName("Int64Scal6"), Uint64(2147483647))); inst.addProperty(CIMProperty(CIMName("Int64Scal7"), Uint64(4067))); inst.addProperty(CIMProperty(CIMName("Int64Scal8"), Uint64(0))); //// TODO add properties max and min integers. // Add real properties inst.addProperty(CIMProperty(CIMName("DoubleScal1"), Real64(20.9))); inst.addProperty(CIMProperty(CIMName("DoubleScal2"), Real64(0.9))); inst.addProperty(CIMProperty(CIMName("DoubleScal3"), Real32(20.9))); inst.addProperty(CIMProperty(CIMName("DoubleScal4"), Real32(0.9))); // add scalar string properties inst.addProperty(CIMProperty(CIMName("strScal1"), String("Test"))); inst.addProperty(CIMProperty(CIMName("strScal2"), String("noTest"))); inst.addProperty(CIMProperty(CIMName("strScal3"), String(""))); // add string property with special characters. inst.addProperty(CIMProperty(CIMName("strScal4"), String("./\\\"\'!@#$%^&*()"))); // DateTime Scalar properties - TODO create test for // additional formats for this field (interval, other offsets. CIMDateTime dt1; dt1.set("19991224120000.000000+360"); inst.addProperty(CIMProperty(CIMName("dateTimeScal1"),dt1)); CIMDateTime dt2; dt2.set("19991224120000.0000**+360"); inst.addProperty(CIMProperty(CIMName("dateTimeScal2"),dt2)); // reference literal properties CIMObjectPath op1 = CIMObjectPath ("//atp:77/root/cimv25:" "TennisPlayer.first=\"Chris\",last=\"Evert\""); inst.addProperty(CIMProperty(CIMName("referenceScal1"),op1)); CIMObjectPath op2 = CIMObjectPath ("root/cimv25:" "TennisPlayer.first=\"Chris\",last=\"Evert\""); inst.addProperty(CIMProperty(CIMName("referenceScal2"),op2)); CIMObjectPath op3 = CIMObjectPath ("TennisPlayer.first=\"Chris\",last=\"Evert\""); inst.addProperty(CIMProperty(CIMName("referenceScal3"),op3)); CIMObjectPath op4 = CIMObjectPath ("myclassname.p1=1"); inst.addProperty(CIMProperty(CIMName("referenceScal4"),op4)); // KS_TODO create a Reference array property // Embedded instance property inst.addProperty(CIMProperty(CIMName("embeddedInstance1"),instembed)); // Array properties // Boolean Array Array<Boolean> b1; b1.append(true); b1.append(false); b1.append(true); inst.addProperty(CIMProperty(CIMName("BoolArrayProp1"), b1)); Array<Boolean> b2; b2.append(true); b2.append(false); b2.append(true); inst.addProperty(CIMProperty(CIMName("BoolArrayProp2"), b2)); Array<Boolean> b3; b3.append(false); b3.append(false); b3.append(false); inst.addProperty(CIMProperty(CIMName("BoolArrayProp3"), b1)); // Integer Array Array<Sint64> a1; a1.append(4); a1.append(5); a1.append (7); inst.addProperty(CIMProperty(CIMName("IntArrayProp1"), a1)); Array<Sint64> a2; a2.append(7); a2.append(8); a2.append (9); inst.addProperty(CIMProperty(CIMName("IntArrayProp2"), a2)); Array<Sint64> a3; a3.append(7); a3.append(-888); a3.append (-999); inst.addProperty(CIMProperty(CIMName("IntArrayProp3"), a3)); Array<Sint64> a4; a4.append(7); inst.addProperty(CIMProperty(CIMName("IntArrayProp4"), a4)); Array<Sint64> a5;; inst.addProperty(CIMProperty(CIMName("IntArrayProp5"), a5)); // Double Array Array<Real64> r1; r1.append(1011.04); r1.append(123456.8); r1.append(0.1); inst.addProperty(CIMProperty(CIMName("DoubleArrayProp1"), r1)); Array<Real64> r2; r2.append(-1.04); r2.append(-123456.8); r2.append(0.1); inst.addProperty(CIMProperty(CIMName("DoubleArrayProp2"), r2)); // String Array Array<String> s1; s1.append("zero"); s1.append("one"); s1.append("two"); s1.append("three"); inst.addProperty(CIMProperty(CIMName("StrArrayProp1"), s1)); Array<String> s2; s2.append("zero"); s2.append("one"); s2.append("two"); s2.append("three"); inst.addProperty(CIMProperty(CIMName("StrArrayProp2"), s2)); // DateTime Array Array<CIMDateTime> dta1; dta1.append(dt1); dt1.clear();dt1.set("20131224120000.000000+360"); dta1.append(dt1); dt1.clear();dt1.set("20011224120000.000000+360"); dta1.append(dt1); inst.addProperty(CIMProperty(CIMName("dateTimeArray1"),dta1)); if (display) { VCOUT << "Instance to be used in Test" << endl; PrintInstance(cout, inst); } return inst; }
JSON parse() { bool bPositive = (!tryParse(L'-')); if (bPositive) tryParse(L'+'); SInt64 iBase; UInt8 iFirstDigit; if (Character::decDigit(peek(), iFirstDigit) == Character::eCodingFailure) return JSON(1); iBase = iFirstDigit; pop(); if (iBase != 0) { UInt8 iNextDigit; while (Character::decDigit(peek(), iNextDigit) == Character::eCodingSuccess) { pop(); iBase *= 10; iBase += iNextDigit; } } Real64 fBase = Real64(iBase); bool bPoint = tryParse(L'.'); if (bPoint) { Real64 fFactor = 0.1; UInt8 iNextDigit; while (Character::decDigit(peek(), iNextDigit) == Character::eCodingSuccess) { pop(); fBase += (fFactor * iNextDigit); fFactor /= 10; } } bool bExponent = (tryParse(L'e') || tryParse(L'E')); if (bExponent) { bool bPositiveExponent = (!tryParse(L'-')); if (bPositiveExponent) tryParse(L'+'); SInt64 iExponent; UInt8 iFirstDigit; if (Character::decDigit(peek(), iFirstDigit) == Character::eCodingSuccess) { iExponent = iFirstDigit; pop(); UInt8 iNextDigit; while (Character::decDigit(peek(), iNextDigit) == Character::eCodingSuccess) { pop(); iExponent *= 10; iExponent += iNextDigit; } if (bPositiveExponent) fBase *= std::pow(Real64(10),Real64(iExponent)); else fBase *= std::pow(Real64(10),Real64(-iExponent)); } else bExponent = false; } if (bPoint || bExponent) { if (bPositive) return JSON(fBase); else return JSON(-fBase); } else { if (bPositive) return JSON(iBase); else return JSON(-iBase); } }
int createErrorInstance(CIMClient& client) { // Build the embedded instance Array<CIMKeyBinding> embeddedPathKeys; CIMName key1Name("key1"); CIMValue key1Value(String("fake-key1")); CIMName key2Name("key2"); CIMValue key2Value(String("fake-key2")); embeddedPathKeys.append(CIMKeyBinding(key1Name, key1Value)); embeddedPathKeys.append(CIMKeyBinding(key2Name, key2Value)); CIMObjectPath embeddedPath( "localhost", TEST_NAMESPACE, CIMName("PG_EmbeddedClass"), embeddedPathKeys); embeddedInstance.reset(new CIMInstance(CIMName("PG_EmbeddedClass"))); //embeddedInstance->setPath(embeddedPath); embeddedInstance->addProperty(CIMProperty(key1Name, key1Value)); embeddedInstance->addProperty(CIMProperty(key2Name, key2Value)); embeddedInstance->addProperty(CIMProperty(CIMName("prop01"), Uint8(234))); embeddedInstance->addProperty(CIMProperty(CIMName("prop02"), Uint16(16234))); embeddedInstance->addProperty(CIMProperty(CIMName("prop03"), Uint32(32234))); embeddedInstance->addProperty(CIMProperty(CIMName("prop04"), Uint64(64234))); embeddedInstance->addProperty(CIMProperty(CIMName("prop05"), Sint8(-234))); embeddedInstance->addProperty(CIMProperty(CIMName("prop06"), Sint16(-16234))); embeddedInstance->addProperty(CIMProperty(CIMName("prop07"), Sint32(-32234))); embeddedInstance->addProperty(CIMProperty(CIMName("prop08"), Sint64(-64234))); embeddedInstance->addProperty(CIMProperty(CIMName("prop09"), Real32(-64234.46))); embeddedInstance->addProperty(CIMProperty(CIMName("prop10"), Real64(-23464234.78))); embeddedInstance->addProperty(CIMProperty(CIMName("prop11"), CIMDateTime(60, true))); // Build the embedded instance Array<CIMKeyBinding> errorPathKeys; CIMName errorKeyName("errorKey"); CIMValue errorKeyValue(String("error key 1")); errorPathKeys.append(CIMKeyBinding(errorKeyName, errorKeyValue)); CIMObjectPath localErrorPath( "localhost", TEST_NAMESPACE, CIMName("PG_EmbeddedError"), errorPathKeys); errorInstance.reset(new CIMInstance(CIMName("PG_EmbeddedError"))); errorInstance->setPath(localErrorPath); errorInstance->addProperty(CIMProperty(errorKeyName, errorKeyValue)); errorInstance->addProperty(CIMProperty(CIMName("EmbeddedInst"), CIMValue(*embeddedInstance))); try { errorPath = client.createInstance(TEST_NAMESPACE, *errorInstance); PEGASUS_STD(cout) << "Created EmbeddedError: " << errorPath.toString() << PEGASUS_STD(endl); errorInstance->setPath(errorPath); } catch (Exception& e) { PEGASUS_STD(cout) << "Exception while creating Error Instance: " << e.getMessage() << PEGASUS_STD(endl); return -1; } return 0; }