File: string.wrap.scm

package info (click to toggle)
guile-lib 0.2.6.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,868 kB
  • sloc: lisp: 6,986; sh: 3,962; makefile: 195
file content (68 lines) | stat: -rw-r--r-- 3,099 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
;;; ----------------------------------------------------------------------
;;;    unit test
;;;    Copyright (C) 2003 Richard Todd
;;;
;;;    This program is free software; you can redistribute it and/or modify
;;;    it under the terms of the GNU General Public License as published by
;;;    the Free Software Foundation; either version 2 of the License, or
;;;    (at your option) any later version.
;;;
;;;    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.  See the
;;;    GNU General Public License for more details.
;;;
;;;    You should have received a copy of the GNU General Public License
;;;    along with this program; if not, write to the Free Software
;;;    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
;;; ----------------------------------------------------------------------
(use-modules (string wrap)
             (srfi srfi-13)
             (unit-test)
             (oop goops))


;; **********************************************************************
;; Test of the object itself...
;; **********************************************************************
(define-class <test-string-wrapper> (<test-case>)
  (str  #:accessor test-string))

(define-method (set-up-test (tw <test-string-wrapper>))
  (set! (test-string tw)
"
The last language environment specified with 
`set-language-environment'.   This variable should be 
set only with M-x customize, which is equivalent
to using the function `set-language-environment'.
"))

(define-method (test-util-equivalent-to-class (tw <test-string-wrapper>))
  (assert-equal (fill-string (test-string tw))
                (fill-string (make <text-wrapper>) (test-string tw)))
  (assert-equal (fill-string (test-string tw) #:line-width 20)
                (fill-string (make <text-wrapper> #:line-width 20) (test-string tw)))
  (assert-equal (fill-string (test-string tw) #:initial-indent " * " #:tab-width 3)
                (fill-string (make <text-wrapper> #:initial-indent " * " #:tab-width 3) (test-string tw))))
                
(define-method (test-fill-equivalent-to-joined-lines (tw <test-string-wrapper>))
  (assert-equal (fill-string (test-string tw))
                (string-join (string->wrapped-lines (test-string tw)) "\n" 'infix)))

(define-method (test-no-collapse-ws (tw <test-string-wrapper>))
  (assert-equal (fill-string (test-string tw) #:collapse-whitespace? #f)
"The last language environment specified with  `set-language-environment'.   This
variable should be  set only with M-x customize, which is equivalent to using
the function `set-language-environment'."))

(define-method (test-no-word-break (tw <test-string-wrapper>))
  (assert-equal "thisisalongword
blah
blah"
                (fill-string "thisisalongword blah blah"
                             #:line-width 8
                             #:break-long-words? #f)))

(exit-with-summary (run-all-defined-test-cases))

;;; arch-tag: 03aff8ef-c04c-4fdc-99fa-be36a5faaebf