Browse code

Started adding tests

Jaidyn Lev authored on 2018-09-30 06:35:02
Showing 5 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,12 @@
1
+================================================================================
2
+TESTING FOR :QOTDD
3
+================================================================================
4
+
5
+To test :qotdd, make just change directories into the root of the repository;
6
+then, load `t.lisp` from there, like so:
7
+
8
+	[0]> (load "t/t.lisp")
9
+
10
+Then, you can run the tests:
11
+
12
+	[1]> (qotdd-testing:do-all)
0 13
new file mode 100644
... ...
@@ -0,0 +1,15 @@
1
+;; ----------------------------------------
2
+;; MISC.LISP
3
+;; ----------------------------------------
4
+
5
+(rt:deftest value-or_i
6
+            (qotdd:value-or 1 2)
7
+            1)
8
+
9
+(rt:deftest value-or_ii
10
+            (qotdd:value-or (eq 1 2) 2)
11
+            2)
12
+
13
+(rt:deftest iso8601
14
+            (qotdd:iso8601 3747276860)
15
+            "2018-09-30")
0 16
new file mode 100644
... ...
@@ -0,0 +1,56 @@
1
+(defpackage :qotdd
2
+  (:use :cl)
3
+  (:export 
4
+
5
+    ;; PUBLIC FUNCTIONS
6
+    ;;============================== 
7
+
8
+    ;; server.lisp
9
+    ;;-------------------- 
10
+    :server
11
+
12
+
13
+    ;; PRIVATE FUNCTIONS
14
+    ;;============================== 
15
+
16
+    ;; misc.lisp
17
+    ;;-------------------- 
18
+    :value-or
19
+    :iso8601
20
+    :random-item
21
+
22
+    ;; quotes.lisp
23
+    ;;-------------------- 
24
+    :get-quotes
25
+    :get-quote
26
+    :get-quote-date
27
+    :remove-quote-date
28
+    
29
+    ;; server.lisp
30
+    ;;-------------------- 
31
+    :connection-get
32
+    :connection-kill
33
+    :main
34
+    :connection-msg
35
+
36
+    ;; stream.lisp
37
+    ;;-------------------- 
38
+    :read-line-until
39
+    :read-line-chunked
40
+
41
+    ;; string.lisp
42
+    ;;-------------------- 
43
+    :string-line-list
44
+    :line-list-string
45
+    :string-after-prefix
46
+    :get-line
47
+    :position-line
48
+    :nth-string
49
+    :get-colon-value
50
+    :remove-colon-value
51
+    :min-string-length
52
+    :pad-string
53
+    :getf-string
54
+    :getf-strings))
55
+
56
+(in-package :qotdd)
0 57
new file mode 100644
... ...
@@ -0,0 +1,69 @@
1
+;; ----------------------------------------
2
+;; STRING.LISP
3
+;; ----------------------------------------
4
+
5
+
6
+;; DATA DECLARATIONS
7
+;; ----------------------------------------
8
+
9
+(defvar *single-line-string*
10
+  "Hiya! <3<3<3")
11
+
12
+(defvar *multi-line-string*
13
+  "Oh, hi, how're you doing?
14
+I hope you responded 'fine'.
15
+Honestly, I can't hear you from here,
16
+Hopefully your day is OK, though. <3")
17
+
18
+(defvar *line-list*
19
+  '("Oh, hi, how're you doing?"
20
+   "I hope you responded 'fine'."
21
+   "Honestly, I can't hear you from here,"
22
+   "Hopefully your day is OK, though. <3"))
23
+
24
+(defvar *single-line-list*
25
+  '("Hiya! <3<3<3"))
26
+
27
+
28
+
29
+;; TESTS
30
+;; ----------------------------------------
31
+
32
+(rt:deftest string-line-list-i
33
+            (qotdd:string-line-list *multi-line-string*)
34
+            ("Oh, hi, how're you doing?" "I hope you responded 'fine'."
35
+             "Honestly, I can't hear you from here,"
36
+             "Hopefully your day is OK, though. <3"))
37
+
38
+(rt:deftest string-line-list-ii
39
+            (qotdd:string-line-list *single-line-string*)
40
+            ("Hiya! <3<3<3"))
41
+
42
+
43
+
44
+(rt:deftest line-list-string-i
45
+            (qotdd:line-list-string *line-list*)
46
+            "Oh, hi, how're you doing?
47
+I hope you responded 'fine'.
48
+Honestly, I can't hear you from here,
49
+Hopefully your day is OK, though. <3")
50
+
51
+(rt:deftest line-list-string-ii
52
+            (qotdd:line-list-string *single-line-list*)
53
+            "Hiya! <3<3<3")
54
+
55
+
56
+
57
+(rt:deftest string-after-prefix-i
58
+            (qotdd:string-after-prefix "Doggo -- Pomeranian" "Doggo -- ")
59
+            "Pomeranian")
60
+
61
+(rt:deftest string-after-prefix-ii
62
+            (qotdd:string-after-prefix "Doggo -- Pomeranian" "oggo -- ")
63
+            nil)
64
+
65
+
66
+
67
+(rt:deftest get-line-i
68
+            (qotdd:get-line *multi-line-string* "I hope")
69
+            "I hope you responded 'fine'.")
0 70
new file mode 100644
... ...
@@ -0,0 +1,32 @@
1
+(ql:quickload :rt)
2
+(ql:quickload :cl-strings)
3
+
4
+
5
+
6
+(defpackage :qotdd-testing
7
+  (:use :cl)
8
+  (:export
9
+
10
+    :do-all))
11
+
12
+(in-package :qotdd-testing)
13
+
14
+
15
+
16
+(defun do-all ()
17
+  "Execute all tests."
18
+
19
+  (rt:do-tests))
20
+
21
+
22
+
23
+
24
+(load "t/package.lisp")
25
+
26
+(load "src/misc.lisp")
27
+(load "t/misc.lisp")
28
+
29
+(load "src/string.lisp")
30
+(load "t/string.lisp")
31
+
32
+(qotdd-testing:do-all)