1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Aina Niemetz, Tim King |
4 |
|
* |
5 |
|
* This file is part of the cvc5 project. |
6 |
|
* |
7 |
|
* Copyright (c) 2009-2021 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. |
11 |
|
* **************************************************************************** |
12 |
|
* |
13 |
|
* White box testing of cvc5::Integer. |
14 |
|
*/ |
15 |
|
|
16 |
|
#include <sstream> |
17 |
|
|
18 |
|
#include "test.h" |
19 |
|
#include "util/integer.h" |
20 |
|
|
21 |
|
namespace cvc5 { |
22 |
|
namespace test { |
23 |
|
|
24 |
8 |
class TestUtilWhiteInteger : public TestInternal |
25 |
|
{ |
26 |
|
protected: |
27 |
|
static const char* s_large_val; |
28 |
|
}; |
29 |
|
|
30 |
|
const char* TestUtilWhiteInteger::s_large_val = |
31 |
|
"4547897890548754897897897897890789078907890"; |
32 |
|
|
33 |
11 |
TEST_F(TestUtilWhiteInteger, hash) |
34 |
|
{ |
35 |
4 |
Integer large(s_large_val); |
36 |
4 |
Integer zero; |
37 |
4 |
Integer fits_in_2_bytes(55890); |
38 |
4 |
Integer fits_in_16_bytes("7890D789D33234027890D789D3323402", 16); |
39 |
|
|
40 |
2 |
ASSERT_NO_THROW(zero.hash()); |
41 |
2 |
ASSERT_NO_THROW(fits_in_2_bytes.hash()); |
42 |
2 |
ASSERT_NO_THROW(fits_in_16_bytes.hash()); |
43 |
2 |
ASSERT_NO_THROW(large.hash()); |
44 |
|
} |
45 |
|
|
46 |
|
/** Make sure we can handle: http://www.ginac.de/CLN/cln_3.html#SEC15 */ |
47 |
11 |
TEST_F(TestUtilWhiteInteger, construction) |
48 |
|
{ |
49 |
2 |
const int32_t i = (1 << 29) + 1; |
50 |
2 |
const uint32_t u = (1 << 29) + 1; |
51 |
2 |
ASSERT_EQ(Integer(i), Integer(i)); |
52 |
2 |
ASSERT_EQ(Integer(u), Integer(u)); |
53 |
|
} |
54 |
|
} // namespace test |
55 |
9 |
} // namespace cvc5 |