Foobar 'i'
and 'div' not closed"]
+ aa_true [ns_quotehtml $result] {$result eq "Foobar 'i' and 'div' not closed
"}
+
+ #
+ # wrong nesting of tags and unclosed tags
+ #
+ set text {1 2 3 4 5 6}
+ set result [util_close_html_tags $text]
+ aa_log "Input:
[ns_quotehtml $text]
"
+ aa_log "Result:
[ns_quotehtml $result]
"
+ if {[::acs::icanuse "ns_parsehtml"]} {
+ aa_true "tags are closed:" {[string range $result end-14 end] eq "
"}
+ }
+
}
aa_register_case \
-cats {api smoke} \
- -procs {ad_html_text_convert ad_enhanced_text_to_html} \
+ -procs {
+ ad_html_text_convert
+ ad_enhanced_text_to_html
+
+ ad_html_text_convertible_p
+ ad_enhanced_text_to_plain_text
+ ad_parse_html_attributes_upvar
+ } \
ad_html_text_convert {
Testing ad_html_text_convert.
} {
@@ -133,7 +218,8 @@
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.
+ # 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..."
#----------------------------------------------------------------------
@@ -201,70 +287,92 @@
aa_register_case \
-cats {api smoke} \
- -procs {string_truncate} \
- string_truncate {
+ -procs {ad_string_truncate} \
+ ad_string_truncate {
Testing string truncation
} {
- aa_equals "" [string_truncate -len 5 -ellipsis "" -- "foo"] "foo"
- aa_equals "" [string_truncate -len 5 -ellipsis "" -- "foobar greble"] "fooba"
- 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 7 -ellipsis "" -- "foobar\tgreble"] "foobar"
- aa_equals "" [string_truncate -len 7 -ellipsis "" -- "foobar\ngreble"] "foobar"
- aa_equals "" [string_truncate -len 7 -ellipsis "" -- "foobar\rgreble"] "foobar"
- aa_equals "" [string_truncate -len 7 -ellipsis "" -- "foobar\fgreble"] "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"
+ aa_equals "" [ad_string_truncate -len 5 -ellipsis "" -- "foo"] "foo"
+ aa_equals "" [ad_string_truncate -len 5 -ellipsis "" -- "foobar greble"] "fooba"
+ aa_equals "" [ad_string_truncate -len 6 -ellipsis "" -- "foobar greble"] "foobar"
+ aa_equals "" [ad_string_truncate -len 7 -ellipsis "" -- "foobar greble"] "foobar"
+ aa_equals "" [ad_string_truncate -len 7 -ellipsis "" -- "foobar\tgreble"] "foobar"
+ aa_equals "" [ad_string_truncate -len 7 -ellipsis "" -- "foobar\ngreble"] "foobar"
+ aa_equals "" [ad_string_truncate -len 7 -ellipsis "" -- "foobar\rgreble"] "foobar"
+ aa_equals "" [ad_string_truncate -len 7 -ellipsis "" -- "foobar\fgreble"] "foobar"
+ aa_equals "" [ad_string_truncate -len 8 -ellipsis "" -- "foobar greble"] "foobar"
+ aa_equals "" [ad_string_truncate -len 9 -ellipsis "" -- "foobar greble"] "foobar"
+ aa_equals "" [ad_string_truncate -len 10 -ellipsis "" -- "foobar greble"] "foobar"
+ aa_equals "" [ad_string_truncate -len 11 -ellipsis "" -- "foobar greble"] "foobar"
+ aa_equals "" [ad_string_truncate -len 12 -ellipsis "" -- "foobar greble"] "foobar"
+ aa_equals "" [ad_string_truncate -len 13 -ellipsis "" -- "foobar greble"] "foobar greble"
- aa_equals "" [string_truncate -len 5 -ellipsis "..." -- "foo"] "foo"
- aa_equals "" [string_truncate -len 5 -ellipsis "..." -- "foobar greble"] "fo..."
- aa_equals "" [string_truncate -len 6 -ellipsis "..." -- "foobar greble"] "foo..."
- aa_equals "" [string_truncate -len 7 -ellipsis "..." -- "foobar greble"] "foob..."
- aa_equals "" [string_truncate -len 8 -ellipsis "..." -- "foobar greble"] "fooba..."
- 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"
+ aa_equals "" [ad_string_truncate -len 5 -ellipsis "..." -- "foo"] "foo"
+ aa_equals "" [ad_string_truncate -len 5 -ellipsis "..." -- "foobar greble"] "fo..."
+ aa_equals "" [ad_string_truncate -len 6 -ellipsis "..." -- "foobar greble"] "foo..."
+ aa_equals "" [ad_string_truncate -len 7 -ellipsis "..." -- "foobar greble"] "foob..."
+ aa_equals "" [ad_string_truncate -len 8 -ellipsis "..." -- "foobar greble"] "fooba..."
+ aa_equals "" [ad_string_truncate -len 9 -ellipsis "..." -- "foobar greble"] "foobar..."
+ aa_equals "" [ad_string_truncate -len 10 -ellipsis "..." -- "foobar greble"] "foobar..."
+ aa_equals "" [ad_string_truncate -len 11 -ellipsis "..." -- "foobar greble"] "foobar..."
+ aa_equals "" [ad_string_truncate -len 12 -ellipsis "..." -- "foobar greble"] "foobar..."
+ aa_equals "" [ad_string_truncate -len 13 -ellipsis "..." -- "foobar greble"] "foobar greble"
set long_string [string repeat "Very long text. " 100]
- aa_equals "No truncation" [string_truncate -len [string length $long_string] -- $long_string] $long_string
+ aa_equals "No truncation" [ad_string_truncate -len [string length $long_string] -- $long_string] $long_string
}
aa_register_case \
-cats {api smoke} \
- -procs {util_convert_line_breaks_to_html} \
+ -procs {
+ util_convert_line_breaks_to_html
+ } \
util_convert_line_breaks_to_html {
Test if it converts spaces and line breaks correctly.
} {
- #Convert leading and trailing spaces or tabs
+ # Convert leading and trailing spaces or tabs
set html "\tinter spaces "
- aa_log "html= \"$html\" - Contains tabs and spaces"
+ aa_log "html= '$html' - Contains tabs and spaces"
set result [util_convert_line_breaks_to_html $html]
- aa_false "Now html=\"$result\"" [regexp {\sinter spaces\s} $result]
+ aa_false "Now html='$result'" [regexp {\sinter spaces\s} $result]
- #convert single break
+ # convert single break
set html "\r\n inter\r\nbreaks \r\n"
- aa_log "html= \"$html\" - Contains a single break"
+ aa_log "html= '$html' - Contains a single break"
set result [util_convert_line_breaks_to_html $html]
- aa_false "Now html=\"$result\"" [regexp {inter\nspaces} $result]
+ aa_false "Now html='$result'" [regexp {inter\nspaces} $result]
- #convert paragraph break
+ # convert paragraph break
set html "\r\n inter\r\n\r\nbreaks \r\n"
- aa_log "html= \"$html\" - Contains a double break"
+ aa_log "html= '$html' - Contains a double break"
set result [util_convert_line_breaks_to_html $html]
- aa_false "Now html=\"$result\"" [regexp {interspaces} $result]
+ aa_false "Now html='$result'" [regexp {inter
spaces} $result]
- #convert more than 2 breaks
+ # convert more than 2 breaks
set html "\r\n inter\r\n\r\n\r\nbreaks \r\n"
- aa_log "html= \"$html\" - Contains more than 2 breaks"
+ aa_log "html= '$html' - Contains more than 2 breaks"
set result [util_convert_line_breaks_to_html $html]
- aa_false "Now html=\"$result\"" [regexp {inter\n\n\nspaces} $result]
+ aa_false "Now html='$result'" [regexp {inter\n\n\nspaces} $result]
+
+ # do not trim spaces before and after some tags
+ set html "We could use a
instead than a
layout\r\nfor the list for example."
+ aa_log "html= '[ns_quotehtml $html]' - Contains more than 2 breaks"
+ set result [util_convert_line_breaks_to_html $html]
+ aa_true "Now html='[ns_quotehtml $result]'" [regexp {a layout} $result]
+
+ # do not add
inside
+ set text "text begin\r\n\nline1\nline2\n
text\nend\n"
+ aa_log "Input: [ns_quotehtml $text]
"
+ set result [util_convert_line_breaks_to_html -contains_pre $text]
+ aa_log "result is [ns_quotehtml $result]
"
+ set nrBr [regsub -all
$result
.]
+ aa_true "text contains some [ns_quotehtml
] tags" {$nrBr > 0}
+
+ if {[::acs::icanuse "ns_parsehtml"]} {
+ aa_true "text contains $nrBr [ns_quotehtml
] tags" {$nrBr == 2}
+ }
+
+
}
@@ -312,10 +420,10 @@
util_remove_html_tags {
Test if it remove all between tags
} {
- set html "some text to probe if it
remove all between \"<\" and \">\"
"
+ set html "some text to probe if it
remove all between '<' and '>'
"
set result [util_remove_html_tags $html]
- aa_equals "Without all between \"<\" and \">\" html=\"$result\""\
- "some text to probe if it remove all between \"\"" $result
+ aa_equals "Without all between '<' and '>' html='$result'"\
+ "some text to probe if it remove all between ''" $result
}
aa_register_case \
@@ -332,9 +440,9 @@
set result [ad_parse_html_attributes $html $pos]
aa_equals "Attributes - $result" $result {foo bar}
- # One Attribute with value and one whitout value
+ # One attribute with value and one without value
set html ""
- aa_log "A tag with one Attribute with value and one whitout value - $html"
+ aa_log "A tag with one attribute with value and one without value - $html"
set result [ad_parse_html_attributes $html $pos]
aa_equals "Attributes - $result" $result {{foo bar} tob}
@@ -477,6 +585,45 @@
}
aa_register_case \
+ -cats {api smoke} \
+ -procs {
+ ad_text_to_html
+ util_convert_line_breaks_to_html
+ } \
+ ad_text_to_html {
+ Test rendering of a more or less standard HTML text
+} {
+ set text {We could use a instead than a
layout » for the list for example.»}
+ set result [ad_text_to_html -no_quote -includes_html -- $text]
+ aa_log "Input:\n[ns_quotehtml $text]"
+ aa_log "Result:\n[ns_quotehtml $result]"
+ if {[::acs::icanuse "ns_parsehtml"]} {
+ aa_true "text contains sample code" [string match ** $result]
+ }
+ aa_true "gullimet » preserved" [string match *»* $result]
+
+ #
+ # This calls util_convert_line_breaks_to_html as well, but
+ # strangely when this is called with -includes_html" it removes
+ # newlines around although "pre" is not included in the
+ # regular expression.
+ #
+ set text "text begin\n\nline1\nline2\n
text\nend\n"
+ aa_log "Input: [ns_quotehtml $text]
"
+ set result [ad_text_to_html -includes_html -no_quote $text]
+ aa_log "result is [ns_quotehtml $result]
"
+ set nrBr [regsub -all
$result
.]
+ aa_true "text contains [ns_quotehtml
] tags" {$nrBr > 0}
+
+ if {[::acs::icanuse "ns_parsehtml"]} {
+ aa_true "text contains $nrBr [ns_quotehtml
] tags" {$nrBr == 1}
+ }
+ #aa_equals "new: $html _version should be the same" $html_version $string_with_img
+
+}
+
+
+aa_register_case \
-cats {api} \
-bugs 1450 \
-procs {ad_enhanced_text_to_html} \
@@ -490,7 +637,7 @@
aa_log "Original string is $string_with_img"
set html_version [ad_enhanced_text_to_html $string_with_img]
aa_equals "new: $html_version should be the same" $html_version $string_with_img
-}
+ }
aa_register_case \
-cats {api smoke} \
@@ -515,7 +662,7 @@
# Test offending post sent by Dave Bauer
set offending_post {
-I have a dynamically assigned ip address, so I use dyndns.org to
+I have a dynamically assigned IP address, so I use dyndns.org to
change
addresses for my acs server.
Mail is sent to any yahoo address fine. Mail sent to aol fails. I am
|
|