commit: 03cb1a2b8b6ca7d01c50966cbbc5c0a45f9be35e
parent 9040d023eaf1b34eb1b5a952a9fdcb8d363ff4e3
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Wed, 22 Jan 2025 01:22:38 +0100
test-cmd/uniq: Change from cram to tap.sh
Diffstat:
2 files changed, 42 insertions(+), 27 deletions(-)
diff --git a/test-cmd/uniq.sh b/test-cmd/uniq.sh
@@ -0,0 +1,42 @@
+#!/bin/sh
+# SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
+# SPDX-License-Identifier: MPL-2.0
+
+WD="$(dirname "$0")"
+target="${WD}/../cmd/uniq"
+plans=7
+. "$(dirname "$0")/tap.sh"
+
+t --input='' noargs '' ''
+
+foo_nl='foo
+'
+t --input="$foo_nl" stdin '' "$foo_nl"
+
+t --input="$foo_nl" stdin_dash '-' "$foo_nl"
+
+t_ltrim() {
+ "$target" "$@" | sed 's;[[:space:]]*;;'
+}
+
+t_cmd posix_cf1 \
+'1 #01 foo0 bar0 foo1 bar1
+1 #02 bar0 foo1 bar1 foo1
+1 #03 foo0 bar0 foo1 bar1
+1 #04
+2 #05 foo0 bar0 foo1 bar1
+1 #07 bar0 foo1 bar1 foo0
+' t_ltrim -c -f 1 "${WD}/uniq_0I.txt"
+
+t_args posix_df1 '#05 foo0 bar0 foo1 bar1
+' -d -f 1 "${WD}/uniq_0I.txt"
+
+t_args posix_uf1 \
+'#01 foo0 bar0 foo1 bar1
+#02 bar0 foo1 bar1 foo1
+#03 foo0 bar0 foo1 bar1
+#04
+#07 bar0 foo1 bar1 foo0
+' -u -f 1 "${WD}/uniq_0I.txt"
+
+t_args posix_ds2 '' -d -s 2 "${WD}/uniq_0I.txt"
diff --git a/test-cmd/uniq_posix.t b/test-cmd/uniq_posix.t
@@ -1,27 +0,0 @@
-#!/usr/bin/env cram
-# SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
-# SPDX-License-Identifier: MPL-2.0
-
- $ export PATH="$TESTDIR/../cmd:$PATH"
-
- $ test "$(command -v uniq)" = "$TESTDIR/../cmd/uniq"
-
- $ uniq -c -f 1 "${TESTDIR}/uniq_0I.txt"
- \s*1 #01 foo0 bar0 foo1 bar1 (re)
- \s*1 #02 bar0 foo1 bar1 foo1 (re)
- \s*1 #03 foo0 bar0 foo1 bar1 (re)
- \s*1 #04 (re)
- \s*2 #05 foo0 bar0 foo1 bar1 (re)
- \s*1 #07 bar0 foo1 bar1 foo0 (re)
-
- $ uniq -d -f 1 "${TESTDIR}/uniq_0I.txt"
- #05 foo0 bar0 foo1 bar1
-
- $ uniq -u -f 1 "${TESTDIR}/uniq_0I.txt"
- #01 foo0 bar0 foo1 bar1
- #02 bar0 foo1 bar1 foo1
- #03 foo0 bar0 foo1 bar1
- #04
- #07 bar0 foo1 bar1 foo0
-
- $ uniq -d -s 2 "${TESTDIR}/uniq_0I.txt"