/* 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)); }
/* 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); }
/* 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); }
/* Description: Attempt to check hasNext for a NULL iterator. * * Expected Result: Zero return for hasNext */ TEST_F (MsgNewIteratorTestC, DISABLED_IteratorHasNextNullIter) { mama_bool_t hasNext = 0; /* Check if we have a next value: */ hasNext = mamaMsgIterator_hasNext (NULL); ASSERT_EQ (0, hasNext); }
/* 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_u8_t content = 0; mama_bool_t hasNext = 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); /* Ensure we return the first field again: */ ASSERT_EQ (101, fid); ASSERT_EQ (8, 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_getString (field, &strContent); /* Ensure we return the first field again: */ ASSERT_EQ (102, fid); ASSERT_STREQ ("This is an iteration test.", strContent); }