-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8b85fbe
commit a51fa6a
Showing
8 changed files
with
179 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
(in-package #:lqn-tests) | ||
|
||
(plan 3) | ||
(subtest "types" | ||
|
||
(is (lqn:read? "abc") 'abc) | ||
|
||
; FLT FLT FLT | ||
(is (lqn:flt! "1.0") 1.0) | ||
(is (lqn:flt! "1d0") 1.0) | ||
(is (lqn:flt! 1.0) 1.0) | ||
(is (lqn:flt! 1d0) 1.0) | ||
(is (lqn:flt!? "1") 1.0) | ||
(is (lqn:flt!? "1.0") 1.0) | ||
(is (lqn:flt!? "1d0") 1.0) | ||
(is (lqn:flt!? 1) 1.0) | ||
(is (lqn:flt!? 1.0) 1.0) | ||
(is (lqn:flt!? 1d0) 1.0) | ||
(is (lqn:flt? "1.0") nil) | ||
(is (lqn:flt? "1d0") nil) | ||
(is (lqn:flt? 1) nil) | ||
(is (lqn:flt? 1.0) 1.0) | ||
(is (lqn:flt? 1d0) 1.0) | ||
|
||
; INT INT INT | ||
(is (lqn:int! "1") 1) | ||
(is (lqn:int! 1) 1) | ||
(is (lqn:int!? "1") 1) | ||
(is (lqn:int!? "1.0" nil t) nil) | ||
(is (lqn:int!? "1.0") 1) | ||
(is (lqn:int!? "1d0" nil t) nil) | ||
(is (lqn:int!? "1d0") 1) | ||
(is (lqn:int!? 1) 1) | ||
(is (lqn:int!? 1.0 nil t) nil) | ||
(is (lqn:int!? 1.0) 1) | ||
(is (lqn:int!? 1d0 nil t) nil) | ||
(is (lqn:int!? 1d0) 1) | ||
(is (lqn:int? "1") nil) | ||
(is (lqn:int? 1) 1) | ||
(is (lqn:int? 1.0) nil) | ||
(is (lqn:int? 1d0) nil) | ||
|
||
(is (lqn:read? "1") 1) | ||
(is (lqn:read? ":AAA") :AAA) | ||
(is (lqn:read? "\"AAA\" ") "AAA") | ||
(is (lqn:read? "\"1\" ") "1") | ||
|
||
(is (lqn:str!? "1") "1") | ||
(is (lqn:str!? ":AAA") ":AAA") | ||
(is (lqn:str!? "\"AAA\"") "AAA") | ||
(is (lqn:str!? "\"1\"") "1") | ||
|
||
(is (lqn:str? "1") "1") | ||
(is (lqn:str? ":AAA") ":AAA") | ||
(is (lqn:str? "\"AAA\"") "\"AAA\"") | ||
(is (lqn:str? "\"1\"") "\"1\"") | ||
|
||
; SYM SYM SYM | ||
(is (lqn:ssym? nil) nil) | ||
(is (lqn:ssym? 1) nil) | ||
(is (lqn:ssym? 'aa) 'aa) | ||
(is (lqn:ssym? :aa) nil) | ||
) | ||
|
||
(subtest "utils" | ||
(is (lqn:sub? "aabb" "ab") "aabb") | ||
(is (lqn:sub? "aabb" "abc") nil) | ||
(is (lqn:sub? "AABB" "ab") nil) | ||
(is (lqn:isub? "AABB" "ab") "AABB") | ||
(is (lqn:isub? "AABB" "abc") nil) | ||
(is (lqn:pref? "AABB" "AA") "AABB") | ||
(is (lqn:ipref? "AABB" "aa") "AABB") | ||
(is (lqn:suf? "AABB" "BB") "AABB") | ||
(is (lqn:suf? "AABB" "bb") nil) | ||
(is (lqn:isuf? "AABB" "bb") "AABB") | ||
(is (lqn::ct/kw/str "AABB") "AABB") | ||
(is (lqn::ct/kw/str :AABB) "aabb") | ||
(is (lqn::ct/kw/str 'AABB) 'AABB) | ||
(is (lqn::ct/kw/str (+ 1 2)) 3) | ||
(is (lqn::ct/kw/str (progn 'abc)) 'abc) | ||
(is (lqn:msym? 'aa 'aa) 'aa) | ||
(is (lqn:msym? 'aa :aa) nil) | ||
(is (lqn:msym? 'aabb "ab") 'aabb) | ||
(is (lqn:msym? 'aabb (progn "ab")) nil) | ||
(is (lqn:msym? 'aabb (progn 'aabb)) 'aabb) | ||
(is (lqn:msym? 'AABB (progn 'aabb)) 'aabb) | ||
(is (lqn:msym? :AABB (progn :aabb)) :aabb) | ||
(is (lqn::unpack-mode "?@fxfx") '(:? "fxfx")) | ||
(is (lqn::unpack-mode '?@fxfx) '(:? fxfx)) | ||
(is (lqn::unpack-mode '(?@fxfx)) '(:? (fxfx))) | ||
(is (lqn::unpack-mode '(:? fxfx)) '(:? fxfx)) | ||
(is (lqn::unpack-mode '(:?@fxfx)) '(:? (:fxfx))) | ||
(is (lqn::unpack-mode '(fxfx :ss)) '(:+ (fxfx :ss))) | ||
(is (lqn::unpack-mode "fxfx") '(:+ "fxfx")) | ||
(is (lqn::unpack-mode 'fxfx :y) '(:y fxfx)) | ||
(is (lqn::unpack-mode 'fxfx :y) '(:y fxfx))) | ||
|
||
(subtest "io" | ||
(is (lqn:ldnout *test-data-raw*) *test-data-raw* :test #'equalp) | ||
(is (lqn:ldnout (lqn:jsnloadf *test-data-fn*)) *test-data-raw* :test #'equalp) | ||
(is-str (lqn::jsnstr (lqn:jsnloadf *test-data-fn*)) | ||
"[{\"_id\":\"65679d23d38d711eaf999e89\",\"index\":0,\"things\":[{\"id\":0,\"name\":\"Chris\",\"extra\":\"extra99\"}],\"msg\":\"this is a message\",\"fave\":\"strawberry\"},{\"_id\":\"65679d23fe33bc4c240675c0\",\"index\":1,\"things\":[{\"id\":10,\"name\":\"Winters\",\"extra\":\"extra1\"},{\"id\":11,\"name\":\"Haii\",\"extra\":\"extra2\"},{\"id\":12,\"name\":\"Klein\"}],\"msg\":\"Hello, undefined! You have 1 unread messages.\",\"fave\":\"strawberry\"},{\"_id\":\"65679d235b4143d2932ea17a\",\"things\":[{\"id\":31,\"name\":\"Star\"},{\"id\":32,\"name\":\"Ball\"}],\"msg\":\"Hello, undefined! You have 5 unread messages.\",\"fave\":\"blueberry\"}]") | ||
(is (lqn:ldnout *test-data-2-raw*) *test-data-2-raw* :test #'equalp) | ||
(is (lqn:ldnout (lqn:jsnloadf *test-data-2-fn*)) *test-data-2-raw* :test #'equalp) | ||
(is-str (lqn::jsnstr (lqn:jsnloadf *test-data-2-fn*)) | ||
"{\"credit\":\"Mega Corp.\",\"credit_URL\":\"http://fax.megacorp\",\"disclaimer_url\":null,\"copyright_url\":\"http://fax.megacorp/about/terms.asp\",\"image\":{\"url\":\"http://fax.megacorp/images/Logo.jpg\",\"title\":\"Mega Corp\",\"link\":\"http://fax.megacorp/yyyyyyyyy\"},\"suggested_pickup\":\"15 minutes after the hour\",\"suggested_pickup_period\":\"60\",\"dewpoint_c\":-22.2,\"dewpoint_f\":null,\"dewpoint_string\":\"-8.0 F (-22.2 C)\",\"heat_index_c\":-20.6,\"heat_index_f\":-5.0,\"heat_index_string\":\"-5.0 F (-20.6 C)\",\"observation_time\":\"Last Updated on Dec 5 2023, 9:37 pm CET\",\"current_observation\":{\"station_name\":\"Gulhuset\",\"observation_age\":42,\"dewpoint_day_high_f\":\"-7\",\"dewpoint_day_high_time\":\"8:47pm\",\"dewpoint_day_low_f\":-8.0,\"windchill_month_low_f\":-9,\"windchill_year_low_f\":-9},\"time_to_generate\":0.012046}") | ||
(is (lqn:sdwn (lqn::jsnstr (lqn:jsnloadf *test-data-2-fn*))) | ||
(lqn:sdwn (lqn::jsnstr *test-data-2-raw*)))) | ||
|
||
(unless (finalize) (error "error in test-utils")) | ||
|