Sha256: 213891e4029e88cc08d62f9f842e59151a8089aec46599c895028e1c564eeda8

Contents?: true

Size: 1.56 KB

Versions: 21

Compression:

Stored size: 1.56 KB

Contents

#include "unittest.hpp"
#include "rice/Builtin_Object.hpp"
#include "rice/Class.hpp"

using namespace Rice;

TESTSUITE(Builtin_Object);

SETUP(Builtin_Object)
{
  ruby_init();
}

TESTCASE(construct_with_object)
{
  Class c(rb_cObject);
  Object o(c.call("new"));
  Builtin_Object<RObject, T_OBJECT> b(o);
  ASSERT_EQUAL(o.value(), b.value());
  ASSERT_EQUAL(T_OBJECT, rb_type(b.value()));
  ASSERT_EQUAL(rb_cObject, b.class_of().value());
  ASSERT_EQUAL(rb_cObject, CLASS_OF(b.value()));
}

TESTCASE(copy_construct)
{
  Class c(rb_cObject);
  Object o(c.call("new"));
  Builtin_Object<RObject, T_OBJECT> b(o);
  Builtin_Object<RObject, T_OBJECT> b2(b);
  ASSERT_EQUAL(o.value(), b2.value());
  ASSERT_EQUAL(T_OBJECT, rb_type(b2.value()));
  ASSERT_EQUAL(rb_cObject, b2.class_of().value());
  ASSERT_EQUAL(rb_cObject, CLASS_OF(b2.value()));
}

TESTCASE(dereference)
{
  Class c(rb_cObject);
  Object o(c.call("new"));
  Builtin_Object<RObject, T_OBJECT> b(o);
  ASSERT_EQUAL(ROBJECT(o.value()), &*b);
}

TESTCASE(arrow)
{
  Class c(rb_cObject);
  Object o(c.call("new"));
  Builtin_Object<RObject, T_OBJECT> b(o);
  ASSERT_EQUAL(rb_cObject, b->basic.klass);
}

TESTCASE(get)
{
  Class c(rb_cObject);
  Object o(c.call("new"));
  Builtin_Object<RObject, T_OBJECT> b(o);
  ASSERT_EQUAL(ROBJECT(o.value()), b.get());
}

TESTCASE(swap)
{
  Class c(rb_cObject);
  Object o1(c.call("new"));
  Builtin_Object<RObject, T_OBJECT> b1(o1);
  Object o2(c.call("new"));
  Builtin_Object<RObject, T_OBJECT> b2(o2);
  b1.swap(b2);
  ASSERT_EQUAL(b1.value(), o2.value());
  ASSERT_EQUAL(b2.value(), o1.value());
}

Version data entries

21 entries across 21 versions & 5 rubygems

Version Path
jameskilton-rice-1.2.0 test/test_Builtin_Object.cpp
keyme-rice-1.5.1.keyme1 test/test_Builtin_Object.cpp
keyme-rice-1.5.1.keyme test/test_Builtin_Object.cpp
rice-1.5.1 test/test_Builtin_Object.cpp
rice-1.5.0 test/test_Builtin_Object.cpp
rice-jdguyot-1.4.3p1 test/test_Builtin_Object.cpp
rice-1.4.3 test/test_Builtin_Object.cpp
wurlinc-rice-1.4.0.4 test/test_Builtin_Object.cpp
wurlinc-rice-1.4.0.1 test/test_Builtin_Object.cpp
rice-1.4.2 test/test_Builtin_Object.cpp
rice-jdguyot-1.4.0.p1 test/test_Builtin_Object.cpp
rice-jdguyot-1.4.0 test/test_Builtin_Object.cpp
rice-1.4.0 test/test_Builtin_Object.cpp
rice-1.3.2 test/test_Builtin_Object.cpp
rice-1.3.1 test/test_Builtin_Object.cpp
rice-1.3.0 test/test_Builtin_Object.cpp
rice-1.2.0 test/test_Builtin_Object.cpp
rice-1.0.2 test/test_Builtin_Object.cpp
rice-1.0.0 test/test_Builtin_Object.cpp
rice-1.0.1 test/test_Builtin_Object.cpp