1 /********************* */ 2 /*! \file integer_white.h 3 ** \verbatim 4 ** Top contributors (to current version): 5 ** Tim King, Morgan Deters 6 ** This file is part of the CVC4 project. 7 ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS 8 ** in the top-level source directory) and their institutional affiliations. 9 ** All rights reserved. See the file COPYING in the top-level source 10 ** directory for licensing information.\endverbatim 11 ** 12 ** \brief White box testing of CVC4::Integer. 13 ** 14 ** White box testing of CVC4::Integer. 15 **/ 16 17 #include <cxxtest/TestSuite.h> 18 #include <sstream> 19 20 #include "util/integer.h" 21 22 using namespace CVC4; 23 using namespace std; 24 25 const char* largeVal = "4547897890548754897897897897890789078907890"; 26 27 28 class IntegerWhite : public CxxTest::TestSuite { 29 public: 30 testHash()31 void testHash(){ 32 Integer large (largeVal); 33 Integer zero; 34 Integer fits_in_2_bytes(55890); 35 Integer fits_in_16_bytes("7890D789D33234027890D789D3323402", 16); 36 37 38 TS_ASSERT_THROWS_NOTHING(zero.hash()); 39 TS_ASSERT_THROWS_NOTHING(fits_in_2_bytes.hash()); 40 TS_ASSERT_THROWS_NOTHING(fits_in_16_bytes.hash()); 41 TS_ASSERT_THROWS_NOTHING(large.hash()); 42 } 43 44 //Make sure we can properly handle: 45 //http://www.ginac.de/CLN/cln_3.html#SEC15 testConstruction()46 void testConstruction(){ 47 const int i_above2tothe29 = (1 << 29) + 1; 48 const unsigned int u_above2tothe29 = (1 << 29) + 1; 49 TS_ASSERT_EQUALS(Integer(i_above2tothe29), Integer((long)i_above2tothe29)); 50 TS_ASSERT_EQUALS(Integer(u_above2tothe29), 51 Integer((unsigned long)u_above2tothe29)); 52 53 } 54 }; 55