/** @todo Is it a valid assumption that the position always increases? */ void test_control_tells_current_position() { char *dir = make_directory(); String* path = String::create(state, dir); d->open(state, path); Fixnum* pos = (Fixnum*)d->control(state, Fixnum::from(2), Fixnum::from(0)); d->read(state); Fixnum* pos2 = (Fixnum*)d->control(state, Fixnum::from(2), Fixnum::from(0)); TS_ASSERT_LESS_THAN(pos->to_native(), pos2->to_native()); remove_directory(dir); }
void test_control_seeks_to_a_known_position() { char *dir = make_directory(); String* path = String::create(state, dir); d->open(state, path); d->read(state); Fixnum* pos = (Fixnum*)d->control(state, Fixnum::from(2), Fixnum::from(0)); String* first = as<String>(d->read(state)); d->control(state, Fixnum::from(0), pos); String* second = as<String>(d->read(state)); TS_ASSERT_EQUALS(first->size(), second->size()); TS_ASSERT_SAME_DATA(first, second, first->size()); remove_directory(dir); }
void test_control_rewinds_read_location() { char *dir = make_directory(); String* path = String::create(state, dir); d->open(state, path); d->read(state); d->read(state); TS_ASSERT(d->read(state)->nil_p()); d->control(state, Fixnum::from(1), Fixnum::from(0)); String* name = as<String>(d->read(state)); TS_ASSERT_EQUALS(name->c_str()[0], '.'); remove_directory(dir); }