| 1 | #!/usr/bin/ruby |
|---|
| 2 | # |
|---|
| 3 | # Unit test for bugs found in BlueCloth |
|---|
| 4 | # $Id: 10_Bug.tests.rb 68 2004-08-25 05:14:37Z ged $ |
|---|
| 5 | # |
|---|
| 6 | # Copyright (c) 2004 The FaerieMUD Consortium. |
|---|
| 7 | # |
|---|
| 8 | |
|---|
| 9 | if !defined?( BlueCloth ) || !defined?( BlueCloth::TestCase ) |
|---|
| 10 | basedir = File::dirname( __FILE__ ) |
|---|
| 11 | require File::join( basedir, 'bctestcase' ) |
|---|
| 12 | end |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | require 'timeout' |
|---|
| 16 | |
|---|
| 17 | ### This test case tests ... |
|---|
| 18 | class BugsTestCase < BlueCloth::TestCase |
|---|
| 19 | BaseDir = File::dirname( File::dirname(File::expand_path( __FILE__ )) ) |
|---|
| 20 | |
|---|
| 21 | ### Test to be sure the README file can be transformed. |
|---|
| 22 | def test_00_slow_block_regex |
|---|
| 23 | contents = File::read( File::join(BaseDir,"README") ) |
|---|
| 24 | bcobj = BlueCloth::new( contents ) |
|---|
| 25 | |
|---|
| 26 | assert_nothing_raised { |
|---|
| 27 | timeout( 2 ) do |
|---|
| 28 | bcobj.to_html |
|---|
| 29 | end |
|---|
| 30 | } |
|---|
| 31 | end |
|---|
| 32 | |
|---|
| 33 | ### :TODO: Add more documents and test their transforms. |
|---|
| 34 | |
|---|
| 35 | def test_10_regexp_engine_overflow_bug |
|---|
| 36 | contents = File::read( File::join(BaseDir,"tests/data/re-overflow.txt") ) |
|---|
| 37 | bcobj = BlueCloth::new( contents ) |
|---|
| 38 | |
|---|
| 39 | assert_nothing_raised { |
|---|
| 40 | bcobj.to_html |
|---|
| 41 | } |
|---|
| 42 | end |
|---|
| 43 | |
|---|
| 44 | def test_15_regexp_engine_overflow_bug2 |
|---|
| 45 | contents = File::read( File::join(BaseDir,"tests/data/re-overflow2.txt") ) |
|---|
| 46 | bcobj = BlueCloth::new( contents ) |
|---|
| 47 | |
|---|
| 48 | assert_nothing_raised { |
|---|
| 49 | bcobj.to_html |
|---|
| 50 | } |
|---|
| 51 | end |
|---|
| 52 | |
|---|
| 53 | def test_20_nested_tags_bug |
|---|
| 54 | contents = File::read( File::join(BaseDir,"tests/data/nested_tags.txt") ) |
|---|
| 55 | bcobj = BlueCloth::new( contents ) |
|---|
| 56 | |
|---|
| 57 | assert_nothing_raised { |
|---|
| 58 | bcobj.to_html |
|---|
| 59 | } |
|---|
| 60 | end |
|---|
| 61 | |
|---|
| 62 | end |
|---|
| 63 | |
|---|
| 64 | |
|---|
| 65 | __END__ |
|---|