LONGBOW_TEST_CASE(Object, parcFutureTask_HashCode)
{
    PARCFutureTask *x = parcFutureTask_Create(_function, _function);
    PARCFutureTask *y = parcFutureTask_Create(_function, _function);
    
    parcObjectTesting_AssertHashCode(x, y);
    
    parcFutureTask_Release(&x);
    parcFutureTask_Release(&y);
}
LONGBOW_TEST_CASE(Object, parcFutureTask_Equals)
{
    PARCFutureTask *x = parcFutureTask_Create(_function, _function);
    PARCFutureTask *y = parcFutureTask_Create(_function, _function);
    PARCFutureTask *z = parcFutureTask_Create(_function, _function);
    PARCFutureTask *u1 = parcFutureTask_Create(_function, NULL);

    parcObjectTesting_AssertEquals(x, y, z, u1, NULL);

    parcFutureTask_Release(&x);
    parcFutureTask_Release(&y);
    parcFutureTask_Release(&z);
    parcFutureTask_Release(&u1);
}
LONGBOW_TEST_CASE(Specialization, parcFutureTask_Cancel)
{
    PARCFutureTask *task = parcFutureTask_Create(_function, _function);

    bool parcFutureTask_Cancel(PARCFutureTask *task, bool mayInterruptIfRunning);

    parcFutureTask_Release(&task);
}
LONGBOW_TEST_CASE(Object, parcFutureTask_IsValid)
{
    PARCFutureTask *instance = parcFutureTask_Create(_function, _function);
    assertTrue(parcFutureTask_IsValid(instance), "Expected parcFutureTask_Create to result in a valid instance.");
    
    parcFutureTask_Release(&instance);
    assertFalse(parcFutureTask_IsValid(instance), "Expected parcFutureTask_Release to result in an invalid instance.");
}
LONGBOW_TEST_CASE(Specialization, parcFutureTask_IsCancelled)
{
    PARCFutureTask *task = parcFutureTask_Create(_function, _function);

    bool actual = parcFutureTask_IsCancelled(task);
    assertFalse(actual, "Expected true.");
    
    parcFutureTask_Release(&task);
}
LONGBOW_TEST_CASE(Object, parcFutureTask_Copy)
{
    PARCFutureTask *instance = parcFutureTask_Create(_function, _function);
    PARCFutureTask *copy = parcFutureTask_Copy(instance);
    assertTrue(parcFutureTask_Equals(instance, copy), "Expected the copy to be equal to the original");

    parcFutureTask_Release(&instance);
    parcFutureTask_Release(&copy);
}
LONGBOW_TEST_CASE(CreateAcquireRelease, CreateRelease)
{
    PARCFutureTask *instance = parcFutureTask_Create(_function, _function);
    assertNotNull(instance, "Expected non-null result from parcFutureTask_Create(_function, _function);");

    parcObjectTesting_AssertAcquireReleaseContract(parcFutureTask_Acquire, instance);
    
    parcFutureTask_Release(&instance);
    assertNull(instance, "Expected null result from parcFutureTask_Release();");
}
LONGBOW_TEST_CASE(Specialization, parcFutureTask_RunAndReset)
{
    PARCFutureTask *task = parcFutureTask_Create(_function, _function);

    bool actual = parcFutureTask_RunAndReset(task);
    
    assertTrue(actual, "Expectd parcFutureTask_RunAndReset to return true.");
    assertFalse(parcFutureTask_IsDone(task), "Expected parcFutureTask_IsDone to be false");
    parcFutureTask_Release(&task);
}
LONGBOW_TEST_CASE(Specialization, parcFutureTask_Get)
{
    PARCFutureTask *task = parcFutureTask_Create(_function, _function);

    PARCFutureTaskResult result = parcFutureTask_Get(task, PARCTimeout_Immediate);
    
    assertTrue(parcExecution_Is(result.execution, PARCExecution_Timeout), "Expected Timeout, actual %s",
               parcExecution_GetMessage(result.execution));
    parcFutureTask_Release(&task);
}
示例#10
0
LONGBOW_TEST_CASE(Object, parcFutureTask_ToJSON)
{
    PARCFutureTask *instance = parcFutureTask_Create(_function, _function);
    
    PARCJSON *json = parcFutureTask_ToJSON(instance);

    parcJSON_Release(&json);

    parcFutureTask_Release(&instance);
}
示例#11
0
LONGBOW_TEST_CASE(Object, parcFutureTask_ToString)
{
    PARCFutureTask *instance = parcFutureTask_Create(_function, _function);
    
    char *string = parcFutureTask_ToString(instance);
    
    assertNotNull(string, "Expected non-NULL result from parcFutureTask_ToString");
    
    parcMemory_Deallocate((void **) &string);
    parcFutureTask_Release(&instance);
}
示例#12
0
LONGBOW_TEST_CASE(Specialization, parcFutureTask_Run)
{
    PARCFutureTask *task = parcFutureTask_Create(_function, _function);

    parcFutureTask_Run(task);
    
    PARCFutureTaskResult actual = parcFutureTask_Get(task, PARCTimeout_Immediate);
    
    assertTrue(parcFutureTask_IsDone(task), "Expected parcFutureTask_IsDone to be true.");
    assertTrue(parcExecution_Is(actual.execution, PARCExecution_OK),
               "Expected OK, actual %s", parcExecution_GetMessage(actual.execution));
    assertTrue(actual.value == _function, "Expected actual to point to _function");
    parcFutureTask_Release(&task);
}
示例#13
0
LONGBOW_TEST_CASE(Object, parcThreadPool_Execute)
{
    dprintf(1, "-----\n");
    PARCThreadPool *pool = parcThreadPool_Create(6);

    PARCFutureTask *task = parcFutureTask_Create(_function, _function);
    parcThreadPool_Execute(pool, task);
    parcThreadPool_Execute(pool, task);
    parcThreadPool_Execute(pool, task);
    parcThreadPool_Execute(pool, task);
    parcThreadPool_Execute(pool, task);
    parcFutureTask_Release(&task);
   
    parcThreadPool_Shutdown(pool);
    bool shutdownSuccess = parcThreadPool_AwaitTermination(pool, PARCTimeout_Never);
   
    assertTrue(shutdownSuccess, "parcThreadPool_AwaitTermination timed-out");
   
    uint64_t count = parcThreadPool_GetCompletedTaskCount(pool);
    assertTrue(count == 5, "Expected 5, actual %lld", count);
   
   
    parcThreadPool_Release(&pool);
}
示例#14
0
LONGBOW_TEST_CASE(Object, parcFutureTask_Display)
{
    PARCFutureTask *instance = parcFutureTask_Create(_function, _function);
    parcFutureTask_Display(instance, 0);
    parcFutureTask_Release(&instance);
}