Exemplo n.º 1
0
  void test_move_bytes_out_of_bounds() {
    CharArray* c = String::create(state, "xyzzy")->data();

    Fixnum* neg = Fixnum::from(-1);
    Fixnum* one = Fixnum::from(1);
    Fixnum* zero = Fixnum::from(0);
    Fixnum* size = c->size(state);

    TS_ASSERT_THROWS_ASSERT(c->move_bytes(state, neg, zero, zero), const RubyException &e,
        TS_ASSERT(Exception::object_bounds_exceeded_error_p(state, e.exception)));
    TS_ASSERT_THROWS_ASSERT(c->move_bytes(state, zero, neg, zero), const RubyException &e,
        TS_ASSERT(Exception::object_bounds_exceeded_error_p(state, e.exception)));
    TS_ASSERT_THROWS_ASSERT(c->move_bytes(state, zero, zero, neg), const RubyException &e,
        TS_ASSERT(Exception::object_bounds_exceeded_error_p(state, e.exception)));

    TS_ASSERT_THROWS_ASSERT(c->move_bytes(state, zero, size, one), const RubyException &e,
        TS_ASSERT(Exception::object_bounds_exceeded_error_p(state, e.exception)));
    TS_ASSERT_THROWS_ASSERT(c->move_bytes(state, one, size, zero), const RubyException &e,
        TS_ASSERT(Exception::object_bounds_exceeded_error_p(state, e.exception)));
  }
Exemplo n.º 2
0
 void test_move_bytes() {
   String* s = String::create(state, "xyzzy");
   CharArray* c = s->data();
   c->move_bytes(state, Fixnum::from(0), Fixnum::from(2), Fixnum::from(3));
   TS_ASSERT_SAME_DATA(c->raw_bytes(), "xyzxy", 5);
 }