1*63d1fd59SEnji Cooper# $NetBSD: t_uniq.sh,v 1.1 2016/10/22 14:13:39 abhinav Exp $ 2*63d1fd59SEnji Cooper# 3*63d1fd59SEnji Cooper# Copyright (c) 2016 The NetBSD Foundation, Inc. 4*63d1fd59SEnji Cooper# All rights reserved. 5*63d1fd59SEnji Cooper# 6*63d1fd59SEnji Cooper# This code is derived from software contributed to The NetBSD Foundation 7*63d1fd59SEnji Cooper# by Abhinav Upadhyay 8*63d1fd59SEnji Cooper# 9*63d1fd59SEnji Cooper# Redistribution and use in source and binary forms, with or without 10*63d1fd59SEnji Cooper# modification, are permitted provided that the following conditions 11*63d1fd59SEnji Cooper# are met: 12*63d1fd59SEnji Cooper# 1. Redistributions of source code must retain the above copyright 13*63d1fd59SEnji Cooper# notice, this list of conditions and the following disclaimer. 14*63d1fd59SEnji Cooper# 2. Redistributions in binary form must reproduce the above copyright 15*63d1fd59SEnji Cooper# notice, this list of conditions and the following disclaimer in the 16*63d1fd59SEnji Cooper# documentation and/or other materials provided with the distribution. 17*63d1fd59SEnji Cooper# 18*63d1fd59SEnji Cooper# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 19*63d1fd59SEnji Cooper# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20*63d1fd59SEnji Cooper# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21*63d1fd59SEnji Cooper# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22*63d1fd59SEnji Cooper# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23*63d1fd59SEnji Cooper# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24*63d1fd59SEnji Cooper# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25*63d1fd59SEnji Cooper# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26*63d1fd59SEnji Cooper# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27*63d1fd59SEnji Cooper# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28*63d1fd59SEnji Cooper# POSSIBILITY OF SUCH DAMAGE. 29*63d1fd59SEnji Cooper# 30*63d1fd59SEnji Cooper 31*63d1fd59SEnji Cooperatf_test_case basic 32*63d1fd59SEnji Cooperbasic_head() 33*63d1fd59SEnji Cooper{ 34*63d1fd59SEnji Cooper atf_set "descr" "Checks the basic functionality" 35*63d1fd59SEnji Cooper} 36*63d1fd59SEnji Cooperbasic_body() 37*63d1fd59SEnji Cooper{ 38*63d1fd59SEnji Cooper atf_check -o file:$(atf_get_srcdir)/d_basic.out uniq \ 39*63d1fd59SEnji Cooper $(atf_get_srcdir)/d_basic.in 40*63d1fd59SEnji Cooper} 41*63d1fd59SEnji Cooper 42*63d1fd59SEnji Cooperatf_test_case test_counts 43*63d1fd59SEnji Coopertest_counts_head() 44*63d1fd59SEnji Cooper{ 45*63d1fd59SEnji Cooper atf_set "descr" "Tests the -c option, comparing each line of the input" \ 46*63d1fd59SEnji Cooper "file data starting from the second field" 47*63d1fd59SEnji Cooper} 48*63d1fd59SEnji Coopertest_counts_body() 49*63d1fd59SEnji Cooper{ 50*63d1fd59SEnji Cooper atf_check -o file:$(atf_get_srcdir)/d_counts.out uniq -c -f 1 \ 51*63d1fd59SEnji Cooper $(atf_get_srcdir)/d_input.in 52*63d1fd59SEnji Cooper} 53*63d1fd59SEnji Cooper 54*63d1fd59SEnji Cooperatf_test_case show_duplicates 55*63d1fd59SEnji Coopershow_duplicates_head() 56*63d1fd59SEnji Cooper{ 57*63d1fd59SEnji Cooper atf_set "descr" "Checks the -d option, comparing each line of the input" \ 58*63d1fd59SEnji Cooper "file data starting from the second field" 59*63d1fd59SEnji Cooper} 60*63d1fd59SEnji Coopershow_duplicates_body() 61*63d1fd59SEnji Cooper{ 62*63d1fd59SEnji Cooper atf_check -o file:$(atf_get_srcdir)/d_show_duplicates.out uniq -d -f 1 \ 63*63d1fd59SEnji Cooper $(atf_get_srcdir)/d_input.in 64*63d1fd59SEnji Cooper} 65*63d1fd59SEnji Cooper 66*63d1fd59SEnji Cooperatf_test_case show_uniques 67*63d1fd59SEnji Coopershow_uniques_head() 68*63d1fd59SEnji Cooper{ 69*63d1fd59SEnji Cooper atf_set "descr" "Checks the -u option, comparing each line of the input" \ 70*63d1fd59SEnji Cooper "file data starting from the second field" 71*63d1fd59SEnji Cooper} 72*63d1fd59SEnji Coopershow_uniques_body() 73*63d1fd59SEnji Cooper{ 74*63d1fd59SEnji Cooper atf_check -o file:$(atf_get_srcdir)/d_show_uniques.out uniq -u -f 1 \ 75*63d1fd59SEnji Cooper $(atf_get_srcdir)/d_input.in 76*63d1fd59SEnji Cooper} 77*63d1fd59SEnji Cooper 78*63d1fd59SEnji Cooperatf_test_case show_duplicates_from_third_character 79*63d1fd59SEnji Coopershow_duplicates_from_third_character_head() 80*63d1fd59SEnji Cooper{ 81*63d1fd59SEnji Cooper atf_set "descr" "Checks the -d option, comparing each line of the input" \ 82*63d1fd59SEnji Cooper "file data starting from the third character (-s option)" 83*63d1fd59SEnji Cooper} 84*63d1fd59SEnji Coopershow_duplicates_from_third_character_body() 85*63d1fd59SEnji Cooper{ 86*63d1fd59SEnji Cooper atf_check -o empty uniq -d -s 2 $(atf_get_srcdir)/d_input.in 87*63d1fd59SEnji Cooper 88*63d1fd59SEnji Cooper} 89*63d1fd59SEnji Cooper 90*63d1fd59SEnji Cooperatf_init_test_cases() 91*63d1fd59SEnji Cooper{ 92*63d1fd59SEnji Cooper atf_add_test_case basic 93*63d1fd59SEnji Cooper atf_add_test_case test_counts 94*63d1fd59SEnji Cooper atf_add_test_case show_duplicates 95*63d1fd59SEnji Cooper atf_add_test_case show_uniques 96*63d1fd59SEnji Cooper atf_add_test_case show_duplicates_from_third_character 97*63d1fd59SEnji Cooper} 98