File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,8 @@ local sample_constructor = ffi.typeof('sample')
13
13
14
14
local function quicksort (array , low , high )
15
15
assert (low >= 0 , ' Low bound must be non-negative' )
16
+ assert (high < ffi .sizeof (array ) / ffi .sizeof (' double' ),
17
+ ' Upper bound must be lower than array size' )
16
18
if high - low < 1 then
17
19
return array
18
20
end
Original file line number Diff line number Diff line change @@ -109,6 +109,17 @@ g.test_low_bound_negative = function()
109
109
)
110
110
end
111
111
112
+ g .test_high_bound_higher_array_size = function ()
113
+ local empty = ffi .new (' double[?]' , 2 )
114
+ t .assert_error_msg_contains (
115
+ ' Upper bound must be lower than array size' ,
116
+ quantile .quicksort ,
117
+ empty ,
118
+ 1 ,
119
+ 10
120
+ )
121
+ end
122
+
112
123
g .test_not_sorted = function ()
113
124
local array = ffi .new (' double[?]' , 2 )
114
125
array [0 ] = math.huge
You can’t perform that action at this time.
0 commit comments