1 1.1 maya /*- 2 1.1 maya * Copyright (c) 2018 The NetBSD Foundation, Inc. 3 1.1 maya * All rights reserved. 4 1.1 maya * 5 1.1 maya * This code is derived from software contributed to The NetBSD Foundation 6 1.1 maya * by Maya Rashish 7 1.1 maya * 8 1.1 maya * Redistribution and use in source and binary forms, with or without 9 1.1 maya * modification, are permitted provided that the following conditions 10 1.1 maya * are met: 11 1.1 maya * 1. Redistributions of source code must retain the above copyright 12 1.1 maya * notice, this list of conditions and the following disclaimer. 13 1.1 maya * 2. Redistributions in binary form must reproduce the above copyright 14 1.1 maya * notice, this list of conditions and the following disclaimer in the 15 1.1 maya * documentation and/or other materials provided with the distribution. 16 1.1 maya * 17 1.1 maya * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 18 1.1 maya * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 19 1.1 maya * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 20 1.1 maya * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 21 1.1 maya * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 1.1 maya * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 1.1 maya * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 1.1 maya * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 1.1 maya * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 1.1 maya * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 1.1 maya * POSSIBILITY OF SUCH DAMAGE. 28 1.1 maya */ 29 1.1 maya 30 1.1 maya /* 31 1.1 maya * Test that C++ "cabsl" is usable. PR lib/50646 32 1.1 maya */ 33 1.1 maya 34 1.1 maya #include <atf-c++.hpp> 35 1.1 maya #include <complex> 36 1.1 maya 37 1.1 maya ATF_TEST_CASE(cabsl); 38 1.1 maya ATF_TEST_CASE_HEAD(cabsl) 39 1.1 maya { 40 1.1 maya set_md_var("descr", "Check that cabsl is usable from C++"); 41 1.1 maya } 42 1.1 maya ATF_TEST_CASE_BODY(cabsl) 43 1.1 maya { 44 1.1 maya int sum = 0; 45 1.1 maya 46 1.1 maya std::complex<long double> cld(3.0,4.0); 47 1.1 maya sum += std::abs(cld); 48 1.1 maya std::complex<double> cd(3.0,4.0); 49 1.1 maya sum += std::abs(cd); 50 1.1 maya 51 1.1 maya std::complex<float> cf(3.0,4.0); 52 1.1 maya sum += std::abs(cf); 53 1.1 maya 54 1.1 maya ATF_REQUIRE_EQ(sum, 3*5); 55 1.1 maya } 56 1.1 maya 57 1.1 maya ATF_INIT_TEST_CASES(tcs) 58 1.1 maya { 59 1.1 maya ATF_ADD_TEST_CASE(tcs, cabsl); 60 1.1 maya } 61