/** * test put same keys into Btree,these keys have same content and same address */ TEST(KeyBtree_Put_Char_Test, put_06_sameaddresskey) { int32_t iRet = 0; int32_t iValue = 0; int32_t iSuccess = 0; int32_t iFail = 0; //int32_t iGet = -1; charBtree btree( MAX_SIZE ); get_next_random_value(iValue); char * key = (char *)malloc( TEST_SIZE ); sprintf( key, "%08x", iValue); for (int32_t iLoop = 0; iLoop < TEST_COUNT; iLoop ++) { /* Put the key-value pair */ iRet = btree.put( key, iLoop + 1 ); if (((iRet == ERROR_CODE_OK) && (iLoop == 0)) || (iRet == ERROR_CODE_KEY_REPEAT)) { iSuccess ++; } else { iFail ++; } } free(key); EXPECT_EQ( iFail, 0); EXPECT_EQ( iSuccess, TEST_COUNT ); EXPECT_EQ( 1, btree.get_object_count() ); btree.clear(); }
/** *test put long keys into Btree */ TEST(KeyBtree_Put_Char_Test, put_07_longkey) { set_up(); int32_t iRet = 0; int32_t iValue = 0; int32_t iSuccess = 0; int32_t iFail = 0; charBtree btree(sizeof(char*)); for (int32_t iLoop = 0; iLoop < TEST_COUNT; iLoop ++) { /* malloc */ pstrKey[ iLoop ] = (char *)malloc( TEST_SIZE ); /* Set the flag for free */ iFlag = 1; /* Create the key */ get_next_random_value( iValue ); sprintf( pstrKey[ iLoop ], "%08x", iValue ); /* Put the key-value pair */ iRet = btree.put( pstrKey[ iLoop ], iLoop + 1 ); if (iRet == ERROR_CODE_OK) { iSuccess ++; } else { iFail ++; } } EXPECT_EQ( iFail, 0 ); EXPECT_EQ( iSuccess, btree.get_object_count() ); tear_down(); btree.clear(); }
DR_EXPORT drmf_status_t drfuzz_mutator_get_next_value(drfuzz_mutator_t *mutator_in, IN void *buffer) { mutator_t *mutator = (mutator_t *) mutator_in; drmf_status_t res; switch (mutator->options.alg) { case MUTATOR_ALG_RANDOM: res = get_next_random_value(mutator, buffer); break; case MUTATOR_ALG_ORDERED: res = get_next_ordered_value(mutator, buffer); break; default: return DRMF_ERROR; } if (res == DRMF_SUCCESS) memcpy(mutator->current_value, buffer, mutator->size); return res; }