Index: test/cgi/test_cgi_tag_helper.rb =================================================================== --- test/cgi/test_cgi_tag_helper.rb (revision 0) +++ test/cgi/test_cgi_tag_helper.rb (revision 0) @@ -0,0 +1,253 @@ +require 'test/unit' +require 'cgi' +require 'stringio' + + +class CGICoreTest < Test::Unit::TestCase + + + def setup + #@environ = { + # 'SERVER_PROTOCOL' => 'HTTP/1.1', + # 'REQUEST_METHOD' => 'GET', + # 'SERVER_SOFTWARE' => 'Apache 2.2.0', + #} + #ENV.update(@environ) + end + + + def teardown + @environ.each do |key, val| ENV.delete(key) end + $stdout = STDOUT + end + + + def test_cgi_tag_helper_html3 + @environ = { + 'REQUEST_METHOD' => 'GET', + } + ENV.update(@environ) + ## html3 + cgi = CGI.new('html3') + assert_equal('',cgi.a) + assert_equal('',cgi.a('bar')) + assert_equal('foo',cgi.a{'foo'}) + assert_equal('foo',cgi.a('bar'){'foo'}) + assert_equal('',cgi.tt) + assert_equal('',cgi.tt('bar')) + assert_equal('foo',cgi.tt{'foo'}) + assert_equal('foo',cgi.tt('bar'){'foo'}) + assert_equal('',cgi.i) + assert_equal('',cgi.i('bar')) + assert_equal('foo',cgi.i{'foo'}) + assert_equal('foo',cgi.i('bar'){'foo'}) + assert_equal('',cgi.b) + assert_equal('',cgi.b('bar')) + assert_equal('foo',cgi.b{'foo'}) + assert_equal('foo',cgi.b('bar'){'foo'}) + assert_equal('',cgi.u) + assert_equal('',cgi.u('bar')) + assert_equal('foo',cgi.u{'foo'}) + assert_equal('foo',cgi.u('bar'){'foo'}) + assert_equal('',cgi.strike) + assert_equal('',cgi.strike('bar')) + assert_equal('foo',cgi.strike{'foo'}) + assert_equal('foo',cgi.strike('bar'){'foo'}) + assert_equal('',cgi.big) + assert_equal('',cgi.big('bar')) + assert_equal('foo',cgi.big{'foo'}) + assert_equal('foo',cgi.big('bar'){'foo'}) + assert_equal('',cgi.small) + assert_equal('',cgi.small('bar')) + assert_equal('foo',cgi.small{'foo'}) + assert_equal('foo',cgi.small('bar'){'foo'}) + assert_equal('',cgi.sub) + assert_equal('',cgi.sub('bar')) + assert_equal('foo',cgi.sub{'foo'}) + assert_equal('foo',cgi.sub('bar'){'foo'}) + assert_equal('',cgi.sup) + assert_equal('',cgi.sup('bar')) + assert_equal('foo',cgi.sup{'foo'}) + assert_equal('foo',cgi.sup('bar'){'foo'}) + assert_equal('',cgi.em) + assert_equal('',cgi.em('bar')) + assert_equal('foo',cgi.em{'foo'}) + assert_equal('foo',cgi.em('bar'){'foo'}) + assert_equal('',cgi.strong) + assert_equal('',cgi.strong('bar')) + assert_equal('foo',cgi.strong{'foo'}) + assert_equal('foo',cgi.strong('bar'){'foo'}) + assert_equal('',cgi.dfn) + assert_equal('',cgi.dfn('bar')) + assert_equal('foo',cgi.dfn{'foo'}) + assert_equal('foo',cgi.dfn('bar'){'foo'}) + assert_equal('',cgi.code) + assert_equal('',cgi.code('bar')) + assert_equal('foo',cgi.code{'foo'}) + assert_equal('foo',cgi.code('bar'){'foo'}) + assert_equal('',cgi.samp) + assert_equal('',cgi.samp('bar')) + assert_equal('foo',cgi.samp{'foo'}) + assert_equal('foo',cgi.samp('bar'){'foo'}) + assert_equal('',cgi.kbd) + assert_equal('',cgi.kbd('bar')) + assert_equal('foo',cgi.kbd{'foo'}) + assert_equal('foo',cgi.kbd('bar'){'foo'}) + assert_equal('',cgi.var) + assert_equal('',cgi.var('bar')) + assert_equal('foo',cgi.var{'foo'}) + assert_equal('foo',cgi.var('bar'){'foo'}) + assert_equal('',cgi.cite) + assert_equal('',cgi.cite('bar')) + assert_equal('foo',cgi.cite{'foo'}) + assert_equal('foo',cgi.cite('bar'){'foo'}) + assert_equal('',cgi.font) + assert_equal('',cgi.font('bar')) + assert_equal('foo',cgi.font{'foo'}) + assert_equal('foo',cgi.font('bar'){'foo'}) + assert_equal('
',cgi.address) + assert_equal('
',cgi.address('bar')) + assert_equal('
foo
',cgi.address{'foo'}) + assert_equal('
foo
',cgi.address('bar'){'foo'}) + assert_equal('
',cgi.div) + assert_equal('
',cgi.div('bar')) + assert_equal('
foo
',cgi.div{'foo'}) + assert_equal('
foo
',cgi.div('bar'){'foo'}) + assert_equal('
',cgi.center) + assert_equal('
',cgi.center('bar')) + assert_equal('
foo
',cgi.center{'foo'}) + assert_equal('
foo
',cgi.center('bar'){'foo'}) + assert_equal('',cgi.map) + assert_equal('',cgi.map('bar')) + assert_equal('foo',cgi.map{'foo'}) + assert_equal('foo',cgi.map('bar'){'foo'}) + assert_equal('',cgi.applet) + assert_equal('',cgi.applet('bar')) + assert_equal('foo',cgi.applet{'foo'}) + assert_equal('foo',cgi.applet('bar'){'foo'}) + assert_equal('
',cgi.pre)
+    assert_equal('
',cgi.pre('bar'))
+    assert_equal('
foo
',cgi.pre{'foo'}) + assert_equal('
foo
',cgi.pre('bar'){'foo'}) + assert_equal('',cgi.xmp) + assert_equal('',cgi.xmp('bar')) + assert_equal('foo',cgi.xmp{'foo'}) + assert_equal('foo',cgi.xmp('bar'){'foo'}) + assert_equal('',cgi.listing) + assert_equal('',cgi.listing('bar')) + assert_equal('foo',cgi.listing{'foo'}) + assert_equal('foo',cgi.listing('bar'){'foo'}) + assert_equal('
',cgi.dl) + assert_equal('
',cgi.dl('bar')) + assert_equal('
foo
',cgi.dl{'foo'}) + assert_equal('
foo
',cgi.dl('bar'){'foo'}) + assert_equal('
    ',cgi.ol) + assert_equal('
      ',cgi.ol('bar')) + assert_equal('
        foo
      ',cgi.ol{'foo'}) + assert_equal('
        foo
      ',cgi.ol('bar'){'foo'}) + assert_equal('',cgi.ul) + assert_equal('',cgi.ul('bar')) + assert_equal('',cgi.ul{'foo'}) + assert_equal('',cgi.ul('bar'){'foo'}) + assert_equal('',cgi.dir) + assert_equal('',cgi.dir('bar')) + assert_equal('foo',cgi.dir{'foo'}) + assert_equal('foo',cgi.dir('bar'){'foo'}) + assert_equal('',cgi.menu) + assert_equal('',cgi.menu('bar')) + assert_equal('foo',cgi.menu{'foo'}) + assert_equal('foo',cgi.menu('bar'){'foo'}) + assert_equal('',cgi.select) + assert_equal('',cgi.select('bar')) + assert_equal('',cgi.select{'foo'}) + assert_equal('',cgi.select('bar'){'foo'}) + assert_equal('
      ',cgi.table) + assert_equal('
      ',cgi.table('bar')) + assert_equal('foo
      ',cgi.table{'foo'}) + assert_equal('foo
      ',cgi.table('bar'){'foo'}) + assert_equal('',cgi.title) + assert_equal('',cgi.title('bar')) + assert_equal('foo',cgi.title{'foo'}) + assert_equal('foo',cgi.title('bar'){'foo'}) + assert_equal('',cgi.style) + assert_equal('',cgi.style('bar')) + assert_equal('',cgi.style{'foo'}) + assert_equal('',cgi.style('bar'){'foo'}) + assert_equal('',cgi.script) + assert_equal('',cgi.script('bar')) + assert_equal('',cgi.script{'foo'}) + assert_equal('',cgi.script('bar'){'foo'}) + assert_equal('

      ',cgi.h1) + assert_equal('

      ',cgi.h1('bar')) + assert_equal('

      foo

      ',cgi.h1{'foo'}) + assert_equal('

      foo

      ',cgi.h1('bar'){'foo'}) + assert_equal('

      ',cgi.h2) + assert_equal('

      ',cgi.h2('bar')) + assert_equal('

      foo

      ',cgi.h2{'foo'}) + assert_equal('

      foo

      ',cgi.h2('bar'){'foo'}) + assert_equal('

      ',cgi.h3) + assert_equal('

      ',cgi.h3('bar')) + assert_equal('

      foo

      ',cgi.h3{'foo'}) + assert_equal('

      foo

      ',cgi.h3('bar'){'foo'}) + assert_equal('

      ',cgi.h4) + assert_equal('

      ',cgi.h4('bar')) + assert_equal('

      foo

      ',cgi.h4{'foo'}) + assert_equal('

      foo

      ',cgi.h4('bar'){'foo'}) + assert_equal('
      ',cgi.h5) + assert_equal('
      ',cgi.h5('bar')) + assert_equal('
      foo
      ',cgi.h5{'foo'}) + assert_equal('
      foo
      ',cgi.h5('bar'){'foo'}) + assert_equal('
      ',cgi.h6) + assert_equal('
      ',cgi.h6('bar')) + assert_equal('
      foo
      ',cgi.h6{'foo'}) + assert_equal('
      foo
      ',cgi.h6('bar'){'foo'}) + assert_match(/^