diff --git a/t/README b/t/README new file mode 100644 index 0000000..1a1e907 --- /dev/null +++ b/t/README @@ -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) diff --git a/t/misc.lisp b/t/misc.lisp new file mode 100644 index 0000000..1a42293 --- /dev/null +++ b/t/misc.lisp @@ -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") diff --git a/t/package.lisp b/t/package.lisp new file mode 100644 index 0000000..cc3695f --- /dev/null +++ b/t/package.lisp @@ -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) diff --git a/t/string.lisp b/t/string.lisp new file mode 100644 index 0000000..384fb9f --- /dev/null +++ b/t/string.lisp @@ -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'.") diff --git a/t/t.lisp b/t/t.lisp new file mode 100644 index 0000000..7749370 --- /dev/null +++ b/t/t.lisp @@ -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)