File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,28 @@ private def is_stable_sort(mutable, &block)
4545end
4646
4747describe " Slice" do
48+ describe " .new" do
49+ describe " initializes with default value" do
50+ it " integer" do
51+ Slice (Int32 ).new(3 , 0 ).should eq Slice [0 , 0 , 0 ]
52+ Slice (Int32 ).new(3 , 1 ).should eq Slice [1 , 1 , 1 ]
53+ end
54+
55+ it " float" do
56+ Slice (Float32 ).new(3 , 0.0 ).should eq Slice [0.0 , 0.0 , 0.0 ]
57+ Slice (Float32 ).new(3 , 1.0 ).should eq Slice [1.0 , 1.0 , 1.0 ]
58+ end
59+
60+ it " pointer" do
61+ null = Pointer (Void ).null
62+ Slice (Pointer (Void )).new(3 , null).should eq Slice [null, null, null]
63+
64+ value = Pointer (Void ).new(0x123 _u64 )
65+ Slice (Pointer (Void )).new(3 , value).should eq Slice [value, value, value]
66+ end
67+ end
68+ end
69+
4870 it " gets pointer and size" do
4971 pointer = Pointer .malloc(1 , 0 )
5072 slice = Slice .new(pointer, 1 )
You can’t perform that action at this time.
0 commit comments