summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKerin Millar <kfm@plushkava.net>2024-06-11 06:26:41 +0100
committerKerin Millar <kfm@plushkava.net>2024-06-14 01:27:44 +0100
commit449fed1c13525c8420b4366014ba34616cb20239 (patch)
treed80dfc5d0777e9c30179e8088a3e503eb770b978 /test-functions
parentAdd the from_unit() function (diff)
downloadgentoo-functions-449fed1c13525c8420b4366014ba34616cb20239.tar.gz
gentoo-functions-449fed1c13525c8420b4366014ba34616cb20239.tar.bz2
gentoo-functions-449fed1c13525c8420b4366014ba34616cb20239.zip
Add the is_anyof() and is_subset() functions
Examples follow. is_anyof y x y z # returns 0 is_anoyf y x w z # returns 1 is_subset x y -- x y z # returns 0 is_subset x y z -- z y x # returns 0 is_subset x y -- x w z # returns 1 Signed-off-by: Kerin Millar <kfm@plushkava.net>
Diffstat (limited to 'test-functions')
-rwxr-xr-xtest-functions49
1 files changed, 49 insertions, 0 deletions
diff --git a/test-functions b/test-functions
index 1a2eb81..0b987ab 100755
--- a/test-functions
+++ b/test-functions
@@ -575,6 +575,53 @@ test_parallel_run() {
iterate_tests 4 "$@"
}
+test_is_anyof() {
+ set -- \
+ ge 1 N/A N/A N/A \
+ ge 1 x N/A N/A \
+ ge 1 x y N/A \
+ ge 1 x y z \
+ eq 0 x x N/A \
+ eq 0 x x y \
+ eq 0 x y x
+
+ callback() {
+ shift
+ test_description="is_anyof $(quote_args "$@")"
+ is_anyof "$@"
+ }
+
+ iterate_tests 5 "$@"
+}
+
+test_is_subset() {
+ set -- \
+ ge 1 N/A N/A N/A N/A N/A \
+ ge 1 -- N/A N/A N/A N/A \
+ ge 1 -- -- N/A N/A N/A \
+ ge 1 -- x N/A N/A N/A \
+ ge 1 x -- N/A N/A N/A \
+ ge 1 x y N/A N/A N/A \
+ ge 1 x y x N/A N/A \
+ eq 0 x -- x N/A N/A \
+ eq 0 x -- x y N/A \
+ eq 0 x -- y x N/A \
+ eq 0 x y -- x y \
+ eq 0 x y -- y x \
+ ge 1 x y -- x z \
+ ge 1 y x -- z x \
+ ge 1 x z -- x y \
+ ge 1 z x -- y x
+
+ callback() {
+ shift
+ test_description="is_subset $(quote_args "$@")"
+ is_subset "$@"
+ }
+
+ iterate_tests 7 "$@"
+}
+
iterate_tests() {
slice_width=$1
shift
@@ -641,6 +688,8 @@ test_trim || rc=1
test_hr || rc=1
test_whenceforth || rc=1
test_parallel_run || rc=1
+test_is_anyof || rc=1
+test_is_subset || rc=1
cleanup_tmpdir