当前位置: 首页>>代码示例>>C++>>正文


C++ PEGASUS_TEST_ASSERT函数代码示例

本文整理汇总了C++中PEGASUS_TEST_ASSERT函数的典型用法代码示例。如果您正苦于以下问题:C++ PEGASUS_TEST_ASSERT函数的具体用法?C++ PEGASUS_TEST_ASSERT怎么用?C++ PEGASUS_TEST_ASSERT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了PEGASUS_TEST_ASSERT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: testCreateLocalAuthFile

void testCreateLocalAuthFile(void)
{
    int testUid;
    int testGid;
    PEGASUS_TEST_ASSERT(
        GetUserInfo(PEGASUS_CIMSERVERMAIN_USER, &testUid, &testGid) == 0);

    /* Test with file path that already exists */
    {
        ssize_t result;
        const char* path = "testlocalauthfile";
        int fd = open(path, O_WRONLY | O_EXCL | O_CREAT | O_TRUNC, S_IRUSR);
        EXECUTOR_RESTART(write(fd, "test", 4), result);
        close(fd);
        PEGASUS_TEST_ASSERT(CreateLocalAuthFile(path, testUid, testGid) == 0);
        unlink(path);
    }

    /* Test with non-existent directory in file path */
    {
        const char* path =
            "/tmp/nonexistentdirectory/anotherone/pegasus/localauthtestfile";
        PEGASUS_TEST_ASSERT(CreateLocalAuthFile(path, testUid, testGid) != 0);
    }
}
开发者ID:brunolauze,项目名称:pegasus,代码行数:25,代码来源:TestExecutorLocalAuth.c

示例2: testCheckLocalAuthToken

void testCheckLocalAuthToken(void)
{
    /* Test with file path that does not exist */
    {
        const char* path = "nonexistenttestfile";
        PEGASUS_TEST_ASSERT(CheckLocalAuthToken(path, "secret") != 0);
    }

    /* Test with secret token that is too short */
    {
        ssize_t result;
        const char* path = "testlocalauthfile";
        int fd = open(path, O_WRONLY | O_EXCL | O_CREAT | O_TRUNC, S_IRUSR);
        EXECUTOR_RESTART(write(fd, "secret", 6), result);
        close(fd);
        PEGASUS_TEST_ASSERT(CheckLocalAuthToken(path, "secret") != 0);
        unlink(path);
    }

    /* Test with incorrect secret token */
    {
        ssize_t result;
        const char* path = "testlocalauthfile";
        int fd = open(path, O_WRONLY | O_EXCL | O_CREAT | O_TRUNC, S_IRUSR);
        EXECUTOR_RESTART(
            write(fd, "1234567890123456789012345678901234567890", 40), result);
        close(fd);
        PEGASUS_TEST_ASSERT(CheckLocalAuthToken(
            path, "123456789012345678901234567890123456789X") != 0);
        unlink(path);
    }
}
开发者ID:brunolauze,项目名称:pegasus,代码行数:32,代码来源:TestExecutorLocalAuth.c

示例3: methodName

void _sendIndicationShouldBeBlocked 
    (CIMClient & client)
{
    Array <CIMParamValue> inParams;
    Array <CIMParamValue> outParams;
    Array <CIMKeyBinding> keyBindings;
    Sint32 result;

    CIMName methodName ("SendTestIndication");
    CIMObjectPath className (String::EMPTY, CIMNamespaceName (), 
        CIMName("Test_IndicationProviderClass"), keyBindings);

    try
    {
        CIMValue retValue = client.invokeMethod 
            (SOURCENAMESPACE,
            className,
            methodName,
            inParams,
            outParams);
        retValue.get (result);
        PEGASUS_TEST_ASSERT (false);
    }
    catch (CIMException & e)
    {
        PEGASUS_TEST_ASSERT (e.getCode () == CIM_ERR_NOT_SUPPORTED);
    }
}
开发者ID:host1812,项目名称:scx_plugin_public,代码行数:28,代码来源:DisableEnable2.cpp

示例4: runCIMNameCastTests

void runCIMNameCastTests()
{
    try
    {
        CIMName name(CIMNameCast("Okay"));
    }
    catch (...)
    {
        PEGASUS_TEST_ASSERT(false);
    }

    Boolean caught = false;

    try
    {
        CIMName name(CIMNameCast("Not Okay"));
    }
    catch (InvalidNameException& e)
    {
        caught = true;
    }
    catch (...)
    {
        PEGASUS_TEST_ASSERT(false);
    }

#if defined(PEGASUS_DEBUG)
    PEGASUS_TEST_ASSERT(caught);
#else
    PEGASUS_TEST_ASSERT(!caught);
#endif
}
开发者ID:host1812,项目名称:scx_plugin_public,代码行数:32,代码来源:TestCIMName.cpp

示例5: test05

//Test reference array type properties
void test05()
{
    Array<CIMObjectPath> oa;
    oa.append(CIMObjectPath("/root/cimv2:My_Class.a=1"));
    oa.append(CIMObjectPath("/root/cimv2:My_Class.a=2"));
    CIMProperty p1;

    Boolean gotException = false;
    try
    {
        p1 = CIMProperty(CIMName("property1"), oa, 0, CIMName("refclass"));
    }
    catch (TypeMismatchException&)
    {
        gotException = true;
    }
    PEGASUS_TEST_ASSERT(gotException);

    p1 = CIMProperty(CIMName("property1"), oa[0], 0, CIMName("refclass"));
    gotException = false;
    try
    {
        p1.setValue(oa);
    }
    catch (TypeMismatchException&)
    {
        gotException = true;
    }
    PEGASUS_TEST_ASSERT(gotException);
}
开发者ID:host1812,项目名称:scx_plugin_public,代码行数:31,代码来源:Property.cpp

示例6: test02

// Test Thread and AtomicInt
void test02()
{
    const Uint32 numThreads = 64;
    AtomicInt * atom = new AtomicInt(0);
    Thread* threads[numThreads];

    (*atom)++;
    Boolean zero = atom->decAndTestIfZero();
    PEGASUS_TEST_ASSERT(zero);

    for (Uint32 i=0; i<numThreads; i++)
    {
        threads[i] = new Thread(atomicIncrement, atom, false);
    }

    for (Uint32 i=0; i<numThreads; i++)
    {
        threads[i]->run();
    }

    for (Uint32 i=0; i<numThreads; i++)
    {
        threads[i]->join();
        delete threads[i];
    }

    PEGASUS_TEST_ASSERT(atom->get() == numThreads);
    delete atom;
}
开发者ID:brunolauze,项目名称:pegasus,代码行数:30,代码来源:IPC.cpp

示例7: main

int main (int argc, char** argv)
{
    String stringVal;
    verbose = (getenv("PEGASUS_TEST_VERBOSE")) ? true : false;

    CIMClient client;
    try
    {
        client.connectLocal ();
    }
    catch (Exception & e)
    {
        PEGASUS_STD (cerr) << e.getMessage () << PEGASUS_STD (endl);
        return -1;
    }

    _enumerateInstanceNames(client);
    _getInstance(client);
    _setProperty(client, 7890);
    _getProperty(client);
    // getProperty() only returns CIMValues of type String.
    value.get(stringVal);
    PEGASUS_TEST_ASSERT(atoi((const char*)stringVal.getCString())==7890);
    _setProperty(client,1234);
    _getProperty(client);
    // getProperty() only returns CIMValues of type String.
    // Verify that setProperty worked as expected.
    value.get(stringVal);
    PEGASUS_TEST_ASSERT(atoi((const char*)stringVal.getCString())==1234);

    return 0;
}
开发者ID:rdobson,项目名称:openpegasus,代码行数:32,代码来源:TestCMPIProperty.cpp

示例8: testCleanupIdleThread

void testCleanupIdleThread()
{
    if (verbose)
    {
        cout << "testCleanupIdleThread" << endl;
    }

    try
    {
        struct timeval deallocateWait = { 0, 1 };
        ThreadPool threadPool(0, "test cleanup", 0, 6, deallocateWait);

        threadPool.allocate_and_awaken(
            (void*)1, funcSleepSpecifiedMilliseconds);
        Threads::sleep(1000);

        PEGASUS_TEST_ASSERT(threadPool.idleCount() == 1);
        threadPool.cleanupIdleThreads();
        PEGASUS_TEST_ASSERT(threadPool.idleCount() == 0);
    }
    catch (const Exception& e)
    {
        cout << "Exception in testCleanupIdleThread: " <<
             e.getMessage() << endl;
        PEGASUS_TEST_ASSERT(false);
    }
}
开发者ID:host1812,项目名称:scx_plugin_public,代码行数:27,代码来源:ThreadPool.cpp

示例9: CompareQualifiers

PEGASUS_NAMESPACE_END

void CompareQualifiers(
    CIMRepository& r1,
    CIMRepository& r2,
    const CIMNamespaceName& namespaceName)
{
    Array<CIMQualifierDecl> quals1 = r1.enumerateQualifiers(namespaceName);
    Array<CIMQualifierDecl> quals2 = r2.enumerateQualifiers(namespaceName);
    PEGASUS_TEST_ASSERT(quals1.size() == quals2.size());

    BubbleSort(quals1);
    BubbleSort(quals2);

    for (Uint32 i = 0; i < quals2.size(); i++)
    {
        if (verbose)
        {
            cout << "testing qualifier " << namespaceName.getString() << "/";
            cout << quals1[i].getName().getString() << "/ against /";
            cout << quals2[i].getName().getString() << "/" << endl;
        }

        PEGASUS_TEST_ASSERT(quals1[i].identical(quals2[i]));
    }
}
开发者ID:brunolauze,项目名称:pegasus,代码行数:26,代码来源:CompareRepositories.cpp

示例10: _checkStringValue

void _checkStringValue (CIMValue & theValue,
    const String & value,
    Boolean null = false)
{
    PEGASUS_TEST_ASSERT (theValue.getType () == CIMTYPE_STRING);
    PEGASUS_TEST_ASSERT (!theValue.isArray ());
    if (null)
    {
        PEGASUS_TEST_ASSERT (theValue.isNull ());
    }
    else
    {
        PEGASUS_TEST_ASSERT (!theValue.isNull ());
        String result;
        theValue.get (result);

        if (verbose)
        {
            if (result != value)
            {
                cerr << "Property value comparison failed.  ";
                cerr << "Expected " << value << "; ";
                cerr << "Actual property value was " << result << "." << endl;
            }
        }

        PEGASUS_TEST_ASSERT (result == value);
    }
}
开发者ID:brunolauze,项目名称:pegasus,代码行数:29,代码来源:TestCMPIBroker.cpp

示例11: testInstancesTransfer

void testInstancesTransfer(
    CIMRepository& oldRepository,
    CIMRepository& newRepository,
    const CIMNamespaceName& ns,
    const CIMName& className)
{
    Array<CIMInstance> i1 =
        oldRepository.enumerateInstancesForClass(ns, className);
    Array<CIMInstance> i2 =
        newRepository.enumerateInstancesForClass(ns, className);

    PEGASUS_TEST_ASSERT(i1.size() == i2.size());

    for (Uint32 i = 0; i < i1.size(); i++)
    {
        Boolean found = false;

        for (Uint32 j = 0; j < i2.size(); j++)
        {
            if (i1[i].identical(i2[j]))
            {
                found = true;
                break;
            }
        }

        PEGASUS_TEST_ASSERT(found);
    }
}
开发者ID:brunolauze,项目名称:pegasus,代码行数:29,代码来源:UpgradeTest.cpp

示例12: PEGASUS_TEST_ASSERT

void
test_async_queue::async_handleEnqueue (AsyncOpNode * op,
                                       MessageQueue * q, void *parm)
{

  // I am static, get a pointer to my object 
  test_async_queue *myself = static_cast < test_async_queue * >(q);

  async_start *rq = static_cast < async_start * >(op->removeRequest());
  PEGASUS_TEST_ASSERT(rq != 0);

  async_complete *rp = static_cast < async_complete * >(op->removeResponse());
  PEGASUS_TEST_ASSERT(rp != 0);

  if ((rq->getType () == ASYNC_ASYNC_OP_START) &&
      (rp->getType () == ASYNC_ASYNC_OP_RESULT))
    {
      Message *cim_rq = rq->get_action ();
      Message *cim_rp = rp->get_result_data ();

      PEGASUS_TEST_ASSERT (cim_rq->getType () ==
                           CIM_GET_INSTANCE_REQUEST_MESSAGE);
      PEGASUS_TEST_ASSERT (cim_rp->getType () ==
                      CIM_GET_INSTANCE_RESPONSE_MESSAGE);
      test_async_queue::msg_count++;

      delete cim_rp;
      delete cim_rq;
      delete rp;
      delete rq;
      delete op;
    }
}
开发者ID:host1812,项目名称:scx_plugin_public,代码行数:33,代码来源:async_callback.cpp

示例13: PEGASUS_TEST_ASSERT

void _checkUint32Property
  (CIMInstance & instance, const String & name, Uint32 value)
{
  Uint32 pos = instance.findProperty (name);
  PEGASUS_TEST_ASSERT (pos != PEG_NOT_FOUND);

  CIMProperty theProperty = instance.getProperty (pos);
  CIMValue theValue = theProperty.getValue ();

  PEGASUS_TEST_ASSERT (theValue.getType () == CIMTYPE_UINT32);
  PEGASUS_TEST_ASSERT (!theValue.isArray ());
  PEGASUS_TEST_ASSERT (!theValue.isNull ());
  Uint32 result;
  theValue.get (result);

  if (verbose)
    {
      if (result != value)
        {
          cerr << "Property value comparison failed.  ";
          cerr << "Expected " << value << "; ";
          cerr << "Actual property value was " << result << "." << endl;
        }
    }

  PEGASUS_TEST_ASSERT (result == value);
}
开发者ID:brunolauze,项目名称:pegasus,代码行数:27,代码来源:TestCMPIInstanceExecQuery.cpp

示例14: _testHostedIndicationServiceInstance

void _testHostedIndicationServiceInstance(CIMClient &client)
{
    cout << "Testing Association Class "
        << (const char *)PEGASUS_CLASSNAME_PG_HOSTEDINDICATIONSERVICE.
             getString().getCString()
        << "...";
    // Get PG_HostedIndicationService Instances
    Array<CIMInstance> hostedInstances = client.enumerateInstances(
        PEGASUS_NAMESPACENAME_INTEROP,
        PEGASUS_CLASSNAME_PG_HOSTEDINDICATIONSERVICE);
    PEGASUS_TEST_ASSERT(hostedInstances.size() == 1);

    // Get PG_HostedIndicationService Instance names
    Array<CIMObjectPath> hostedPaths = client.enumerateInstanceNames(
        PEGASUS_NAMESPACENAME_INTEROP,
        PEGASUS_CLASSNAME_PG_HOSTEDINDICATIONSERVICE);
    PEGASUS_TEST_ASSERT(hostedPaths.size() == 1);

    // Get CIM_IndicationService instance names
    Array<CIMObjectPath> servicePaths = client.enumerateInstanceNames(
        PEGASUS_NAMESPACENAME_INTEROP,
        PEGASUS_CLASSNAME_CIM_INDICATIONSERVICE);
    PEGASUS_TEST_ASSERT(servicePaths.size() == 1);

    // Test the CIM_IndicationService value.
    CIMValue capValue = hostedInstances[0].getProperty(
        hostedInstances[0].findProperty("Dependent")).getValue();
    CIMObjectPath testPath;
    capValue.get(testPath);
    testPath.setNameSpace(CIMNamespaceName());
    PEGASUS_TEST_ASSERT(testPath.identical(servicePaths[0]));

    cout << "Test Complete" << endl;
}
开发者ID:brunolauze,项目名称:pegasus,代码行数:34,代码来源:ServerProfile.cpp

示例15: drive_Schema

void drive_Schema(QueryContext& _query)
{
    CIMName base("CQL_TestElement");
    CIMClass _class = _query.getClass(base);
    PEGASUS_TEST_ASSERT(_class.getClassName() == base);

    Array<CIMName> names = _query.enumerateClassNames(base);
    PEGASUS_TEST_ASSERT(names.size() == 2);

    CIMName derived("CQL_TestPropertyTypes");

    PEGASUS_TEST_ASSERT(_query.isSubClass(base, derived));
    PEGASUS_TEST_ASSERT(!_query.isSubClass(derived, base));

    PEGASUS_TEST_ASSERT(
        _query.getClassRelation(base, base) == QueryContext::SAMECLASS);
    PEGASUS_TEST_ASSERT(
        _query.getClassRelation(base, derived) == QueryContext::SUBCLASS);
    PEGASUS_TEST_ASSERT(
        _query.getClassRelation(derived, base) == QueryContext::SUPERCLASS);

    CIMName unrelated("CIM_Process");
    PEGASUS_TEST_ASSERT(
        _query.getClassRelation(base, unrelated) == QueryContext::NOTRELATED);
    PEGASUS_TEST_ASSERT(
        _query.getClassRelation(unrelated, base) == QueryContext::NOTRELATED);
}
开发者ID:host1812,项目名称:scx_plugin_public,代码行数:27,代码来源:TestQueryContext.cpp


注:本文中的PEGASUS_TEST_ASSERT函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。