📄 cqlvalue.cpp
字号:
_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 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 drive_resolve_primitive(){ const char* env = getenv("PEGASUS_HOME"); String repositoryDir(env); repositoryDir.append("/repository"); //String repositoryDir("c:/pegasus-cvs/pegasus/repository"); CIMNamespaceName _ns("root/cimv2"); CIMRepository *_rep = new CIMRepository(repositoryDir); RepositoryQueryContext _query(_ns, _rep); RepositoryQueryContext _query1(_ns, _rep);try{ const CQLIdentifier _Id1(String("CIM_OperatingSystem")); _query.insertClassPath(_Id1); 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); CQLChainedIdentifier ci1(String("CIM_OperatingSystem.CIM_OperatingSystem::Description")); CQLChainedIdentifier ci2(String("CIM_OperatingSystem.CIM_OperatingSystem::EnabledState")); CQLChainedIdentifier ci3(String("CIM_OperatingSystem.CIM_OperatingSystem::CurrentTimeZone")); CQLChainedIdentifier ci4(String("CIM_OperatingSystem.CIM_OperatingSystem::TimeOfLastStateChange")); CQLChainedIdentifier ci5(String( "CIM_OperatingSystem.CIM_EnabledLogicalElement::TimeOfLastStateChange")); CQLChainedIdentifier ci7(String("CIM_OperatingSystem")); CQLChainedIdentifier ci9(String( "CIM_EnabledLogicalElement.CIM_OperatingSystem::CSCreationClassName")); CQLChainedIdentifier ci10(String("CIM_OperatingSystem.CIM_OperatingSystem::Bubba")); CQLValue a1(ci1); CQLValue a2(ci2); CQLValue a3(ci3); CQLValue a4(ci4); CQLValue a5(ci5); CQLValue a7(ci7); CQLValue a9(ci9); CQLValue a10(ci10); CQLValue a11(_query.getClass(CIMName("CIM_OperatingSystem"))); a1.resolve(_i1, _query); a2.resolve(_i1, _query); a3.resolve(_i1, _query); a4.resolve(_i1, _query); a5.resolve(_i1, _query); a7.resolve(_i1, _query); a10.resolve(_i1, _query1); a9.resolve(_i1, _query); PEGASUS_TEST_ASSERT(a1 == CQLValue(String("Dave Rules"))); PEGASUS_TEST_ASSERT(a2 == CQLValue(Uint64(2))); PEGASUS_TEST_ASSERT(a3 == CQLValue(Sint64(-600))); PEGASUS_TEST_ASSERT(a4 == CQLValue(CIMDateTime(String("20040811105625.000000-360")))); PEGASUS_TEST_ASSERT(a5 == CQLValue(CIMDateTime(String("20040811105625.000000-360")))); //PEGASUS_TEST_ASSERT(a7 == CQLValue(_i1)); PEGASUS_TEST_ASSERT(a9.getValueType() == CQLValue::Null_type); PEGASUS_TEST_ASSERT(a10.getValueType() == CQLValue::Null_type); } catch(Exception & e) { cout << e.getMessage() << endl; PEGASUS_TEST_ASSERT(0); } delete _rep; return;}void drive_resolve_specialChars(){ const char* env = getenv("PEGASUS_HOME"); String repositoryDir(env); repositoryDir.append("/repository"); //String repositoryDir("c:/pegasus-cvs/pegasus/repository"); CIMNamespaceName _ns("root/cimv2"); CIMRepository *_rep = new CIMRepository(repositoryDir); RepositoryQueryContext _query(_ns, _rep); RepositoryQueryContext _query1(_ns, _rep); try{ const CQLIdentifier _Id1(String("CIM_OperatingSystem")); _query.insertClassPath(_Id1); const CIMName _cimName(String("CIM_OperatingSystem")); CIMInstance _i1(_cimName); CIMProperty _p1(CIMName("OSType"),CIMValue(Uint16(11))); CIMProperty _p2(CIMName("Status"),CIMValue(String("Degraded"))); Array<Uint16> array16; array16.append(Uint16(0)); array16.append(Uint16(1)); array16.append(Uint16(2)); array16.append(Uint16(3)); CIMProperty _p3(CIMName("OperationalStatus"),CIMValue(array16)); _i1.addProperty(_p1); _i1.addProperty(_p2); _i1.addProperty(_p3); CQLChainedIdentifier ci1(String("CIM_OperatingSystem.OSType#OS400")); CQLChainedIdentifier ci2(String("CIM_OperatingSystem.OSType#LINUX")); CQLChainedIdentifier ci3(String("CIM_OperatingSystem.Status#Degraded")); CQLChainedIdentifier ci5(String("CIM_OperatingSystem.Status#BOGUS")); CQLChainedIdentifier ci6(String("CIM_OperatingSystem.CIM_OperatingSystem::OperationalStatus[2]")); CQLValue a1(ci1); CQLValue a2(ci2); CQLValue a3(ci3); CQLValue a5(ci5); CQLValue a6(ci6); a1.resolve(_i1, _query); a2.resolve(_i1, _query); a6.resolve(_i1, _query); try { a3.resolve(_i1, _query); PEGASUS_TEST_ASSERT(0); } catch(...) { PEGASUS_TEST_ASSERT(1); } try { a5.resolve(_i1, _query); PEGASUS_TEST_ASSERT(0); } catch(...) { PEGASUS_TEST_ASSERT(1); } PEGASUS_TEST_ASSERT(a1 == CQLValue(Uint64(11))); PEGASUS_TEST_ASSERT(a2 == CQLValue(Uint64(36))); PEGASUS_TEST_ASSERT(a6 == CQLValue(Uint64(2))); } catch(Exception & e) { cout << e.getMessage() << endl; PEGASUS_TEST_ASSERT(0); } delete _rep; return;}int main( int argc, char *argv[] ){ Boolean verbose = false; verbose = getenv("PEGASUS_TEST_VERBOSE"); Boolean unittests = false; if (argc == 2 && !strcmp (argv[1],"unittests")) { unittests = true; } else if (argc == 2 && !strcmp (argv[1],"poststarttests")) { unittests = false; } else { cout << argv[0] << ": ERROR - paramater invalid must be either unittests or poststarttests" << endl; exit(0); } try { //BEGIN TESTS.... if (unittests) { if (verbose) cout << argv[0] << " " << argv[1] << " +++++ operation " << endl; drive_operation(); if (verbose) cout << argv[0] << " " << argv[1] << " +++++ misc " << endl; drive_get_misc_functions(); } else { if (verbose) cout << argv[0] << " " << argv[1] << " +++++ primitive " << endl; drive_resolve_primitive(); if (verbose) cout << argv[0] << " " << argv[1] << " +++++ special " << endl; drive_resolve_specialChars(); } //END TESTS.... cout << argv[0] << " " << argv[1] << " +++++ passed all tests" << endl; }catch(Exception e) { cout << e.getMessage() << endl; PEGASUS_TEST_ASSERT(0); } return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -