# # dehtmlify.test -- # nca-073-9 # # Copyright (c) 1996-2000 by Netcetera AG. # Copyright (c) 2001 by Apache Software Foundation. # All rights reserved. # # See the file "license.terms" for information on usage and # redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. # # @(#) $Id$ # #----------------------------------------------------------------------- # tcltest package if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest namespace import ::tcltest::* } #----------------------------------------------------------------------- # errors test dehtmlify-1.1 {missing string} { catch {web::dehtmlify} msg set msg } {wrong # args: should be "web::dehtmlify string"} test dehtmlify-1.2 {too many args} { catch {web::dehtmlify "a" "b"} msg set msg } {wrong # args: should be "web::dehtmlify string"} #----------------------------------------------------------------------- # normal operation test dehtmlify-2.1 {test numeric entities} { web::dehtmlify " !"#\$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ\[\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ" } " !\"#\$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ\[\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ" test dehtmlify-2.2 {test symbolic entities} { web::dehtmlify ""&<> ¡¢£¤¥¦§¨©ª«¬­®¯&hibar;°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ" } "\"&<> \xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff" test dehtmlify-2.3 {simple text with  } { web::dehtmlify "some text" } "some text" test dehtmlify-2.4 {test invalid entities} { web::dehtmlify "&Amp; >&UUML;" } {&Amp; >&UUML;} test dehtmlify-2.5 {test tags} { web::dehtmlify "

some text
" } {some text} test dehtmlify-2.6 {test nested tags} { web::dehtmlify {

testbold\">ing

} } {testbold\">ing} test dehtmlify-2.7 {comments} { web::dehtmlify {

testing

and more

} } {testing and more} test dehtmlify-2.8 {test unclosed tag} { web::dehtmlify "

testtest
" } {thisisastrangetag>test} test dehtmlify-2.10 {strange nesting} {} { web::dehtmlify "textorbold" } {textorbold} #----------------------------------------------------------------------- # special cases test dehtmlify-3.1 {empty string} { catch {set a [web::dehtmlify ""]} msg set a } {} test dehtmlify-3.2 {long string > 64kByte} { set arg ">" for {set i 0} {$i < 2000} {incr i} { append arg "abcdefghijklmnopqrstuvwxyABCDEFGHIJKLMNOPQRSTUVWXY" } append arg "<" set res [web::dehtmlify $arg] list [string length $res] [string range $res 0 0] [string range $res 100001 100001] } {100002 > <} test dehtmlify-3.3 {remove HTML comment in comment-only string} { web::dehtmlify "" } {} test dehtmlify-3.4 {remove HTML comment, two comments right after each other} { web::dehtmlify "" } {} test dehtmlify-3.5 {catch last char after comment} { web::dehtmlify "L" } {L} test dehtmlify-3.6 {catch first char before comment} { web::dehtmlify "P" } {P} test dehtmlify-3.7 {comment without end} { web::dehtmlify "P" } {} test dehtmlify-5.2 {special cases for comments} { web::html::removecomments "" } {} test dehtmlify-5.3 {special cases for comments} { web::html::removecomments "" } {} test dehtmlify-5.4 {special cases for comments} { web::html::removecomments "" } "" test dehtmlify-5.5 {one char} { set res [web::dehtmlify m] lappend res [web::dehtmlify ""] } {m {}} test dehtmlify-6.0 {multibyte characters} { set res [web::dehtmlify "あいうえお"] expr {$res == "\u3042\u3044\u3046\u3048\u304a"} } {1} # cleanup ::tcltest::cleanupTests