blob: b466c08b4e3eea3615afc80691fe9a7777d3395c (
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
(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))))
(ert-deftest link-to-data ()
(should
(equal
(sx--link-to-data "http://meta.emacs.stackexchange.com/posts/comments/510?noredirect=1")
'((id . 510) (type . comment) (site_par . "meta.emacs"))))
(should
(equal
(sx--link-to-data "http://emacs.stackexchange.com/questions/7409/is-there-a-generic-toggle-previous-window-function#comment10965_7409")
'((id . 10965) (type . comment) (site_par . "emacs"))))
(should
(equal
(sx--link-to-data "http://emacs.stackexchange.com/q/7409/50")
'((id . 7409) (type . question) (site_par . "emacs"))))
(should
(equal
(sx--link-to-data "http://emacs.stackexchange.com/a/7410/50")
'((id . 7410) (type . answer) (site_par . "emacs"))))
(should
(equal
(sx--link-to-data "http://emacs.stackexchange.com/questions/7409/is-there-a-generic-toggle-previous-window-function/9999#7410")
'((id . 7410) (type . answer) (site_par . "emacs"))))
(should
(equal
(sx--link-to-data "http://emacs.stackexchange.com/questions/7409/is-there-a-generic-toggle-previous-window-function/7410")
'((id . 7410) (type . answer) (site_par . "emacs")))))
|