Index: openacs-4/packages/acs-tcl/tcl/test/html-conversion-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/test/html-conversion-procs.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/acs-tcl/tcl/test/html-conversion-procs.tcl 26 Jan 2004 15:39:46 -0000 1.3 +++ openacs-4/packages/acs-tcl/tcl/test/html-conversion-procs.tcl 5 Feb 2004 17:05:43 -0000 1.4 @@ -55,4 +55,88 @@ } { set html "An Link" aa_true "href is allowed for A tags" [string equal [ad_html_security_check $html] ""] -} \ No newline at end of file +} + +aa_register_case util_close_html_tags { + Tests closing HTML tags. +} { + aa_equals "" [util_close_html_tags "Foobar"] "Foobar" + + aa_equals "" [util_close_html_tags "Foobar"] "Foobar" + + aa_equals "" [util_close_html_tags "Foobar is a very long word"] "Foobar is a very long word" + + aa_equals "" [util_close_html_tags "Foobar is a very long word" 15] "Foobar is a" + + aa_equals "" [util_close_html_tags "Foobar is a very long word" 0 20 "..."] "Foobar is a very..." +} + + +aa_register_case ad_html_text_convert { + Testing ad_html_text_convert. +} { + #---------------------------------------------------------------------- + # text/enhanced + #---------------------------------------------------------------------- + + set string "What?\nNever mind, buddy" + + aa_equals "" [ad_html_text_convert -from "text/enhanced" -to "text/html" -truncate_len 14 -- $string] \ + [ad_enhanced_text_to_html "What?\nNever..."] + + # The string is longer in plaintext, because the "_" symbol to denote italics is counted as well. + aa_equals "" [ad_html_text_convert -from "text/enhanced" -to "text/plain" -truncate_len 15 -- $string] "What?\n_Never..." + + #---------------------------------------------------------------------- + # text/plain + #---------------------------------------------------------------------- + + set string "What?\nNever mind, buddy" + + aa_equals "" [ad_html_text_convert -from "text/plain" -to "text/html" -truncate_len 14 -- $string] \ + [ad_text_to_html "What?\nNever..."] + + aa_equals "" [ad_html_text_convert -from "text/plain" -to "text/plain" -truncate_len 14 -- $string] \ + "What?\nNever..." + + #---------------------------------------------------------------------- + # text/fixed-width + #---------------------------------------------------------------------- + + set string "What?\nNever mind, buddy" + + aa_equals "" [ad_html_text_convert -from "text/fixed-width" -to "text/html" -truncate_len 14 -- $string] \ + "
What?\nNever
..." + + aa_equals "" [ad_html_text_convert -from "text/fixed-width" -to "text/plain" -truncate_len 14 -- $string] \ + "What?\nNever..." + + + #---------------------------------------------------------------------- + # text/html + #---------------------------------------------------------------------- + + set string "What?
Never mind, buddy" + + aa_equals "" [ad_html_text_convert -from "text/html" -to "text/html" -truncate_len 14 -- $string] \ + "What?
Never..." + + aa_equals "" [ad_html_text_convert -from "text/html" -to "text/plain" -truncate_len 15 -- $string] \ + "What?\n_Never..." + + +} + +aa_register_case string_truncate { + Testing string truncation +} { + aa_equals "" [string_truncate -len 5 -ellipsis "" -- "foobar greble"] "" + aa_equals "" [string_truncate -len 6 -ellipsis "" -- "foobar greble"] "foobar" + aa_equals "" [string_truncate -len 7 -ellipsis "" -- "foobar greble"] "foobar" + aa_equals "" [string_truncate -len 8 -ellipsis "" -- "foobar greble"] "foobar" + aa_equals "" [string_truncate -len 9 -ellipsis "" -- "foobar greble"] "foobar" + aa_equals "" [string_truncate -len 10 -ellipsis "" -- "foobar greble"] "foobar" + aa_equals "" [string_truncate -len 11 -ellipsis "" -- "foobar greble"] "foobar" + aa_equals "" [string_truncate -len 12 -ellipsis "" -- "foobar greble"] "foobar" + aa_equals "" [string_truncate -len 13 -ellipsis "" -- "foobar greble"] "foobar greble" +}