diff options
Diffstat (limited to 'test/contains-selector.test')
| -rw-r--r-- | test/contains-selector.test | 55 |
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 |
