void test_locate() { CharArray* c = String::create(state, "xyZfoo\nzyx")->data(); Fixnum* size = Fixnum::from(c->size()); Fixnum* zero = Fixnum::from(0); Fixnum* three = Fixnum::from(3); Fixnum* seven = Fixnum::from(7); Fixnum* four = Fixnum::from(4); Fixnum* two = Fixnum::from(2); String* foo_nl = String::create(state, "foo\n"); TS_ASSERT_EQUALS(three, (Fixnum*)c->locate(state, String::create(state, ""), three, size)); TS_ASSERT_EQUALS(Qnil, c->locate(state, String::create(state, "\n\n"), zero, size)); TS_ASSERT_EQUALS(seven, (Fixnum*)c->locate(state, String::create(state, "\n"), zero, size)); TS_ASSERT_EQUALS(Qnil, c->locate(state, foo_nl, four, size)); TS_ASSERT_EQUALS(seven, (Fixnum*)c->locate(state, foo_nl, two, size)); TS_ASSERT_EQUALS(seven, (Fixnum*)c->locate(state, foo_nl, three, size)); TS_ASSERT_EQUALS(Fixnum::from(10), (Fixnum*)c->locate(state, String::create(state, "yx"), three, size)); }