Added integer-string? predicate
This commit is contained in:
parent
aac5209322
commit
e6074cdb4d
2 changed files with 15 additions and 0 deletions
|
@ -44,6 +44,12 @@
|
|||
(fqdn-string? (first split-string))
|
||||
(port-number? (edn/read-string (second split-string)))))))
|
||||
|
||||
(defn integer-string?
|
||||
[input]
|
||||
(and (string? input)
|
||||
(some? (re-matches #"^\d+$" input))
|
||||
(integer? (edn/read-string input))))
|
||||
|
||||
(defn string-sequence?
|
||||
[input]
|
||||
(and (sequential? input)
|
||||
|
|
|
@ -51,6 +51,15 @@
|
|||
(is (false? (cut/host-and-port-string? "test.123:1234")))
|
||||
(is (false? (cut/host-and-port-string? "test.de:abc"))))
|
||||
|
||||
(deftest test-integer-string?
|
||||
(is (true? (cut/integer-string? "1")))
|
||||
(is (true? (cut/integer-string? "42")))
|
||||
(is (false? (cut/integer-string? 42)))
|
||||
(is (false? (cut/integer-string? "42.2")))
|
||||
(is (false? (cut/integer-string? "4 2")))
|
||||
(is (false? (cut/integer-string? "1e2")))
|
||||
(is (false? (cut/integer-string? true))))
|
||||
|
||||
(deftest test-string-sequence?
|
||||
(is (true? (cut/string-sequence? ["hallo" "welt" "!"])))
|
||||
(is (false? (cut/string-sequence? ["hallo" 1 "welt" "!"])))
|
||||
|
|
Loading…
Reference in a new issue