Started adding tests

This commit is contained in:
Jaidyn Lev 2018-09-30 01:35:02 -05:00
parent 132708e0c4
commit b55ddaa3e5
5 changed files with 184 additions and 0 deletions

12
t/README Normal file
View File

@ -0,0 +1,12 @@
================================================================================
TESTING FOR :QOTDD
================================================================================
To test :qotdd, make just change directories into the root of the repository;
then, load `t.lisp` from there, like so:
[0]> (load "t/t.lisp")
Then, you can run the tests:
[1]> (qotdd-testing:do-all)

15
t/misc.lisp Normal file
View File

@ -0,0 +1,15 @@
;; ----------------------------------------
;; MISC.LISP
;; ----------------------------------------
(rt:deftest value-or_i
(qotdd:value-or 1 2)
1)
(rt:deftest value-or_ii
(qotdd:value-or (eq 1 2) 2)
2)
(rt:deftest iso8601
(qotdd:iso8601 3747276860)
"2018-09-30")

56
t/package.lisp Normal file
View File

@ -0,0 +1,56 @@
(defpackage :qotdd
(:use :cl)
(:export
;; PUBLIC FUNCTIONS
;;==============================
;; server.lisp
;;--------------------
:server
;; PRIVATE FUNCTIONS
;;==============================
;; misc.lisp
;;--------------------
:value-or
:iso8601
:random-item
;; quotes.lisp
;;--------------------
:get-quotes
:get-quote
:get-quote-date
:remove-quote-date
;; server.lisp
;;--------------------
:connection-get
:connection-kill
:main
:connection-msg
;; stream.lisp
;;--------------------
:read-line-until
:read-line-chunked
;; string.lisp
;;--------------------
:string-line-list
:line-list-string
:string-after-prefix
:get-line
:position-line
:nth-string
:get-colon-value
:remove-colon-value
:min-string-length
:pad-string
:getf-string
:getf-strings))
(in-package :qotdd)

69
t/string.lisp Normal file
View File

@ -0,0 +1,69 @@
;; ----------------------------------------
;; STRING.LISP
;; ----------------------------------------
;; DATA DECLARATIONS
;; ----------------------------------------
(defvar *single-line-string*
"Hiya! <3<3<3")
(defvar *multi-line-string*
"Oh, hi, how're you doing?
I hope you responded 'fine'.
Honestly, I can't hear you from here,
Hopefully your day is OK, though. <3")
(defvar *line-list*
'("Oh, hi, how're you doing?"
"I hope you responded 'fine'."
"Honestly, I can't hear you from here,"
"Hopefully your day is OK, though. <3"))
(defvar *single-line-list*
'("Hiya! <3<3<3"))
;; TESTS
;; ----------------------------------------
(rt:deftest string-line-list-i
(qotdd:string-line-list *multi-line-string*)
("Oh, hi, how're you doing?" "I hope you responded 'fine'."
"Honestly, I can't hear you from here,"
"Hopefully your day is OK, though. <3"))
(rt:deftest string-line-list-ii
(qotdd:string-line-list *single-line-string*)
("Hiya! <3<3<3"))
(rt:deftest line-list-string-i
(qotdd:line-list-string *line-list*)
"Oh, hi, how're you doing?
I hope you responded 'fine'.
Honestly, I can't hear you from here,
Hopefully your day is OK, though. <3")
(rt:deftest line-list-string-ii
(qotdd:line-list-string *single-line-list*)
"Hiya! <3<3<3")
(rt:deftest string-after-prefix-i
(qotdd:string-after-prefix "Doggo -- Pomeranian" "Doggo -- ")
"Pomeranian")
(rt:deftest string-after-prefix-ii
(qotdd:string-after-prefix "Doggo -- Pomeranian" "oggo -- ")
nil)
(rt:deftest get-line-i
(qotdd:get-line *multi-line-string* "I hope")
"I hope you responded 'fine'.")

32
t/t.lisp Normal file
View File

@ -0,0 +1,32 @@
(ql:quickload :rt)
(ql:quickload :cl-strings)
(defpackage :qotdd-testing
(:use :cl)
(:export
:do-all))
(in-package :qotdd-testing)
(defun do-all ()
"Execute all tests."
(rt:do-tests))
(load "t/package.lisp")
(load "src/misc.lisp")
(load "t/misc.lisp")
(load "src/string.lisp")
(load "t/string.lisp")
(qotdd-testing:do-all)