Example #1
0
/*  Description:     Step to the end of the message, check if it has a next,
 *                   expecting that it does not.
 *
 *  Expected Result: Zero return for hasNext
 */
TEST_F (MsgNewIteratorTestC, IteratorHasNoNext)
{
    mama_fid_t      fid      = 0;
    mama_u64_t      content  = 0;

    field = mamaMsgIterator_begin (iterator);

    mamaMsgField_getFid (field, &fid);
    mamaMsgField_getU64 (field, &content);

    /* Check the contents of the field: */
    ASSERT_EQ(values[fid], content);

    field = mamaMsgIterator_next (iterator);

    /* Ensure we return the first field again: */
    ASSERT_EQ(values[fid], content);

    /* Move to the last message: */
    field = mamaMsgIterator_next (iterator);
    field = mamaMsgIterator_next (iterator);
    field = mamaMsgIterator_next (iterator);
    field = mamaMsgIterator_next (iterator);

    /* Move past last message - should not crash */
    field = mamaMsgIterator_next (iterator);
    ASSERT_EQ(NULL, field);

    /* Check if we have a next value: */
    ASSERT_EQ (0, mamaMsgIterator_hasNext (iterator));
}
Example #2
0
/*  Description:     Check that when passed a NULL iterator, begin returns a NULL
 *                   field.
 *
 *  Expected Result: NULL field.
 */
TEST_F (MsgNewIteratorTestC, DISABLED_IteratorBeginNullIter)
{
    field = mamaMsgIterator_begin (NULL);

    /* Check the contents of the field: */
    ASSERT_EQ (NULL, field);
}
Example #3
0
/*  Description:     Step into the message, determine if it has a next value, 
 *                   retrieve and check the contents of that value.
 *
 *  Expected Result: Non-zero return for hasNext
 */
TEST_F (MsgNewIteratorTestC, IteratorHasNext)
{
    mama_fid_t      fid      = 0;
    mama_u64_t      content  = 0;
    mama_bool_t     hasNext  = 0;

    field = mamaMsgIterator_begin (iterator);

    mamaMsgField_getFid (field, &fid);
    mamaMsgField_getU64 (field, &content);

    /* Check the contents of the field: */
    ASSERT_EQ(values[fid], content);

    field = mamaMsgIterator_next (iterator);

    /* Ensure we return the first field again: */
    ASSERT_EQ(values[fid], content);

    /* Check if we have a next value: */
    hasNext = mamaMsgIterator_hasNext (iterator);

    ASSERT_NE (0, hasNext);

    /* Get the next value */
    field = mamaMsgIterator_next (iterator);
    mamaMsgField_getFid (field, &fid);
    mamaMsgField_getU64 (field, &content);

    /* Ensure we return the first field again: */
    ASSERT_EQ(values[fid], content);
}
Example #4
0
/*  Description:     Step to the end of the message, check if it has a next,
 *                   expecting that it does not.
 *
 *  Expected Result: Zero return for hasNext
 */
TEST_F (MsgNewIteratorTestC, IteratorHasNoNext)
{
    mama_fid_t      fid      = 0;
    mama_u8_t       content  = 0;
    mama_bool_t     hasNext  = 0;

    field = mamaMsgIterator_begin (iterator);

    mamaMsgField_getFid (field, &fid);
    mamaMsgField_getU8 (field, &content);

    /* Check the contents of the field: */
    ASSERT_EQ (101, fid);
    ASSERT_EQ (8, content);

    field = mamaMsgIterator_next (iterator);

    /* Ensure we return the first field again: */
    ASSERT_EQ (101, fid);
    ASSERT_EQ (8, content);

    /* Move to the last message: */
    field = mamaMsgIterator_next (iterator);
    field = mamaMsgIterator_next (iterator);
    field = mamaMsgIterator_next (iterator);
    field = mamaMsgIterator_next (iterator);

    /* Check if we have a next value: */
    hasNext = mamaMsgIterator_hasNext (iterator);

    ASSERT_EQ (0, hasNext);
}
Example #5
0
/*  Description:     Call begin, check that the first field is returned, then
 *                   call next, and check that the first field is returned again,
 *                   then call next again, and ensure that the second field is
 *                   returned.
 *
 *  Expected Result: First  Check: fid - 101, value - 8
 *                   Second Check: fid - 101, value - 8
 *                   Third  Check: fid - 102, value - "This is an iteration test."
 */
TEST_F (MsgNewIteratorTestC, IteratorBeginNext)
{
    mama_fid_t      fid      = 0;
    mama_u8_t       content  = 0;
    const char*     strContent;

    field = mamaMsgIterator_begin (iterator);

    mamaMsgField_getFid (field, &fid);
    mamaMsgField_getU8 (field, &content);

    /* Check the contents of the field: */
    ASSERT_EQ (101, fid);
    ASSERT_EQ (8, content);

    field = mamaMsgIterator_next (iterator);

    mamaMsgField_getFid (field, &fid);
    mamaMsgField_getU8 (field, &content);

    /* Ensure we return the first field again: */
    ASSERT_EQ (101, fid);
    ASSERT_EQ (8, content);

    field = mamaMsgIterator_next (iterator);

    mamaMsgField_getFid      (field, &fid);
    mamaMsgField_getString   (field, &strContent);

    /* Ensure we return the first field again: */
    ASSERT_EQ (102, fid);
    ASSERT_STREQ ("This is an iteration test.", strContent);
}
Example #6
0
/*  Description:     Call begin on the already associated mamaMsgIterator, and
 *                   check that the contents of the first field are returned.
 *
 *  Expected Result: Fid should be 101, value should be 8.
 */
TEST_F (MsgNewIteratorTestC, IteratorBegin)
{
    mama_fid_t      fid      = 0;
    mama_u64_t      content  = 0;

    field = mamaMsgIterator_begin (iterator);

    mamaMsgField_getFid (field, &fid);
    mamaMsgField_getU64 (field, &content);

    /* Check the contents of the field: */
    ASSERT_EQ(values.at(fid), content);
}
Example #7
0
/*  Description:     Call begin on the already associated mamaMsgIterator, and
 *                   check that the contents of the first field are returned.
 *
 *  Expected Result: Fid should be 101, value should be 8.
 */
TEST_F (MsgNewIteratorTestC, IteratorBegin)
{
    mama_fid_t      fid      = 0;
    mama_u8_t       content  = 0;

    field = mamaMsgIterator_begin (iterator);

    mamaMsgField_getFid (field, &fid);
    mamaMsgField_getU8  (field, &content);

    /* Check the contents of the field: */
    ASSERT_EQ (101, fid);
    ASSERT_EQ (8, content);
}
Example #8
0
/*  Description:     Call begin, check that the first field is returned, then
 *                   call next, and check that the first field is returned again,
 *                   then call next again, until all fields are confirmed.
 */
TEST_F (MsgNewIteratorTestC, IteratorBeginNext)
{
    mama_fid_t      fid      = 0;
    mama_u64_t      content  = 0;

    field = mamaMsgIterator_begin (iterator);

    mamaMsgField_getFid (field, &fid);
    mamaMsgField_getU64 (field, &content);

    /* Check the contents of the field match legal entry */
    ASSERT_EQ(values.at(fid), content);

    field = mamaMsgIterator_next (iterator);

    mamaMsgField_getFid (field, &fid);

    /* Ensure we return the first field again: */
    ASSERT_EQ(values[fid], content);

    /* Remove from reference map */
    values.erase(fid);

    /* For the 4 remaining fields, check contents */
    for (int i = 0; i < 4; i++)
    {
        field = mamaMsgIterator_next (iterator);
        mamaMsgField_getFid (field, &fid);
        mamaMsgField_getU64 (field, &content);
        ASSERT_EQ(values[fid], content);
        /* Remove from reference map */
        values.erase(fid);
    }

    /* Gotta catch 'em all */
    EXPECT_EQ(0, values.size());
}