summaryrefslogtreecommitdiff
path: root/test/contains-selector.test
diff options
context:
space:
mode:
authorcashmere <cashmere@autistici.org>2026-09-04 09:05:24 +0200
committercashmere <cashmere@autistici.org>2026-09-04 09:05:24 +0200
commit4f49b16079b27d7ce633619e4cddfdf2bffbc952 (patch)
treec296c1e7f3c3e2f6859c6d3a1b1b208779b89679 /test/contains-selector.test
downloadrelic-4f49b16079b27d7ce633619e4cddfdf2bffbc952.tar.gz
initial commitHEADmaster
Diffstat (limited to 'test/contains-selector.test')
-rw-r--r--test/contains-selector.test55
1 files changed, 55 insertions, 0 deletions
diff --git a/test/contains-selector.test b/test/contains-selector.test
new file mode 100644
index 0000000..1f971f1
--- /dev/null
+++ b/test/contains-selector.test
@@ -0,0 +1,55 @@
+#
+# Copyright (c) 2015 D. Richard Hipp
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the Simplified BSD License (also
+# known as the "2-Clause License" or "FreeBSD License".)
+#
+# This program is distributed in the hope that it will be useful,
+# but without any warranty; without even the implied warranty of
+# merchantability or fitness for a particular purpose.
+#
+# Author contact information:
+# drh@hwaci.com
+# http://www.hwaci.com/drh/
+#
+############################################################################
+#
+# Test containsSelector() function in src/style.c
+#
+
+test_setup ""
+
+proc contains-selector {testId css selectorResultMap} {
+ set css [string trim $css]
+ set filename [file join $::tempPath compare-selector.css]
+ set fh [open $filename w]
+ puts -nonewline $fh $css
+ close $fh
+ foreach {selector found} $selectorResultMap {
+ set expected "$selector [expr {$found ? "found" : "not found"}]"
+ set result [fossil test-contains-selector $filename $selector]
+ test "contains-selector $testId $selector" {$result eq $expected}
+ }
+ file delete $filename
+}
+
+contains-selector 1 {
+ .a.b {}
+ .c .de {}
+ /* comment */
+ .c .d, .e /* comment */ {}
+} {
+ .a 0
+ .b 0
+ .a.b 1
+ .c 0
+ .d 0
+ {.c.d} 0
+ {.c .d} 1
+ .e 1
+}
+
+###############################################################################
+
+test_cleanup