]> gitweb.factorcode.org Git - factor.git/blob - basis/wrap/strings/strings-tests.factor
factor: rename [ ] [ ] unit-test -> { } [ ] unit-test using a refactoring tool!
[factor.git] / basis / wrap / strings / strings-tests.factor
1 ! Copyright (C) 2008, 2009 Daniel Ehrenberg, Slava Pestov
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: kernel tools.test wrap.strings ;
4 IN: wrap.strings.tests
5
6 {
7     """This is a
8 long piece
9 of text
10 that we
11 wish to
12 word wrap."""
13 } [
14     """This is a long piece of text that we wish to word wrap.""" 10
15     wrap-string
16 ] unit-test
17
18 {
19     """  This is a
20   long piece
21   of text
22   that we
23   wish to
24   word wrap."""
25 } [
26     """This is a long piece of text that we wish to word wrap.""" 12
27     "  " wrap-indented-string
28 ] unit-test
29
30 { t } [
31     """This is a long piece of text that we wish to word wrap.""" 12
32     [ "  " wrap-indented-string ] [ 2 wrap-indented-string ] 2bi =
33 ] unit-test
34
35 { "this text\nhas lots of\nspaces" }
36 [ "this text        has lots of       spaces" 12 wrap-string ] unit-test
37
38 { "hello\nhow\nare\nyou\ntoday?" }
39 [ "hello how are you today?" 3 wrap-string ] unit-test
40
41 { "aaa\nbb cc\nddddd" } [ "aaa bb cc ddddd" 6 wrap-string ] unit-test
42 { "aaa\nbb ccc\ndddddd" } [ "aaa bb ccc dddddd" 6 wrap-string ] unit-test
43 { "aaa bb\ncccc\nddddd" } [ "aaa bb cccc ddddd" 6 wrap-string ] unit-test
44 { "aaa bb\nccccccc\nddddddd" } [ "aaa bb ccccccc ddddddd" 6 wrap-string ] unit-test
45
46 { "a b c d e f\ng h" } [ "a b c d e f g h" 11 wrap-string ] unit-test
47
48 { "" } [ "" 10 wrap-string ] unit-test
49 { "Hello" } [ "\nHello\n" 10 wrap-string ] unit-test
50
51 { " > > > " } [ "" 70 " > > > " wrap-indented-string ] unit-test