Sha256: 64466e87dd6d0fc6bd89e1a3e0a667b5f0d7a0e98d1c70ddf9032edede645a48
Contents?: true
Size: 1.39 KB
Versions: 9
Compression:
Stored size: 1.39 KB
Contents
# frozen_string_literal: true require 'gir_ffi_test_helper' describe GLib::Bytes do it 'can succesfully be created with GLib::Bytes.new' do bytes = GLib::Bytes.new [1, 2, 3] bytes.must_be_instance_of GLib::Bytes end it 'has a working #get_size method' do bytes = GLib::Bytes.new [1, 2, 3] bytes.get_size.must_equal 3 end it 'has a working #get_data method' do bytes = GLib::Bytes.new [1, 2, 3] bytes.get_data.to_a.must_equal [1, 2, 3] end it 'has a working #each method' do a = [] bytes = GLib::Bytes.new [1, 2, 3] bytes.each do |v| a.unshift v end a.must_equal [3, 2, 1] end it 'has a working #to_a method' do bytes = GLib::Bytes.new [1, 2, 3] bytes.to_a.must_equal [1, 2, 3] end describe '.from' do it 'creates a GLib::Bytes object form an array of small integers' do bytes = GLib::Bytes.from [1, 2, 3] bytes.must_be_instance_of GLib::Bytes bytes.to_a.must_equal [1, 2, 3] end it 'returns its argument if given a GLib::Bytes object' do bytes = GLib::Bytes.new [1, 2, 3] result = GLib::Bytes.from bytes assert result.equal?(bytes) end it 'wraps its argument if given a pointer' do bytes = GLib::Bytes.new [1, 2, 3] ptr = bytes.to_ptr result = GLib::Bytes.from ptr result.to_a.must_equal [1, 2, 3] result.to_ptr.must_equal ptr end end end
Version data entries
9 entries across 9 versions & 1 rubygems