DEFINE_CLASS_NAME("test_hash_table");
int raw_random_id(); //!< returns an unvetted random number.
- int unused_random_id(); //!< returns an unused (so far) random number.
+
+ //! returns an unused (so far) random number.
+ int unused_random_id();
int execute();
// the main startup for the test.
int checking = raw_random_id();
if (!_keys_in_use.member(checking)) return checking; // got one.
} // keep going until we find unused id.
+ return -1; // this is a failure, but we will never get here.
}
int test_hash_table::execute()
to_add->snacky_string = string_manipulation::make_random_name();
to_add->food_bar = random_id;
outcome expected = common::IS_NEW;
- if (_keys_in_use.member(random_id)) return common::EXISTING;
+ // make sure it doesn't exist already.
+ if (_keys_in_use.member(random_id)) return false;
ASSERT_EQUAL(_the_table.add(random_id, to_add).value(), expected.value(),
"add should give proper outcome based on expectation");
if (_keys_in_use.member(random_id))
//////////////
-hash_table<int, data_shuttle> *_hang_on = NIL;
+hash_table<int, data_shuttle> *_hang_on = NULL_POINTER;
// must be set before calling the apply method.
#undef UNIT_BASE_THIS_OBJECT
_hits[FIND - FIRST_TEST]++;
int rand_indy = randomizer().inclusive(0, _keys_in_use.elements() - 1);
int find_key = _keys_in_use[rand_indy];
- data_shuttle *found = NIL;
+ data_shuttle *found = NULL_POINTER;
ASSERT_TRUE(_the_table.find(find_key, found), "key should be there as expected");
- ASSERT_NON_NULL(found, "contents should not be NIL");
+ ASSERT_NON_NULL(found, "contents should not be null");
ASSERT_EQUAL(found->food_bar, find_key, "stored key should be same as real key");
ASSERT_TRUE(found->snacky_string.length(), "stored string should have length");
return true;
int rand_indy = randomizer().inclusive(0, _keys_in_use.elements() - 1);
// this is another key list invariant function, if it works.
int find_key = _keys_in_use[rand_indy];
- data_shuttle *found = NIL;
+ data_shuttle *found = NULL_POINTER;
ASSERT_TRUE(_the_table.find(find_key, found), "key should be locateable");
- ASSERT_NON_NULL(found, "key should not have NIL contents");
+ ASSERT_NON_NULL(found, "key should not have null contents");
ASSERT_EQUAL(found->food_bar, find_key, "stored key should be equal to real key");
ASSERT_TRUE(found->snacky_string.length(), "stored string should not have zero length");
// zap.
HOOPLE_MAIN(test_hash_table, )
+