move find-string tests into the wxme test suite
original commit: 6d4b708851cd0a16d7e476746ef1c66a2665bb8b
This commit is contained in:
parent
72ac3e8972
commit
269e2f583c
|
@ -356,6 +356,144 @@
|
|||
|
||||
(expect (send t find-next-non-string-snip #f) #f)
|
||||
|
||||
(let ()
|
||||
(define (txt s)
|
||||
(define t (new text%))
|
||||
(send t insert s)
|
||||
(send t set-position 0 0)
|
||||
t)
|
||||
(define (kmp-search txt str all?)
|
||||
(send txt do-find-string-all str 'forward 0 (send txt last-position) (not all?) #t #t #f))
|
||||
|
||||
(expect (kmp-search (txt "x") "x" #f) 0)
|
||||
(expect (kmp-search (txt "yx") "x" #f) 1)
|
||||
(expect (kmp-search (txt "yx") "yx" #f) 0)
|
||||
(expect (kmp-search (txt "zyx") "yx" #f) 1)
|
||||
(expect (kmp-search (txt "yyx") "yx" #f) 1)
|
||||
(expect (kmp-search (txt "qqq") "yx" #f) #f)
|
||||
(expect (kmp-search (txt "ABC ABCDAB ABCDABCDABDE") "ABCDABD" #f) 15)
|
||||
(expect (kmp-search (txt "xxxx") "y" #t) '())
|
||||
(expect (kmp-search (txt "xxxx") "x" #t) '(0 1 2 3))
|
||||
(expect (kmp-search (txt "xyxy") "x" #t) '(0 2))
|
||||
(expect (kmp-search (txt " x\n ") "x" #t) '(1))
|
||||
(expect (kmp-search (txt "") "x" #t) '())
|
||||
(expect (send (txt " x\n ") do-find-string-all "X" 'forward 0 'eof #f #t #f #f)
|
||||
'(1))
|
||||
(expect (send (txt "xXxXxX") do-find-string-all "x" 'forward 0 'eof #f #t #f #f)
|
||||
'(0 1 2 3 4 5))
|
||||
(expect (send (txt "xXxXxX") do-find-string-all "x" 'forward 2 4 #f #t #f #f)
|
||||
'(2 3))
|
||||
(expect (send (txt "xyxyxyxyxyx") do-find-string-all "xy" 'forward 2 5 #f #t #t #f)
|
||||
'(2))
|
||||
(expect (send (txt "abcdabcdabcd") do-find-string-all "abcd" 'forward 0 'eof #f #f #t #f)
|
||||
'(4 8 12))
|
||||
(expect (send (txt "qqabcdabcdabcd") do-find-string-all "abcd" 'forward 0 'eof #t #f #t #f)
|
||||
6)
|
||||
(expect (send (txt "qqabcdabcdabcd") do-find-string-all "abcd" 'forward 0 'eof #t #t #t #f)
|
||||
2)
|
||||
(expect (send (txt "abcdabcdabcd") do-find-string-all "abcd" 'backward 12 0 #f #t #t #f)
|
||||
'(12 8 4))
|
||||
(expect (send (txt "abcdabcdabcd") do-find-string-all "abcd" 'backward 12 0 #f #f #t #f)
|
||||
'(8 4 0))
|
||||
(expect (send (txt "abcd\nabcdabcd") do-find-string-all "abcd" 'backward 12 0 #f #t #t #f)
|
||||
'(9 4))
|
||||
(expect (send (txt "abcd\nabcdabcd") do-find-string-all "abcd" 'backward 13 0 #f #t #t #f)
|
||||
'(13 9 4))
|
||||
(expect (send (txt "abcdabcd\nabcd") do-find-string-all "abcd" 'backward 12 0 #f #t #t #f)
|
||||
'(8 4))
|
||||
(expect (send (txt "abcdabcd\nabcd") do-find-string-all "abcd" 'backward 13 0 #f #t #t #f)
|
||||
'(13 8 4))
|
||||
(expect (send (txt "abcdabcd\nabcd") do-find-string-all "abcd" 'backward 8 0 #f #t #t #f)
|
||||
'(8 4))
|
||||
(expect (send (txt "abcdabcd\nabcd") do-find-string-all "abcd" 'forward 4 13 #f #t #t #f)
|
||||
'(4 9))
|
||||
(expect (send (txt "xyz") do-find-string-all "xyz" 'backward 3 0 #t #f #t #f)
|
||||
0)
|
||||
(expect (send (txt "xyz") do-find-string-all "xyz" 'backward 3 0 #t #t #t #f)
|
||||
3)
|
||||
|
||||
(let ([t1 (new text%)]
|
||||
[t2 (new text%)])
|
||||
(send t1 insert "abc")
|
||||
(send t1 insert (new editor-snip% [editor t2]))
|
||||
(send t1 insert "abc")
|
||||
(send t2 insert "abc")
|
||||
(expect (send t1 do-find-string-all "abc" 'forward 0 (send t1 last-position) #f #t #t #t)
|
||||
(list 0 (list t2 0) 4)))
|
||||
|
||||
(let ([t1 (new text%)]
|
||||
[t2 (new text%)])
|
||||
(send t1 insert "abc")
|
||||
(send t1 insert (new editor-snip% [editor t2]))
|
||||
(send t1 insert "abc")
|
||||
(send t2 insert "abc")
|
||||
(expect (send t1 do-find-string-all "abc" 'backward (send t1 last-position) 0 #f #t #t #t)
|
||||
(list 7 (list t2 3) 3)))
|
||||
|
||||
(let ([t1 (new text%)]
|
||||
[t2 (new text%)])
|
||||
(send t1 insert "abc")
|
||||
(send t1 insert (new editor-snip% [editor t2]))
|
||||
(send t1 insert "abcd")
|
||||
(send t2 insert "abc")
|
||||
(expect (send t1 do-find-string-all "abcd" 'forward 0 (send t1 last-position) #t #t #t #t)
|
||||
4))
|
||||
|
||||
(let ([t1 (new text%)]
|
||||
[t2 (new text%)])
|
||||
(send t1 insert "abc")
|
||||
(send t1 insert (new editor-snip% [editor t2]))
|
||||
(send t1 insert "abc")
|
||||
(send t2 insert "abcd")
|
||||
(expect (send t1 do-find-string-all "abcd" 'forward 0 (send t1 last-position) #t #t #t #t)
|
||||
(cons t2 0)))
|
||||
|
||||
(let ([t1 (new text%)]
|
||||
[t2 (new text%)]
|
||||
[pb (new pasteboard%)])
|
||||
(send t1 insert "abc")
|
||||
(send t1 insert (new editor-snip% [editor pb]))
|
||||
(send pb insert (new editor-snip% [editor t2]))
|
||||
(send t1 insert "abc")
|
||||
(send t2 insert "abcd")
|
||||
(expect (send t1 do-find-string-all "abcd" 'forward 0 (send t1 last-position) #t #t #t #t)
|
||||
(list* pb t2 0)))
|
||||
|
||||
(let ([t1 (new text%)]
|
||||
[t2 (new text%)]
|
||||
[t3 (new text%)]
|
||||
[pb (new pasteboard%)])
|
||||
(send t1 insert "abc")
|
||||
(send t1 insert (new editor-snip% [editor pb]))
|
||||
(send pb insert (new editor-snip% [editor t2]))
|
||||
(send pb insert (new editor-snip% [editor t3]))
|
||||
(send t1 insert "abc")
|
||||
(send t2 insert "abcd")
|
||||
(send t3 insert "abcd")
|
||||
(expect (send t1 do-find-string-all "abcd" 'forward 0 (send t1 last-position) #f #t #t #t)
|
||||
(list (list pb (list t2 0) (list t3 0)))))
|
||||
|
||||
(let ([t1 (new text%)])
|
||||
(send t1 insert "abc")
|
||||
(define es (new editor-snip%))
|
||||
(send t1 insert es)
|
||||
(send t1 insert "abc")
|
||||
(expect (send t1 do-find-string-all "abcd" 'forward 0 (send t1 last-position) #f #t #t #t)
|
||||
'()))
|
||||
|
||||
(let ([t1 (new text%)]
|
||||
[pb (new pasteboard%)])
|
||||
(send t1 insert "abc")
|
||||
(send t1 insert (new editor-snip% [editor pb]))
|
||||
(send t1 insert "abc")
|
||||
(send pb insert (new editor-snip%))
|
||||
(send pb insert (new editor-snip%))
|
||||
(expect (send t1 do-find-string-all "abcd" 'forward 0 (send t1 last-position) #f #t #t #t)
|
||||
'()))
|
||||
|
||||
(expect (send (txt "aaa") find-string-all "a") '(0 1 2)))
|
||||
|
||||
|
||||
;; ----------------------------------------
|
||||
|
||||
;; Insert very long strings to test max-string-length handling
|
||||
|
|
Loading…
Reference in New Issue
Block a user