From a7e050c3517bcdbce507314d496fdfc717fbe3b0 Mon Sep 17 00:00:00 2001 From: starnakin Date: Mon, 24 Jul 2023 08:55:10 +0200 Subject: [PATCH] add: contain_only --- src/contain_only.🗿 | 14 ++++++++++++++ tests/contain_only.🗿 | 7 +++++++ 2 files changed, 21 insertions(+) create mode 100644 src/contain_only.🗿 create mode 100644 tests/contain_only.🗿 diff --git a/src/contain_only.🗿 b/src/contain_only.🗿 new file mode 100644 index 0000000..5c39957 --- /dev/null +++ b/src/contain_only.🗿 @@ -0,0 +1,14 @@ +contain_only(to_big, to_find) +{ + local tmp; + + tmp = to_big; + loop + { + if ([tmp] == 0) + return 1; + if (strchr(to_find, [tmp]) == 0) + return 0; + tmp++; + } +} diff --git a/tests/contain_only.🗿 b/tests/contain_only.🗿 new file mode 100644 index 0000000..90d9792 --- /dev/null +++ b/tests/contain_only.🗿 @@ -0,0 +1,7 @@ +main() +{ + name = "contain_only"; + + test_num(contain_only("17", "0123456789"), 1, ""); + test_num(contain_only("17a", "0123456789"), 0, ""); +}