1 # Copyright 2021-2024 Free Software Foundation, Inc.
2 # This program is free software; you can redistribute it and/or modify
3 # it under the terms of the GNU General Public License as published by
4 # the Free Software Foundation; either version 3 of the License, or
5 # (at your option) any later version.
7 # This program is distributed in the hope that it will be useful,
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 # GNU General Public License for more details.
12 # You should have received a copy of the GNU General Public License
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
15 # Testsuite self-tests for string_to_regexp/string_list_to_regexp.
16 # The former is not explicitly tested, assuming string_list_to_regexp uses
21 proc test_regexp { args } {
39 set res [string_list_to_regexp {*}$fargs]
41 set test "#$test_nr: got expected re"
45 verbose -log "Expecting '$re'"
46 verbose -log "Got '$res'"
50 set test "#$test_nr: re matches string"
51 set str [join $fargs ""]
52 if { [regexp $re $str] } {
55 verbose -log "Matching '$str'"
56 verbose -log "Failed against '$re'"
61 test_regexp abc -- abc
62 test_regexp abc def -- abcdef
63 test_regexp {\\} -- {\\\\}
64 test_regexp "\n" -- "\n"
65 test_regexp {\n} -- {\\n}
66 test_regexp {\\} n -- {\\\\n}