Skip to content

Commit

Permalink
Add specs for Pointer::Appender (#14719)
Browse files Browse the repository at this point in the history
  • Loading branch information
straight-shoota committed Jun 18, 2024
1 parent e5032d0 commit 245edd1
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions spec/std/pointer/appender_spec.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
require "spec"

describe Pointer::Appender do
it ".new" do
Pointer::Appender.new(Pointer(Void).null)
end

it "#<<" do
data = Slice(Int32).new(5)
appender = data.to_unsafe.appender
4.times do |i|
appender << (i + 1) * 2
end

data.should eq Slice[2, 4, 6, 8, 0]
end

it "#size" do
data = Slice(Int32).new(5)
appender = data.to_unsafe.appender
appender.size.should eq 0
4.times do |i|
appender << 0
appender.size.should eq i + 1
end
appender.size.should eq 4
end
end

0 comments on commit 245edd1

Please sign in to comment.