summaryrefslogtreecommitdiff
path: root/tests/uniq
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1998-12-13 19:01:59 +0000
committerJim Meyering <jim@meyering.net>1998-12-13 19:01:59 +0000
commit8a644a90ef21d698559f30ccfe475a14c0d1e242 (patch)
tree3963e2c381ac60c41846abe535e0c68aa11712ca /tests/uniq
parent29ab746b7919d8cc48a0896b4ca9b92da5152de0 (diff)
downloadcoreutils-8a644a90ef21d698559f30ccfe475a14c0d1e242.tar.xz
.
Diffstat (limited to 'tests/uniq')
-rw-r--r--tests/uniq/.cvsignore8
-rw-r--r--tests/uniq/Makefile.am46
-rw-r--r--tests/uniq/Makefile.in250
-rw-r--r--tests/uniq/Test.pm76
4 files changed, 380 insertions, 0 deletions
diff --git a/tests/uniq/.cvsignore b/tests/uniq/.cvsignore
new file mode 100644
index 000000000..852508156
--- /dev/null
+++ b/tests/uniq/.cvsignore
@@ -0,0 +1,8 @@
+*.I
+*.E
+*.X
+*.O
+*-tests
+build-script
+Makefile
+mk-script
diff --git a/tests/uniq/Makefile.am b/tests/uniq/Makefile.am
new file mode 100644
index 000000000..c2f7bcbd9
--- /dev/null
+++ b/tests/uniq/Makefile.am
@@ -0,0 +1,46 @@
+## Process this file with automake to produce Makefile.in -*-Makefile-*-.
+
+##test-files-begin
+x = uniq
+explicit =
+maint_gen = 1.I 1.X 2.I 2.X 3.I 3.X 4.I 4.X 5.I 5.X 6.I 6.X 7.I 7.X 8.I 8.X \
+9.I 9.X 10.I 10.X 11.I 11.X 12.I 12.X 13.I 13.X 20.I 20.X 21.I 21.X 22.I 22.X \
+23.I 23.X 30.I 30.X 31.I 31.X 32.I 32.X 33.I 33.X 34.I 34.X 35.I 35.X 40.I \
+40.X 41.I 41.X 42.I 42.X 43.I 43.X 44.I 44.X 45.I 45.X 50.I 50.X 51.I 51.X \
+52.I 52.X 53.I 53.X 60.I 60.X 61.I 61.X 62.I 62.X 63.I 63.X 64.I 64.X 65.I \
+65.X 101.I 101.X 102.I 102.X
+run_gen = 1.O 1.E 2.O 2.E 3.O 3.E 4.O 4.E 5.O 5.E 6.O 6.E 7.O 7.E 8.O 8.E 9.O \
+9.E 10.O 10.E 11.O 11.E 12.O 12.E 13.O 13.E 20.O 20.E 21.O 21.E 22.O 22.E \
+23.O 23.E 30.O 30.E 31.O 31.E 32.O 32.E 33.O 33.E 34.O 34.E 35.O 35.E 40.O \
+40.E 41.O 41.E 42.O 42.E 43.O 43.E 44.O 44.E 45.O 45.E 50.O 50.E 51.O 51.E \
+52.O 52.E 53.O 53.E 60.O 60.E 61.O 61.E 62.O 62.E 63.O 63.E 64.O 64.E 65.O \
+65.E 101.O 101.E 102.O 102.E
+##test-files-end
+
+EXTRA_DIST = Test.pm $x-tests $(explicit) $(maint_gen)
+noinst_SCRIPTS = $x-tests
+
+PERL = @PERL@
+editpl = sed -e 's,@''PERL''@,$(PERL),g' -e 's,@''srcdir''@,@srcdir@,g'
+
+TESTS = $x-tests
+
+mk_script = $(srcdir)/../mk-script
+$(srcdir)/$x-tests: $(mk_script) Test.pm
+ $(PERL) -I. -w -- $(mk_script) ../../src/$x > $@.n
+ mv $@.n $@
+ chmod 755 $@
+
+MAINTAINERCLEANFILES = $x-tests $(maint_gen)
+CLEANFILES = $(run_gen)
+
+check: $(maint_gen)
+
+Makefile.am: ../Makefile.am.in Test.pm $(mk_script)
+ rm -f $@ $@t
+ sed -n '1,/^##test-files-begin/p' $< > $@t
+ tool=`echo $(subdir)|sed 's/^tests.//;s/-test//'`; \
+ echo "x = $$tool" >> $@t
+ $(PERL) -I. -w -- $(mk_script) --list >> $@t
+ sed -n '/^##test-files-end/,$$p' $< >> $@t
+ mv $@t $@
diff --git a/tests/uniq/Makefile.in b/tests/uniq/Makefile.in
new file mode 100644
index 000000000..95a3a3652
--- /dev/null
+++ b/tests/uniq/Makefile.in
@@ -0,0 +1,250 @@
+# Makefile.in generated automatically by automake 1.3b from Makefile.am
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+
+SHELL = /bin/sh
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+
+bindir = @bindir@
+sbindir = @sbindir@
+libexecdir = @libexecdir@
+datadir = @datadir@
+sysconfdir = @sysconfdir@
+sharedstatedir = @sharedstatedir@
+localstatedir = @localstatedir@
+libdir = @libdir@
+infodir = @infodir@
+mandir = @mandir@
+includedir = @includedir@
+oldincludedir = /usr/include
+
+DESTDIR =
+
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+
+top_builddir = ../..
+
+ACLOCAL = @ACLOCAL@
+AUTOCONF = @AUTOCONF@
+AUTOMAKE = @AUTOMAKE@
+AUTOHEADER = @AUTOHEADER@
+
+INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+transform = @program_transform_name@
+
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+CATALOGS = @CATALOGS@
+CATOBJEXT = @CATOBJEXT@
+CC = @CC@
+CPP = @CPP@
+DATADIRNAME = @DATADIRNAME@
+GENCAT = @GENCAT@
+GMOFILES = @GMOFILES@
+GMSGFMT = @GMSGFMT@
+GT_NO = @GT_NO@
+GT_YES = @GT_YES@
+INCLUDE_LOCALE_H = @INCLUDE_LOCALE_H@
+INSTOBJEXT = @INSTOBJEXT@
+INTLDEPS = @INTLDEPS@
+INTLLIBS = @INTLLIBS@
+INTLOBJS = @INTLOBJS@
+LIBOBJS = @LIBOBJS@
+MAKEINFO = @MAKEINFO@
+MKINSTALLDIRS = @MKINSTALLDIRS@
+MSGFMT = @MSGFMT@
+PACKAGE = @PACKAGE@
+POFILES = @POFILES@
+POSUB = @POSUB@
+POW_LIBM = @POW_LIBM@
+RANLIB = @RANLIB@
+U = @U@
+USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@
+USE_NLS = @USE_NLS@
+VERSION = @VERSION@
+l = @l@
+
+x = uniq
+explicit =
+maint_gen = 1.I 1.X 2.I 2.X 3.I 3.X 4.I 4.X 5.I 5.X 6.I 6.X 7.I 7.X 8.I 8.X \
+9.I 9.X 10.I 10.X 11.I 11.X 12.I 12.X 13.I 13.X 20.I 20.X 21.I 21.X 22.I 22.X \
+23.I 23.X 30.I 30.X 31.I 31.X 32.I 32.X 33.I 33.X 34.I 34.X 35.I 35.X 40.I \
+40.X 41.I 41.X 42.I 42.X 43.I 43.X 44.I 44.X 45.I 45.X 50.I 50.X 51.I 51.X \
+52.I 52.X 53.I 53.X 60.I 60.X 61.I 61.X 62.I 62.X 63.I 63.X 64.I 64.X 65.I \
+65.X 101.I 101.X 102.I 102.X
+run_gen = 1.O 1.E 2.O 2.E 3.O 3.E 4.O 4.E 5.O 5.E 6.O 6.E 7.O 7.E 8.O 8.E 9.O \
+9.E 10.O 10.E 11.O 11.E 12.O 12.E 13.O 13.E 20.O 20.E 21.O 21.E 22.O 22.E \
+23.O 23.E 30.O 30.E 31.O 31.E 32.O 32.E 33.O 33.E 34.O 34.E 35.O 35.E 40.O \
+40.E 41.O 41.E 42.O 42.E 43.O 43.E 44.O 44.E 45.O 45.E 50.O 50.E 51.O 51.E \
+52.O 52.E 53.O 53.E 60.O 60.E 61.O 61.E 62.O 62.E 63.O 63.E 64.O 64.E 65.O \
+65.E 101.O 101.E 102.O 102.E
+
+EXTRA_DIST = Test.pm $x-tests $(explicit) $(maint_gen)
+noinst_SCRIPTS = $x-tests
+
+PERL = @PERL@
+editpl = sed -e 's,@''PERL''@,$(PERL),g' -e 's,@''srcdir''@,@srcdir@,g'
+
+TESTS = $x-tests
+
+mk_script = $(srcdir)/../mk-script
+
+MAINTAINERCLEANFILES = $x-tests $(maint_gen)
+CLEANFILES = $(run_gen)
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = ../../config.h
+CONFIG_CLEAN_FILES =
+SCRIPTS = $(noinst_SCRIPTS)
+
+DIST_COMMON = Makefile.am Makefile.in
+
+
+DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
+
+TAR = tar
+GZIP = --best
+all: Makefile $(SCRIPTS)
+
+.SUFFIXES:
+$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
+ cd $(top_srcdir) && $(AUTOMAKE) --gnits tests/uniq/Makefile
+
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
+ cd $(top_builddir) \
+ && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+
+tags: TAGS
+TAGS:
+
+
+distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
+
+subdir = tests/uniq
+
+distdir: $(DISTFILES)
+ here=`cd $(top_builddir) && pwd`; \
+ top_distdir=`cd $(top_distdir) && pwd`; \
+ distdir=`cd $(distdir) && pwd`; \
+ cd $(top_srcdir) \
+ && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnits tests/uniq/Makefile
+ @for file in $(DISTFILES); do \
+ d=$(srcdir); \
+ test -f $(distdir)/$$file \
+ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
+ || cp -p $$d/$$file $(distdir)/$$file; \
+ done
+check-TESTS: $(TESTS)
+ @failed=0; all=0; \
+ srcdir=$(srcdir); export srcdir; \
+ for tst in $(TESTS); do \
+ if test -f $$tst; then dir=.; \
+ else dir="$(srcdir)"; fi; \
+ if $(TESTS_ENVIRONMENT) $$dir/$$tst; then \
+ all=`expr $$all + 1`; \
+ echo "PASS: $$tst"; \
+ elif test $$? -ne 77; then \
+ all=`expr $$all + 1`; \
+ failed=`expr $$failed + 1`; \
+ echo "FAIL: $$tst"; \
+ fi; \
+ done; \
+ if test "$$failed" -eq 0; then \
+ banner="All $$all tests passed"; \
+ else \
+ banner="$$failed of $$all tests failed"; \
+ fi; \
+ dashes=`echo "$$banner" | sed s/./=/g`; \
+ echo "$$dashes"; \
+ echo "$$banner"; \
+ echo "$$dashes"; \
+ test "$$failed" -eq 0
+info:
+dvi:
+check: all
+ $(MAKE) $(AM_MAKEFLAGS) check-TESTS
+installcheck:
+install-exec:
+ @$(NORMAL_INSTALL)
+
+install-data:
+ @$(NORMAL_INSTALL)
+
+install: install-exec install-data all
+ @:
+
+uninstall:
+
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' INSTALL_SCRIPT='$(INSTALL_PROGRAM)' install
+installdirs:
+
+
+mostlyclean-generic:
+
+clean-generic:
+ -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
+
+distclean-generic:
+ -rm -f Makefile $(CONFIG_CLEAN_FILES)
+ -rm -f config.cache config.log stamp-h stamp-h[0-9]*
+
+maintainer-clean-generic:
+ -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
+mostlyclean: mostlyclean-generic
+
+clean: clean-generic mostlyclean
+
+distclean: distclean-generic clean
+ -rm -f config.status
+
+maintainer-clean: maintainer-clean-generic distclean
+ @echo "This command is intended for maintainers to use;"
+ @echo "it deletes files that may require special tools to rebuild."
+
+.PHONY: tags distdir check-TESTS info dvi installcheck install-exec \
+install-data install uninstall all installdirs mostlyclean-generic \
+distclean-generic clean-generic maintainer-clean-generic clean \
+mostlyclean distclean maintainer-clean
+
+$(srcdir)/$x-tests: $(mk_script) Test.pm
+ $(PERL) -I. -w -- $(mk_script) ../../src/$x > $@.n
+ mv $@.n $@
+ chmod 755 $@
+
+check: $(maint_gen)
+
+Makefile.am: ../Makefile.am.in Test.pm $(mk_script)
+ rm -f $@ $@t
+ sed -n '1,/^##test-files-begin/p' $< > $@t
+ tool=`echo $(subdir)|sed 's/^tests.//;s/-test//'`; \
+ echo "x = $$tool" >> $@t
+ $(PERL) -I. -w -- $(mk_script) --list >> $@t
+ sed -n '/^##test-files-end/,$$p' $< >> $@t
+ mv $@t $@
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/tests/uniq/Test.pm b/tests/uniq/Test.pm
new file mode 100644
index 000000000..270a3c7c9
--- /dev/null
+++ b/tests/uniq/Test.pm
@@ -0,0 +1,76 @@
+package Test;
+require 5.002;
+use strict;
+
+$Test::input_via_stdin = 1;
+
+my @tv = (
+# test flags input expected output expected return code
+#
+['1', '', '', '', 0],
+['2', '', "a\na\n", "a\n", 0],
+['3', '', "a\na", "a\n", 0],
+['4', '', "a\nb", "a\nb\n", 0],
+['5', '', "a\na\nb", "a\nb\n", 0],
+['6', '', "b\na\na\n", "b\na\n", 0],
+['7', '', "a\nb\nc\n", "a\nb\nc\n", 0],
+# Make sure that eight bit characters work
+['8', '', "ö\nv\n", "ö\nv\n", 0],
+# Test output of -u option; only unique lines
+['9', '-u', "a\na\n", "", 0],
+['10', '-u', "a\nb\n", "a\nb\n", 0],
+['11', '-u', "a\nb\na\n", "a\nb\na\n", 0],
+['12', '-u', "a\na\n", "", 0],
+['13', '-u', "a\na\n", "", 0],
+#['5', '-u', "a\na\n", "", 0],
+# Test output of -d option; only repeated lines
+['20', '-d', "a\na\n", "a\n", 0],
+['21', '-d', "a\nb\n", "", 0],
+['22', '-d', "a\nb\na\n", "", 0],
+['23', '-d', "a\na\nb\n", "a\n", 0],
+# Check the key options
+# If we skip over fields or characters, is the output deterministic?
+['30', '-1', "a a\nb a\n", "a a\n", 0],
+['31', '-f 1',"a a\nb a\n", "a a\n", 0],
+['32', '-f 1',"a a\nb b\n", "a a\nb b\n", 0],
+['33', '-f 1',"a a a\nb a c\n", "a a a\nb a c\n", 0],
+['34', '-f 1',"b a\na a\n", "b a\n", 0],
+['35', '-f 2',"a a c\nb a c\n", "a a c\n", 0],
+# Skip over characters
+['40', '+1', "aaa\naaa\n", "aaa\n", 0],
+['41', '+1', "baa\naaa\n", "aaa\n", 0],
+['42', '-s 1',"aaa\naaa\n", "aaa\n", 0],
+['43', '-s 2',"baa\naaa\n", "baa\n", 0],
+['44', '+1 --', "aaa\naaa\n", "aaa\n", 0],
+['45', '+1 --', "baa\naaa\n", "aaa\n", 0],
+# Skip over fields and characters
+['50', '-f 1 -s 1',"a aaa\nb ab\n", "a aaa\nb ab\n", 0],
+['51', '-f 1 -s 1',"a aaa\nb aaa\n", "a aaa\n", 0],
+['52', '-s 1 -f 1',"a aaa\nb ab\n", "a aaa\nb ab\n", 0],
+['53', '-s 1 -f 1',"a aaa\nb aaa\n", "a aaa\n", 0],
+# Only account for a number of characters
+['60', '-w 1',"a a\nb a\n", "a a\nb a\n", 0],
+['61', '-w 3',"a a\nb a\n", "a a\nb a\n", 0],
+['62', '-w 1 -f 1',"a a a\nb a c\n", "a a a\n", 0],
+['63', '-f 1 -w 1',"a a a\nb a c\n", "a a a\n", 0],
+# The blank after field one is checked too
+['64', '-f 1 -w 4',"a a a\nb a c\n", "a a a\nb a c\n", 0],
+['65', '-f 1 -w 3',"a a a\nb a c\n", "a a a\n", 0],
+# Check the count option
+['101', '-c', "a\nb\n", " 1\ta\n 1\tb\n", 0],
+['102', '-c', "a\na\n", " 2\ta\n", 0],
+);
+
+sub test_vector
+{
+ my $t;
+ foreach $t (@tv)
+ {
+ my ($test_name, $flags, $in, $exp, $ret) = @$t;
+ $Test::input_via{$test_name} = {REDIR => 0, PIPE => 0};
+ }
+
+ return @tv;
+}
+
+1;