Sha256: 94dd77b2cf6cb1957aa2e578fdcc75f17c98a0a1e1510acde2551f3b646c2bdb

Contents?: true

Size: 905 Bytes

Versions: 5

Compression:

Stored size: 905 Bytes

Contents

#include "unittest.hpp"
#include "embed_ruby.hpp"
#include <rice/rice.hpp>

using namespace Rice;

TESTSUITE(Memory_Management);

SETUP(Memory_Management)
{
  embed_ruby();
}

namespace
{
  class TestClass {
    double tmp;
    public:
      TestClass() {tmp=0;}

      double getTmp() {
        return tmp;
      }

      void setTmp(double x) {
        tmp = x;
      }
  };

  TestClass returnTestClass() {
    TestClass x = TestClass();
    x.setTmp(8);
    return x;
  }
}

TESTCASE(allows_copy_contructors_to_work)
{
  define_class<TestClass>("TestClass")
    .define_method("tmp=", &TestClass::setTmp)
    .define_method("tmp", &TestClass::getTmp);

  define_global_function("return_test_class", &returnTestClass);

  Module m = define_module("TestingModule");

  Object result = m.instance_eval("return_test_class.tmp");
  ASSERT_EQUAL(8.0, detail::From_Ruby<double>().convert(result.value()));
}

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rice-4.0.4 test/test_Memory_Management.cpp
rice-4.0.3 test/test_Memory_Management.cpp
rice-4.0.2 test/test_Memory_Management.cpp
rice-4.0.1 test/test_Memory_Management.cpp
rice-4.0.0 test/test_Memory_Management.cpp