2015-03-21 09:51:17 +00:00
|
|
|
require 'c_spec_helper'
|
|
|
|
|
|
|
|
describe V8::C::String do
|
|
|
|
requires_v8_context
|
|
|
|
|
2015-03-21 10:54:39 +00:00
|
|
|
it 'is a primitive' do
|
2015-04-04 14:03:06 +00:00
|
|
|
expect(V8::C::String.NewFromUtf8(@isolate, 'test')).to be_a V8::C::Primitive
|
2015-03-21 10:54:39 +00:00
|
|
|
end
|
|
|
|
|
2015-03-21 09:51:17 +00:00
|
|
|
it 'can create new strings' do
|
2015-04-04 14:03:06 +00:00
|
|
|
expect(V8::C::String.NewFromUtf8(@isolate, 'test')).to be
|
2015-03-21 09:51:17 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'can be converted to a ruby string' do
|
2015-04-04 14:03:06 +00:00
|
|
|
expect(V8::C::String.NewFromUtf8(@isolate, 'test').Utf8Value).to eq 'test'
|
2015-03-21 09:51:17 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'can hold Unicode values outside the Basic Multilingual Plane' do
|
2015-04-04 14:03:06 +00:00
|
|
|
string = V8::C::String.NewFromUtf8(@isolate, "\u{100000}")
|
2015-03-21 09:51:17 +00:00
|
|
|
expect(string.Utf8Value).to eq "\u{100000}"
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'can concatenate strings' do
|
2015-04-04 14:03:06 +00:00
|
|
|
string_one = V8::C::String.NewFromUtf8(@isolate, 'Hello ')
|
|
|
|
string_two = V8::C::String.NewFromUtf8(@isolate, 'World!')
|
2015-03-21 09:51:17 +00:00
|
|
|
|
|
|
|
expect(V8::C::String.Concat(string_one, string_two).Utf8Value).to eq 'Hello World!'
|
|
|
|
end
|
|
|
|
end
|