Skip to content

Commit 505f2ea

Browse files
committed
SQ: Add test
1 parent f574540 commit 505f2ea

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

test/rdiscount_test.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,21 @@ def test_that_discount_does_not_blow_up_with_weird_formatting_case
2121
RDiscount.new(text).to_html
2222
end
2323

24+
def test_that_oversized_input_raises_argument_error
25+
# mkd_string() takes an int length, so inputs > INT_MAX (2 147 483 647 bytes)
26+
# must be rejected before reaching C to avoid integer truncation / overflow.
27+
INT_MAX = 2_147_483_647
28+
begin
29+
oversized_text = 'a' * (INT_MAX + 1)
30+
rescue NoMemoryError
31+
skip "Insufficient memory to create oversized input for this test"
32+
end
33+
34+
assert_raise(ArgumentError) do
35+
RDiscount.new(oversized_text).to_html
36+
end
37+
end
38+
2439
def test_that_smart_converts_double_quotes_to_curly_quotes
2540
rd = RDiscount.new(%("Quoted text"), :smart)
2641
assert_equal %(<p>&ldquo;Quoted text&rdquo;</p>\n), rd.to_html

0 commit comments

Comments
 (0)