Branch data Line data Source code
1 : : /****************************************************************************** 2 : : * This file is part of the cvc5 project. 3 : : * 4 : : * Copyright (c) 2009-2026 by the authors listed in the file AUTHORS 5 : : * in the top-level source directory and their institutional affiliations. 6 : : * All rights reserved. See the file COPYING in the top-level source 7 : : * directory for licensing information. 8 : : * **************************************************************************** 9 : : * 10 : : * White box testing of cvc5::Integer. 11 : : */ 12 : : 13 : : #include <sstream> 14 : : 15 : : #include "test.h" 16 : : #include "util/integer.h" 17 : : 18 : : namespace cvc5::internal { 19 : : namespace test { 20 : : 21 : : class TestUtilWhiteInteger : public TestInternal 22 : : { 23 : : protected: 24 : : static const char* s_large_val; 25 : : }; 26 : : 27 : : const char* TestUtilWhiteInteger::s_large_val = 28 : : "4547897890548754897897897897890789078907890"; 29 : : 30 : 4 : TEST_F(TestUtilWhiteInteger, hash) 31 : : { 32 : 1 : Integer large(s_large_val); 33 : 1 : Integer zero; 34 : 1 : Integer fits_in_2_bytes(55890); 35 : 1 : Integer fits_in_16_bytes("7890D789D33234027890D789D3323402", 16); 36 : : 37 [ + - ][ + - ]: 1 : ASSERT_NO_THROW(zero.hash()); [ + - ][ - - ] 38 [ + - ][ + - ]: 1 : ASSERT_NO_THROW(fits_in_2_bytes.hash()); [ + - ][ - - ] 39 [ + - ][ + - ]: 1 : ASSERT_NO_THROW(fits_in_16_bytes.hash()); [ + - ][ - - ] 40 [ + - ][ + - ]: 1 : ASSERT_NO_THROW(large.hash()); [ + - ][ - - ] 41 [ + - ][ + - ]: 1 : } [ + - ][ + - ] 42 : : 43 : : /** Make sure we can handle: http://www.ginac.de/CLN/cln_3.html#SEC15 */ 44 : 4 : TEST_F(TestUtilWhiteInteger, construction) 45 : : { 46 : 1 : const int32_t i = (1 << 29) + 1; 47 : 1 : const uint32_t u = (1 << 29) + 1; 48 [ - + ][ + - ]: 2 : ASSERT_EQ(Integer(i), Integer(i)); 49 [ - + ][ + - ]: 2 : ASSERT_EQ(Integer(u), Integer(u)); 50 : : } 51 : : } // namespace test 52 : : } // namespace cvc5::internal