# # htmlify.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 htmlify-1.1 {websh3_htmlify: missing string} { catch {web::htmlify} msg set msg } {usage: ?-numeric? string} test htmlify-1.2 {websh3_htmlify: too many args} { catch {web::htmlify "a" "b"} msg set msg } {usage: ?-numeric? string} #----------------------------------------------------------------------- # normal operation test htmlify-1.3 {websh3_htmlify: test complete charset} { set in " !\"#\$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ\[\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ" set out [web::htmlify -numeric $in] } " !"#\$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ\[\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ" #----------------------------------------------------------------------- # special cases test htmlify-1.4 {websh3_htmlify: empty string} { set a [web::htmlify ""] } {} test htmlify-1.5 {websh3_htmlify: long string > 64kByte} { set arg ">" for {set i 0} {$i < 2000} {incr i} { append arg "abcdefghijklmnopqrstuvwxyABCDEFGHIJKLMNOPQRSTUVWXY" } append arg "<" set res [web::htmlify -numeric $arg] list [string length $res] [string range $res 0 4] [string range $res 100005 100009] } {100010 {>} {<}} # ----------------------------------------------------------------------------- # normal operation, using forward hash # ----------------------------------------------------------------------------- test htmlify-2.1 {websh3_htmlify: test complete charset, non-numeric} { set in " !\"#\$%&'()*+,-./0123456789:;<=>?@" append in "ABCDEFGHIJKLMNOPQRSTUVWXYZ\[\\\]^_`abcdefghijklmnopqrstuvwxyz" append in "{|}~ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ" append in "×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ" set out [web::htmlify $in] } " !"#\$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ\[\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ" test htmlify-2.2 {"websh3_htmlify: is deHtmlify(htmlify(in)) == in ?, except for nbsp"} { set in " !\"#\$%&'()*+,-./0123456789:;<=>?@" append in "ABCDEFGHIJKLMNOPQRSTUVWXYZ\[\\\]^_`abcdefghijklmnopqrstuvwxyz" append in "{|}~¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ" append in "×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ" string compare [web::dehtmlify [web::htmlify $in]] $in } {0} # ----------------------------------------------------------------------------- # look for memory problems # ----------------------------------------------------------------------------- test htmlify-3.1 {start and stop interpreter (without use of htmlify)} {} { interp create htmlify3_1 htmlify3_1 eval "load $env(WEB_LIBRARY)" interp delete htmlify3_1 set res "" } {} test htmlify-3.2 {start interp, use htmlify, and stop again} {} { interp create htmlify3_2 htmlify3_2 eval "load $env(WEB_LIBRARY)" set res [htmlify3_2 eval web::htmlify " !\"#\$%&'()*+"] interp delete htmlify3_2 set res } "!"\#\$%&'()*+" # ----------------------------------------------------------------------------- # -- syntax # ----------------------------------------------------------------------------- test htmlify-4.1 {--syntax} { set res [web::htmlify -test] append res [web::htmlify -- -test] set res } {-test-test} test htmlify-6.0 {multibyte characters} { web::htmlify "\u3042\u3044\u3046\u3048\u304a" } {あいうえお} # cleanup ::tcltest::cleanupTests