⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 paramvalue.cpp

📁 Pegasus is an open-source implementationof the DMTF CIM and WBEM standards. It is designed to be por
💻 CPP
字号:
//%2006//////////////////////////////////////////////////////////////////////////// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;// IBM Corp.; EMC Corporation, The Open Group.// Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;// EMC Corporation; VERITAS Software Corporation; The Open Group.// Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;// EMC Corporation; Symantec Corporation; The Open Group.//// Permission is hereby granted, free of charge, to any person obtaining a copy// of this software and associated documentation files (the "Software"), to// deal in the Software without restriction, including without limitation the// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or// sell copies of the Software, and to permit persons to whom the Software is// furnished to do so, subject to the following conditions:// // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN// ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED// "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.////==============================================================================//// Author: Nitin Upasani, Hewlett-Packard Company (Nitin_Upasani@hp.com)//// Modified By: Jenny Yu, Hewlett-Packard Company (jenny_yu@hp.com)//              Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)//              Carol Ann Krug Graves, Hewlett-Packard Company//                  (carolann_graves@hp.com)//              David Dillard, VERITAS Software Corp.//                  (david.dillard@veritas.com)////%/////////////////////////////////////////////////////////////////////////////#include <Pegasus/Common/PegasusAssert.h>#include <Pegasus/Common/CIMParamValue.h>#include <Pegasus/Common/XmlWriter.h>PEGASUS_USING_PEGASUS;PEGASUS_USING_STD;static char * verbose;void test01(){    CIMParamValue pv;    PEGASUS_TEST_ASSERT(pv.isUninitialized());    String p1("message");    CIMValue v1(String("argument_Test"));    CIMParamValue a1(p1, v1);//  Test call to CIMParamValue::setValue(CIMValue& value)//  this test uses the above values for a1, p1 and v1.    CIMParamValue a7(p1, v1);    CIMValue v7(String("argument_Test7"));    a7.setValue( v7);    PEGASUS_TEST_ASSERT(a1.getValue().toString() != a7.getValue().toString());    PEGASUS_TEST_ASSERT(a1.getParameterName() == a7.getParameterName());//  Test call to CIMParamValue::setParameterName(String& parameterName)//  this test uses the above values for a1, p1 and v1.    CIMParamValue a8(p1, v1);    String p8("message8");    a8.setParameterName( p8);    PEGASUS_TEST_ASSERT(a1.getValue().toString() == a8.getValue().toString());    PEGASUS_TEST_ASSERT(a1.getParameterName() != a8.getParameterName());    PEGASUS_TEST_ASSERT(a8.isTyped());    a8.setIsTyped(false);    PEGASUS_TEST_ASSERT(!a8.isTyped());    String p2("message2");    CIMValue v2(String("argument_Test2"));    CIMParamValue a2(p2, v2);    String p3("message3");    CIMValue v3(String("argument_Test3"));    CIMParamValue a3(p3, v3);    String p4("message4");    CIMValue v4(String("argument_Test4"));    CIMParamValue a4(p4, v4);    CIMParamValue a5 = a4;    String p6("message6");    CIMValue v6(String("argument_Test6"));    CIMParamValue a6(p6, v6);    Array<CIMParamValue> aa;    aa.append(a1);    aa.append(a2);    aa.append(CIMParamValue("message3", CIMValue(200000)));    aa.append(CIMParamValue("message4", CIMValue(String("test4"))));        //    // clone    //    CIMParamValue a4clone = a4.clone();    aa.append(a4clone);    if (verbose)    {        for (Uint32 i=0; i< aa.size(); i++)        {            XmlWriter::printParamValueElement(aa[i], cout);        }    }    //    // toXml    //    Buffer xmlOut;    XmlWriter::appendParamValueElement(xmlOut, a4clone);}#define TEST_UNINITIALIZED_OBJECT_EXCEPTION(statement) \    {                                                  \        Boolean gotException = false;                  \        try                                            \        {                                              \            statement;                                 \        }                                              \        catch (const UninitializedObjectException&)    \        {                                              \            gotException = true;                       \        }                                              \        PEGASUS_TEST_ASSERT(gotException);             \    }void testUninitializedObject(){    CIMParamValue uninitializedParamValue;    String name("name");    CIMValue value(String("value"));    PEGASUS_TEST_ASSERT(uninitializedParamValue.isUninitialized());    // Copy constructor allows an uninitialized object    {        CIMParamValue initializedParamValue(uninitializedParamValue);    }    // Assignment operator allows an uninitialized object    {        CIMParamValue initializedParamValue(name, value);        initializedParamValue = uninitializedParamValue;    }    TEST_UNINITIALIZED_OBJECT_EXCEPTION(        uninitializedParamValue.getParameterName());    TEST_UNINITIALIZED_OBJECT_EXCEPTION(        uninitializedParamValue.getValue());    TEST_UNINITIALIZED_OBJECT_EXCEPTION(        uninitializedParamValue.isTyped());    TEST_UNINITIALIZED_OBJECT_EXCEPTION(        uninitializedParamValue.setParameterName(name));    TEST_UNINITIALIZED_OBJECT_EXCEPTION(        uninitializedParamValue.setValue(value));    TEST_UNINITIALIZED_OBJECT_EXCEPTION(        uninitializedParamValue.setIsTyped(true));    TEST_UNINITIALIZED_OBJECT_EXCEPTION(        uninitializedParamValue.clone());}int main(int argc, char** argv){    verbose = getenv("PEGASUS_TEST_VERBOSE");    try    {        test01();        testUninitializedObject();    }    catch (Exception& e)    {        cout << "Exception: " << e.getMessage() << endl;        return 1;    }    cout << argv[0] << " +++++ passed all tests" << endl;    return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -