Skip to content

Commit

Permalink
objectionary#153 - added blank-string matcher
Browse files Browse the repository at this point in the history
  • Loading branch information
Graur committed Nov 14, 2022
1 parent 65c8377 commit 4ef2725
Show file tree
Hide file tree
Showing 4 changed files with 145 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/main/eo/org/eolang/hamcrest/assert-that.eo
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
+alias org.eolang.hamcrest.matchers.any-of-matcher
+alias org.eolang.hamcrest.matchers.anything-matcher
+alias org.eolang.hamcrest.matchers.array-each-matcher
+alias org.eolang.hamcrest.matchers.blank-string-matcher
+alias org.eolang.hamcrest.matchers.close-to-matcher
+alias org.eolang.hamcrest.matchers.contains-string-matcher
+alias org.eolang.hamcrest.matchers.described-as-matcher
Expand Down Expand Up @@ -160,3 +161,7 @@
[str] > is-substring
is-substring-matcher > @
str

# Tests if the examined string contains zero or more whitespace characters and nothing else.
[] > blank-string
blank-string-matcher > @
49 changes: 49 additions & 0 deletions src/main/eo/org/eolang/hamcrest/matchers/blank-string-matcher.eo
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# MIT License
#
# Copyright (c) 2022 Graur Andrew
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

+alias org.eolang.txt.text
+alias sprintf org.eolang.txt.sprintf
+home https://github.com/objectionary/eo-hamcrest
+package org.eolang.hamcrest.matchers
+rt jvm org.eolang:eo-hamcrest:0.0.0
+version 0.0.0

# Tests if the examined string contains zero or more whitespace characters and nothing else.
[] > blank-string-matcher

[a] > match
text a > str!
or. > @
eq.
str
""
eq.
str
" "

[act] > describe-mismatch
sprintf > @
"was <%s>"
act

[] > description-of
"blank string" > @
42 changes: 42 additions & 0 deletions src/test/eo/org/eolang/hamcrest/blank-string-tests.eo
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# MIT License
#
# Copyright (c) 2020-2022 Graur Andrew
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

+alias org.eolang.hamcrest.assert-that
+home https://github.com/objectionary/eo-hamcrest
+junit
+package org.eolang.hamcrest
+version 0.0.0

[] > simple-blank-string
assert-that > @
""
$.blank-string
"simple-blank-string"

[] > simple-blank-string-with-space
assert-that > @
" "
$.is
$.blank-string
"simple-blank-string-with-space"


Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# MIT License
#
# Copyright (c) 2020-2022 Graur Andrew
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

+alias org.eolang.hamcrest.assert-that
+home https://github.com/objectionary/eo-hamcrest
+junit
+package org.eolang.hamcrest.failed-output
+version 0.0.0

[] > simple-blank-string-failed
[] > suggestion
assert-that > @
"Привет, 世界"
$.blank-string
"simple-blank-string"
assert-that > @
suggestion
$.equal-to "simple-blank-string\nExpected: blank string\n but: was <Привет, 世界>"

[] > is-blank-string-failed
[] > suggestion
assert-that > @
"Привет, 世界"
$.is
$.blank-string
"simple-blank-string"
assert-that > @
suggestion
$.equal-to "simple-blank-string\nExpected: is blank string\n but: was <Привет, 世界>"

0 comments on commit 4ef2725

Please sign in to comment.