// // Copyright 2018 Ettus Research, a National Instruments Company // // SPDX-License-Identifier: GPL-3.0-or-later // #include #include <../lib/include/uhdlib/utils/narrow.hpp> #include #include using namespace uhd; BOOST_AUTO_TEST_CASE(test_narrow){ uint16_t x = 5; uint8_t y = narrow_cast(x); BOOST_CHECK_EQUAL(x, y); BOOST_CHECK_THROW(narrow(uint16_t(1<<10)), narrowing_error); BOOST_CHECK_THROW(narrow(int8_t(-1)), narrowing_error); }