test/fiber/test_fiber_scheduler_from_fiber_get.cpp
TEST(get_scheduler)
{
    allocator* alloc = nullptr;
    fiber_scheduler* sched = nullptr;
    fiber* f = nullptr;

    /* we should be able to create a malloc allocator. */
    TEST_ASSERT(
        STATUS_SUCCESS == malloc_allocator_create(&alloc));

    /* we should be able to create a disciplined fiber scheduler. */
    TEST_ASSERT(
        STATUS_SUCCESS ==
            fiber_scheduler_create_with_disciplines(&sched, alloc));

    /* we should be able to create a fiber for a thread. */
    TEST_ASSERT(STATUS_SUCCESS == fiber_create_for_thread(&f, sched, alloc));

    /* we should be able to get the fiber scheduler for this fiber. */
    TEST_EXPECT(sched == fiber_scheduler_from_fiber_get(f));

    /* we should be able to release the fiber instance. */
    TEST_ASSERT(
        STATUS_SUCCESS ==
            resource_release(fiber_resource_handle(f)));

    /* clean up. */
    TEST_ASSERT(
        STATUS_SUCCESS ==
            resource_release(fiber_scheduler_resource_handle(sched)));
    TEST_ASSERT(
        STATUS_SUCCESS == resource_release(allocator_resource_handle(alloc)));
}
/**
 * Verify that we can get the fiber scheduler assigned to a fiber.
 */
Verify that we can get the fiber scheduler assigned to a fiber.
Verify that we can get the fiber scheduler assigned to a fiber .
TEST(get_scheduler)
{
    allocator* alloc = nullptr;
    fiber_scheduler* sched = nullptr;
    fiber* f = nullptr;
    TEST_ASSERT(
        STATUS_SUCCESS == malloc_allocator_create(&alloc));
    TEST_ASSERT(
        STATUS_SUCCESS ==
            fiber_scheduler_create_with_disciplines(&sched, alloc));
    TEST_ASSERT(STATUS_SUCCESS == fiber_create_for_thread(&f, sched, alloc));
    TEST_EXPECT(sched == fiber_scheduler_from_fiber_get(f));
    TEST_ASSERT(
        STATUS_SUCCESS ==
            resource_release(fiber_resource_handle(f)));
    TEST_ASSERT(
        STATUS_SUCCESS ==
            resource_release(fiber_scheduler_resource_handle(sched)));
    TEST_ASSERT(
        STATUS_SUCCESS == resource_release(allocator_resource_handle(alloc)));
}
TEST ( get_scheduler ) { allocator * alloc = nullptr ; fiber_scheduler * sched = nullptr ; fiber * f = nullptr ; TEST_ASSERT ( STATUS_SUCCESS == malloc_allocator_create ( & alloc ) ) ; TEST_ASSERT ( STATUS_SUCCESS == fiber_scheduler_create_with_disciplines ( & sched , alloc ) ) ; TEST_ASSERT ( STATUS_SUCCESS == fiber_create_for_thread ( & f , sched , alloc ) ) ; TEST_EXPECT ( sched == fiber_scheduler_from_fiber_get ( f ) ) ; TEST_ASSERT ( STATUS_SUCCESS == resource_release ( fiber_resource_handle ( f ) ) ) ; TEST_ASSERT ( STATUS_SUCCESS == resource_release ( fiber_scheduler_resource_handle ( sched ) ) ) ; TEST_ASSERT ( STATUS_SUCCESS == resource_release ( allocator_resource_handle ( alloc ) ) ) ; }
Verify that we can get the fiber scheduler assigned to a fiber.
Verify that we can get the fiber scheduler assigned to a fiber .
/* we should be able to create a malloc allocator. */ /* we should be able to create a disciplined fiber scheduler. */ /* we should be able to create a fiber for a thread. */ /* we should be able to get the fiber scheduler for this fiber. */ /* we should be able to release the fiber instance. */ /* clean up. */