busybox/testsuite/unexpand.tests
<<
>>
Prefs
   1#!/bin/sh
   2# Copyright 2008 by Denys Vlasenko
   3# Licensed under GPLv2, see file LICENSE in this source tree.
   4
   5. ./testing.sh
   6test -f "$bindir/.config" && . "$bindir/.config"
   7
   8# testing "test name" "options" "expected result" "file input" "stdin"
   9
  10testing "unexpand case 1" "unexpand" \
  11        "\t12345678\n" "" "        12345678\n" \
  12
  13testing "unexpand case 2" "unexpand" \
  14        "\t 12345678\n" "" "         12345678\n" \
  15
  16testing "unexpand case 3" "unexpand" \
  17        "\t  12345678\n" "" "          12345678\n" \
  18
  19testing "unexpand case 4" "unexpand" \
  20        "\t12345678\n" "" "       \t12345678\n" \
  21
  22testing "unexpand case 5" "unexpand" \
  23        "\t12345678\n" "" "      \t12345678\n" \
  24
  25testing "unexpand case 6" "unexpand" \
  26        "\t12345678\n" "" "     \t12345678\n" \
  27
  28testing "unexpand case 7" "unexpand" \
  29        "123\t 45678\n" "" "123 \t 45678\n" \
  30
  31testing "unexpand case 8" "unexpand" \
  32        "a b\n" "" "a b\n" \
  33
  34testcase()
  35{
  36        testing "unexpand flags $*" "unexpand $*" \
  37                "$want" "" '        a       b    c'
  38}
  39
  40# tabs=8, Convert only leading sequences of blanks
  41want='\ta       b    c'
  42testcase
  43testcase -f
  44testcase -f -t8
  45testcase -t8 -f
  46testcase -t8 --first-only
  47
  48# tabs=8, Convert all blanks
  49want='\ta\tb    c'
  50testcase -a
  51testcase -t8
  52testcase -a -t8
  53
  54# tabs=4, Convert all blanks
  55want='\t\ta\t\tb\t c'
  56testcase -t4
  57testcase -a -t4
  58testcase -t4 -a
  59
  60# tabs=4, Convert only leading sequences of blanks
  61want='\t\ta       b    c'
  62testcase -t4 -f
  63testcase -f -t4
  64testcase -t4 --first-only
  65testcase --first-only -t4
  66
  67test x"$CONFIG_UNICODE_SUPPORT" = x"y" \
  68&& test x"$CONFIG_UNICODE_USING_LOCALE" != x"y" \
  69&& testing "unexpand with unicode characher 0x394" "unexpand" \
  70        "1ΔΔΔ5\t99999\n" "" "1ΔΔΔ5   99999\n"
  71
  72exit $FAILCOUNT
  73