Ejemplo n.º 1
0
  void test_find_entry() {
    Object* k = Fixnum::from(47);
    tbl->store(state, k, cTrue);

    LookupTableBucket* entry = tbl->find_entry(state, k);
    TS_ASSERT(!entry->nil_p());
    TS_ASSERT_EQUALS(entry->key(),k);
    TS_ASSERT_EQUALS(entry->value(),cTrue);

    entry = tbl->find_entry(state, Fixnum::from(40));
    TS_ASSERT(entry->nil_p());
  }
Ejemplo n.º 2
0
  void test_store_handles_entries_in_same_bin() {
    Object* k1 = Fixnum::from((4 << 4)  | 15);
    Object* k2 = Fixnum::from((10 << 4) | 15);
    Object* k3 = Fixnum::from((11 << 4) | 15);
    Object* v1 = cTrue;
    Object* v2 = cFalse;
    Object* v3 = cTrue;

    tbl->store(state, k1, v1);
    tbl->store(state, k2, v2);
    tbl->store(state, k3, v3);
    TS_ASSERT_EQUALS(as<Integer>(tbl->entries())->to_native(), 3);

    LookupTableBucket* entry = tbl->find_entry(state, k1);
    TS_ASSERT(!entry->nil_p());

    TS_ASSERT(!entry->next()->nil_p());
    TS_ASSERT_EQUALS(entry->next()->key(), k2);

    entry = tbl->find_entry(state, k3);
    TS_ASSERT(!entry->nil_p());
    TS_ASSERT_EQUALS(entry->key(), k3);
  }