1*c60be9eaSEnji Cooper# 2*c60be9eaSEnji Cooper# SPDX-License-Identifier: BSD-2-Clause 3*c60be9eaSEnji Cooper# 4*c60be9eaSEnji Cooper# Copyright 2023 (C) Enji Cooper 5*c60be9eaSEnji Cooper# 6*c60be9eaSEnji Cooper# Redistribution and use in source and binary forms, with or without 7*c60be9eaSEnji Cooper# modification, are permitted provided that the following conditions 8*c60be9eaSEnji Cooper# are met: 9*c60be9eaSEnji Cooper# 1. Redistributions of source code must retain the above copyright 10*c60be9eaSEnji Cooper# notice, this list of conditions and the following disclaimer. 11*c60be9eaSEnji Cooper# 2. Redistributions in binary form must reproduce the above copyright 12*c60be9eaSEnji Cooper# notice, this list of conditions and the following disclaimer in the 13*c60be9eaSEnji Cooper# documentation and/or other materials provided with the distribution. 14*c60be9eaSEnji Cooper# 15*c60be9eaSEnji Cooper# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16*c60be9eaSEnji Cooper# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17*c60be9eaSEnji Cooper# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18*c60be9eaSEnji Cooper# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19*c60be9eaSEnji Cooper# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20*c60be9eaSEnji Cooper# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21*c60be9eaSEnji Cooper# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22*c60be9eaSEnji Cooper# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23*c60be9eaSEnji Cooper# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24*c60be9eaSEnji Cooper# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25*c60be9eaSEnji Cooper# SUCH DAMAGE. 26*c60be9eaSEnji Cooper 27*c60be9eaSEnji Cooperatf_test_case invalid_range 28*c60be9eaSEnji Cooperinvalid_range_head() 29*c60be9eaSEnji Cooper{ 30*c60be9eaSEnji Cooper atf_set "descr" "Verify that invalid ranges are not allowed." 31*c60be9eaSEnji Cooper} 32*c60be9eaSEnji Cooperinvalid_range_body() 33*c60be9eaSEnji Cooper{ 34*c60be9eaSEnji Cooper atf_check -s not-exit:0 -e inline:"primes: start value must be less than stop value.\n" primes -- 2 1 35*c60be9eaSEnji Cooper} 36*c60be9eaSEnji Cooper 37*c60be9eaSEnji Cooperatf_test_case negative_numbers_not_allowed 38*c60be9eaSEnji Coopernegative_numbers_not_allowed_head() 39*c60be9eaSEnji Cooper{ 40*c60be9eaSEnji Cooper atf_set "descr" "Verify that negative numbers are not allowed." 41*c60be9eaSEnji Cooper} 42*c60be9eaSEnji Coopernegative_numbers_not_allowed_body() 43*c60be9eaSEnji Cooper{ 44*c60be9eaSEnji Cooper atf_check -s not-exit:0 -e inline:"primes: negative numbers aren't permitted.\n" primes -- -1 0 45*c60be9eaSEnji Cooper} 46*c60be9eaSEnji Cooper 47*c60be9eaSEnji Cooperatf_test_case no_primes_between_between_20_and_22 48*c60be9eaSEnji Cooperno_primes_between_between_20_and_22_head() 49*c60be9eaSEnji Cooper{ 50*c60be9eaSEnji Cooper atf_set "descr" "Show that no primes exist between [20, 22]." 51*c60be9eaSEnji Cooper} 52*c60be9eaSEnji Cooper 53*c60be9eaSEnji Cooperno_primes_between_between_20_and_22_body() 54*c60be9eaSEnji Cooper{ 55*c60be9eaSEnji Cooper atf_check primes 20 22 56*c60be9eaSEnji Cooper} 57*c60be9eaSEnji Cooper 58*c60be9eaSEnji Cooperatf_test_case primes_in_20_to_50_range 59*c60be9eaSEnji Cooperprimes_in_20_to_50_range_head() 60*c60be9eaSEnji Cooper{ 61*c60be9eaSEnji Cooper atf_set "descr" "Find all primes between [20, 50]." 62*c60be9eaSEnji Cooper} 63*c60be9eaSEnji Cooper 64*c60be9eaSEnji Cooperprimes_in_20_to_50_range_body() 65*c60be9eaSEnji Cooper{ 66*c60be9eaSEnji Cooper atf_check -o inline:"23\n29\n31\n37\n41\n43\n47\n" primes 20 50 67*c60be9eaSEnji Cooper} 68*c60be9eaSEnji Cooper 69*c60be9eaSEnji Cooperatf_init_test_cases() 70*c60be9eaSEnji Cooper{ 71*c60be9eaSEnji Cooper atf_add_test_case invalid_range 72*c60be9eaSEnji Cooper atf_add_test_case negative_numbers_not_allowed 73*c60be9eaSEnji Cooper atf_add_test_case no_primes_between_between_20_and_22 74*c60be9eaSEnji Cooper atf_add_test_case primes_in_20_to_50_range 75*c60be9eaSEnji Cooper} 76