From 4ef2725830f4de0a7d4cb93aa66fea25384305de Mon Sep 17 00:00:00 2001 From: graur Date: Mon, 14 Nov 2022 15:43:45 +0300 Subject: [PATCH] #153 - added blank-string matcher --- .../eo/org/eolang/hamcrest/assert-that.eo | 5 ++ .../hamcrest/matchers/blank-string-matcher.eo | 49 +++++++++++++++++++ .../org/eolang/hamcrest/blank-string-tests.eo | 42 ++++++++++++++++ .../blank-string-failed-output.eo | 49 +++++++++++++++++++ 4 files changed, 145 insertions(+) create mode 100644 src/main/eo/org/eolang/hamcrest/matchers/blank-string-matcher.eo create mode 100644 src/test/eo/org/eolang/hamcrest/blank-string-tests.eo create mode 100644 src/test/eo/org/eolang/hamcrest/failed-output/blank-string-failed-output.eo diff --git a/src/main/eo/org/eolang/hamcrest/assert-that.eo b/src/main/eo/org/eolang/hamcrest/assert-that.eo index db17354..080ac41 100644 --- a/src/main/eo/org/eolang/hamcrest/assert-that.eo +++ b/src/main/eo/org/eolang/hamcrest/assert-that.eo @@ -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 @@ -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 > @ diff --git a/src/main/eo/org/eolang/hamcrest/matchers/blank-string-matcher.eo b/src/main/eo/org/eolang/hamcrest/matchers/blank-string-matcher.eo new file mode 100644 index 0000000..35267cd --- /dev/null +++ b/src/main/eo/org/eolang/hamcrest/matchers/blank-string-matcher.eo @@ -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" > @ diff --git a/src/test/eo/org/eolang/hamcrest/blank-string-tests.eo b/src/test/eo/org/eolang/hamcrest/blank-string-tests.eo new file mode 100644 index 0000000..1818fde --- /dev/null +++ b/src/test/eo/org/eolang/hamcrest/blank-string-tests.eo @@ -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" + + diff --git a/src/test/eo/org/eolang/hamcrest/failed-output/blank-string-failed-output.eo b/src/test/eo/org/eolang/hamcrest/failed-output/blank-string-failed-output.eo new file mode 100644 index 0000000..10327ca --- /dev/null +++ b/src/test/eo/org/eolang/hamcrest/failed-output/blank-string-failed-output.eo @@ -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 <Привет, 世界>" +