1 /* $NetBSD: t_hypot.c,v 1.1 2016/01/24 20:26:47 gson Exp $ */
4 * Copyright (c) 2016 The NetBSD Foundation, Inc.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
32 ATF_TC(hypot_integer);
33 ATF_TC_HEAD(hypot_integer, tc)
35 atf_tc_set_md_var(tc, "descr", "Test hypot with integer args");
38 ATF_TC_BODY(hypot_integer, tc)
40 /* volatile so hypotf() won't be evaluated at compile time */
41 volatile double a = 5;
42 volatile double b = 12;
43 ATF_CHECK(hypot(a, b) == 13.0);
46 ATF_TC(hypotf_integer);
47 ATF_TC_HEAD(hypotf_integer, tc)
49 atf_tc_set_md_var(tc, "descr", "Test hypotf with integer args");
52 ATF_TC_BODY(hypotf_integer, tc)
55 volatile float b = 12;
56 ATF_CHECK(hypotf(a, b) == 13.0f);
60 ATF_TC_HEAD(pr50698, tc)
62 atf_tc_set_md_var(tc, "descr", "Check for the bug of PR 50698");
65 ATF_TC_BODY(pr50698, tc)
67 volatile float a = 1e-18f;
68 float val = hypotf(a, a);
69 ATF_CHECK(!isinf(val));
70 ATF_CHECK(!isnan(val));
76 ATF_TP_ADD_TC(tp, hypot_integer);
77 ATF_TP_ADD_TC(tp, hypotf_integer);
78 ATF_TP_ADD_TC(tp, pr50698);
80 return atf_no_error();