Sha256: afa5b6dc9c9233878388b956e737a0ee20f9200ba98b470af3e4c29daa858d83

Contents?: true

Size: 1.24 KB

Versions: 37

Compression:

Stored size: 1.24 KB

Contents

#include "unittest.hpp"
#include "rice/Identifier.hpp"
#include "rice/Symbol.hpp"

using namespace Rice;

TESTSUITE(Identifier);

SETUP(Identifier)
{
  ruby_init();
}

TESTCASE(construct_from_id)
{
  ID id = rb_intern("foo");
  Identifier identifier(id);
  ASSERT_EQUAL(id, identifier.id());
}

TESTCASE(construct_from_symbol)
{
  Symbol symbol("FOO");
  Identifier identifier(symbol);
  ASSERT_EQUAL(rb_intern("FOO"), identifier.id());
}

TESTCASE(construct_from_c_string)
{
  Identifier identifier("Foo");
  ASSERT_EQUAL(rb_intern("Foo"), identifier.id());
}

TESTCASE(default_construct)
{
  Identifier identifier;
  ASSERT_EQUAL(rb_intern(""), identifier.id());
}

TESTCASE(copy_construct)
{
  Identifier identifier1("Foo");
  Identifier identifier2(identifier1);
  ASSERT_EQUAL(rb_intern("Foo"), identifier2.id());
}

TESTCASE(c_str)
{
  Identifier identifier("Foo");
  ASSERT_EQUAL("Foo", identifier.c_str());
}

TESTCASE(str)
{
  Identifier identifier("Foo");
  ASSERT_EQUAL(std::string("Foo"), identifier.str());
}

TESTCASE(implicit_conversion_to_id)
{
  Identifier identifier("Foo");
  ASSERT_EQUAL(rb_intern("Foo"), static_cast<ID>(identifier));
}

TESTCASE(to_sym)
{
  Identifier identifier("Foo");
  ASSERT_EQUAL(Symbol("Foo"), Symbol(identifier.to_sym()));
}

Version data entries

37 entries across 37 versions & 6 rubygems

Version Path
rice2-2.2.1 test/test_Identifier.cpp
rice2-2.2.0 test/test_Identifier.cpp
rice-2.2.0 test/test_Identifier.cpp
rice-2.1.3 test/test_Identifier.cpp
rice-2.1.2 test/test_Identifier.cpp
rice-2.1.1 test/test_Identifier.cpp
rice-2.1.0 test/test_Identifier.cpp
rice-2.0.0 test/test_Identifier.cpp
rice-1.7.0 test/test_Identifier.cpp
rice-1.6.3 test/test_Identifier.cpp
jameskilton-rice-1.2.0 test/test_Identifier.cpp
rice-1.6.2 test/test_Identifier.cpp
rice-1.6.1 test/test_Identifier.cpp
rice-1.6.0 test/test_Identifier.cpp
rice-1.6.0.pre test/test_Identifier.cpp
rice-1.5.3 test/test_Identifier.cpp
rice-1.5.2 test/test_Identifier.cpp
keyme-rice-1.5.1.keyme1 test/test_Identifier.cpp
keyme-rice-1.5.1.keyme test/test_Identifier.cpp
rice-1.5.1 test/test_Identifier.cpp