aboutsummaryrefslogtreecommitdiff
path: root/test/test-util.el
blob: 1e3dc2b7ee5f7eb5bc19306236516d48cc4d8c5f (plain) (blame)
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
(ert-deftest thing-as-string ()
  "Test `sx--thing-as-string'"
  (should
   (string= (sx--thing-as-string
             '(hello world (this is a test))
             '(";" "+"))
            "hello;world;this+is+a+test"))
  (should
   (string= (sx--thing-as-string
             '(this is a test) '(";" "+"))
            "this;is;a;test"))
  (should
   (string= (sx--thing-as-string
             '(this is a test) "+")
            "this+is+a+test"))
  (should
   (string= (sx--thing-as-string
             '(this is a test))
            "this;is;a;test"))
  (should
   (string= (sx--thing-as-string
             'test)
            "test"))
  (should
   (string= (sx--thing-as-string
             'test&)
            "test&"))
  (should
   (string= (sx--thing-as-string
             'test& nil t)
            "test%26")))

(ert-deftest tree ()
  (should
   (equal
    (sx--tree-expand
     (lambda (path) (mapconcat #'symbol-name path "."))
     '(a b (c d (e f g) h i (j k) l) m (n o) p))
    '("a" "b" "c.d" "c.e.f" "c.e.g" "c.h" "c.i" "c.j.k" "c.l" "m" "n.o" "p")))
  (should
   (equal
    (sx--tree-expand
     (lambda (path) (intern (mapconcat #'symbol-name path "/")))
     '(a b (c d (e f g) h i (j k) l) m (n o) p))
    '(a b c/d c/e/f c/e/g c/h c/i c/j/k c/l m n/o p))))