1
0
Fork 0
mirror of https://github.com/rubyjs/therubyracer synced 2023-03-27 23:21:42 -04:00
therubyracer/spec/c/string_spec.rb

29 lines
867 B
Ruby

require 'c_spec_helper'
describe V8::C::String do
requires_v8_context
it 'is a primitive' do
expect(V8::C::String.NewFromUtf8(@isolate, 'test')).to be_a V8::C::Primitive
end
it 'can create new strings' do
expect(V8::C::String.NewFromUtf8(@isolate, 'test')).to be
end
it 'can be converted to a ruby string' do
expect(V8::C::String.NewFromUtf8(@isolate, 'test').Utf8Value).to eq 'test'
end
it 'can hold Unicode values outside the Basic Multilingual Plane' do
string = V8::C::String.NewFromUtf8(@isolate, "\u{100000}")
expect(string.Utf8Value).to eq "\u{100000}"
end
it 'can concatenate strings' do
string_one = V8::C::String.NewFromUtf8(@isolate, 'Hello ')
string_two = V8::C::String.NewFromUtf8(@isolate, 'World!')
expect(V8::C::String.Concat(string_one, string_two).Utf8Value).to eq 'Hello World!'
end
end