1312123Sngie# $NetBSD: t_uniq.sh,v 1.1 2016/10/22 14:13:39 abhinav Exp $ 2312123Sngie# 3312123Sngie# Copyright (c) 2016 The NetBSD Foundation, Inc. 4312123Sngie# All rights reserved. 5312123Sngie# 6312123Sngie# This code is derived from software contributed to The NetBSD Foundation 7312123Sngie# by Abhinav Upadhyay 8312123Sngie# 9312123Sngie# Redistribution and use in source and binary forms, with or without 10312123Sngie# modification, are permitted provided that the following conditions 11312123Sngie# are met: 12312123Sngie# 1. Redistributions of source code must retain the above copyright 13312123Sngie# notice, this list of conditions and the following disclaimer. 14312123Sngie# 2. Redistributions in binary form must reproduce the above copyright 15312123Sngie# notice, this list of conditions and the following disclaimer in the 16312123Sngie# documentation and/or other materials provided with the distribution. 17312123Sngie# 18312123Sngie# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 19312123Sngie# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20312123Sngie# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21312123Sngie# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22312123Sngie# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23312123Sngie# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24312123Sngie# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25312123Sngie# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26312123Sngie# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27312123Sngie# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28312123Sngie# POSSIBILITY OF SUCH DAMAGE. 29312123Sngie# 30312123Sngie 31312123Sngieatf_test_case basic 32312123Sngiebasic_head() 33312123Sngie{ 34312123Sngie atf_set "descr" "Checks the basic functionality" 35312123Sngie} 36312123Sngiebasic_body() 37312123Sngie{ 38312123Sngie atf_check -o file:$(atf_get_srcdir)/d_basic.out uniq \ 39312123Sngie $(atf_get_srcdir)/d_basic.in 40312123Sngie} 41312123Sngie 42312123Sngieatf_test_case test_counts 43312123Sngietest_counts_head() 44312123Sngie{ 45312123Sngie atf_set "descr" "Tests the -c option, comparing each line of the input" \ 46312123Sngie "file data starting from the second field" 47312123Sngie} 48312123Sngietest_counts_body() 49312123Sngie{ 50312123Sngie atf_check -o file:$(atf_get_srcdir)/d_counts.out uniq -c -f 1 \ 51312123Sngie $(atf_get_srcdir)/d_input.in 52312123Sngie} 53312123Sngie 54312123Sngieatf_test_case show_duplicates 55312123Sngieshow_duplicates_head() 56312123Sngie{ 57312123Sngie atf_set "descr" "Checks the -d option, comparing each line of the input" \ 58312123Sngie "file data starting from the second field" 59312123Sngie} 60312123Sngieshow_duplicates_body() 61312123Sngie{ 62312123Sngie atf_check -o file:$(atf_get_srcdir)/d_show_duplicates.out uniq -d -f 1 \ 63312123Sngie $(atf_get_srcdir)/d_input.in 64312123Sngie} 65312123Sngie 66312123Sngieatf_test_case show_uniques 67312123Sngieshow_uniques_head() 68312123Sngie{ 69312123Sngie atf_set "descr" "Checks the -u option, comparing each line of the input" \ 70312123Sngie "file data starting from the second field" 71312123Sngie} 72312123Sngieshow_uniques_body() 73312123Sngie{ 74312123Sngie atf_check -o file:$(atf_get_srcdir)/d_show_uniques.out uniq -u -f 1 \ 75312123Sngie $(atf_get_srcdir)/d_input.in 76312123Sngie} 77312123Sngie 78312123Sngieatf_test_case show_duplicates_from_third_character 79312123Sngieshow_duplicates_from_third_character_head() 80312123Sngie{ 81312123Sngie atf_set "descr" "Checks the -d option, comparing each line of the input" \ 82312123Sngie "file data starting from the third character (-s option)" 83312123Sngie} 84312123Sngieshow_duplicates_from_third_character_body() 85312123Sngie{ 86312123Sngie atf_check -o empty uniq -d -s 2 $(atf_get_srcdir)/d_input.in 87312123Sngie 88312123Sngie} 89312123Sngie 90312123Sngieatf_init_test_cases() 91312123Sngie{ 92312123Sngie atf_add_test_case basic 93312123Sngie atf_add_test_case test_counts 94312123Sngie atf_add_test_case show_duplicates 95312123Sngie atf_add_test_case show_uniques 96312123Sngie atf_add_test_case show_duplicates_from_third_character 97312123Sngie} 98