@@ -225,6 +225,16 @@ defmodule EnumTest do
225225 assert count_until_stream . ( [ 1 , 2 ] , 2 ) == 2
226226 end
227227
228+ test "count_until/2 with invalid limit" do
229+ assert_raise ArgumentError , "expected limit to be greater than 0, got: 0" , fn ->
230+ Enum . count_until ( [ 1 , 2 , 3 ] , 0 )
231+ end
232+
233+ assert_raise ArgumentError , "expected limit to be greater than 0, got: -22" , fn ->
234+ Enum . count_until ( [ 1 , 2 , 3 ] , - 22 )
235+ end
236+ end
237+
228238 test "count_until/3" do
229239 assert Enum . count_until ( [ 1 , 2 , 3 , 4 , 5 , 6 ] , fn x -> rem ( x , 2 ) == 0 end , 2 ) == 2
230240 assert Enum . count_until ( [ 1 , 2 ] , fn x -> rem ( x , 2 ) == 0 end , 2 ) == 1
@@ -243,6 +253,16 @@ defmodule EnumTest do
243253 assert count_until_stream . ( [ ] , fn x -> rem ( x , 2 ) == 0 end , 2 ) == 0
244254 end
245255
256+ test "count_until/3 with invalid limit" do
257+ assert_raise ArgumentError , "expected limit to be greater than 0, got: 0" , fn ->
258+ Enum . count_until ( [ 1 , 2 , 3 ] , fn x -> rem ( x , 2 ) == 0 end , 0 )
259+ end
260+
261+ assert_raise ArgumentError , "expected limit to be greater than 0, got: -22" , fn ->
262+ Enum . count_until ( [ 1 , 2 , 3 ] , fn x -> rem ( x , 2 ) == 0 end , - 22 )
263+ end
264+ end
265+
246266 test "dedup/1" do
247267 assert Enum . dedup ( [ 1 , 1 , 2 , 1 , 1 , 2 , 1 ] ) == [ 1 , 2 , 1 , 2 , 1 ]
248268 assert Enum . dedup ( [ 2 , 1 , 1 , 2 , 1 ] ) == [ 2 , 1 , 2 , 1 ]
0 commit comments