1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Aina Niemetz |
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 |
|
* Black box testing of cvc5::ArrayStoreAll. |
14 |
|
*/ |
15 |
|
|
16 |
|
#include "expr/array_store_all.h" |
17 |
|
#include "expr/uninterpreted_constant.h" |
18 |
|
#include "test_smt.h" |
19 |
|
#include "util/rational.h" |
20 |
|
|
21 |
|
namespace cvc5 { |
22 |
|
namespace test { |
23 |
|
|
24 |
12 |
class TestUtilWhiteArrayStoreAll : public TestSmt |
25 |
|
{ |
26 |
|
}; |
27 |
|
|
28 |
12 |
TEST_F(TestUtilWhiteArrayStoreAll, store_all) |
29 |
|
{ |
30 |
4 |
TypeNode usort = d_nodeManager->mkSort("U"); |
31 |
4 |
ArrayStoreAll(d_nodeManager->mkArrayType(d_nodeManager->integerType(), |
32 |
4 |
d_nodeManager->realType()), |
33 |
4 |
d_nodeManager->mkConst(Rational(9, 2))); |
34 |
2 |
ArrayStoreAll(d_nodeManager->mkArrayType(d_nodeManager->mkSort("U"), usort), |
35 |
4 |
d_nodeManager->mkConst(UninterpretedConstant(usort, 0))); |
36 |
4 |
ArrayStoreAll(d_nodeManager->mkArrayType(d_nodeManager->mkBitVectorType(8), |
37 |
4 |
d_nodeManager->realType()), |
38 |
4 |
d_nodeManager->mkConst(Rational(0))); |
39 |
4 |
ArrayStoreAll(d_nodeManager->mkArrayType(d_nodeManager->mkBitVectorType(8), |
40 |
4 |
d_nodeManager->integerType()), |
41 |
4 |
d_nodeManager->mkConst(Rational(0))); |
42 |
2 |
} |
43 |
|
|
44 |
12 |
TEST_F(TestUtilWhiteArrayStoreAll, type_errors) |
45 |
|
{ |
46 |
4 |
ASSERT_THROW(ArrayStoreAll(d_nodeManager->integerType(), |
47 |
|
d_nodeManager->mkConst(UninterpretedConstant( |
48 |
|
d_nodeManager->mkSort("U"), 0))), |
49 |
2 |
IllegalArgumentException); |
50 |
4 |
ASSERT_THROW(ArrayStoreAll(d_nodeManager->integerType(), |
51 |
|
d_nodeManager->mkConst(Rational(9, 2))), |
52 |
2 |
IllegalArgumentException); |
53 |
4 |
ASSERT_THROW( |
54 |
|
ArrayStoreAll(d_nodeManager->mkArrayType(d_nodeManager->integerType(), |
55 |
|
d_nodeManager->mkSort("U")), |
56 |
|
d_nodeManager->mkConst(Rational(9, 2))), |
57 |
2 |
IllegalArgumentException); |
58 |
|
} |
59 |
|
|
60 |
12 |
TEST_F(TestUtilWhiteArrayStoreAll, const_error) |
61 |
|
{ |
62 |
4 |
TypeNode usort = d_nodeManager->mkSort("U"); |
63 |
4 |
ASSERT_THROW(ArrayStoreAll(d_nodeManager->mkArrayType( |
64 |
|
d_nodeManager->mkSort("U"), usort), |
65 |
|
d_nodeManager->mkVar(usort)), |
66 |
2 |
IllegalArgumentException); |
67 |
4 |
ASSERT_THROW( |
68 |
|
ArrayStoreAll(d_nodeManager->integerType(), |
69 |
|
d_nodeManager->mkVar("x", d_nodeManager->integerType())), |
70 |
2 |
IllegalArgumentException); |
71 |
4 |
ASSERT_THROW( |
72 |
|
ArrayStoreAll(d_nodeManager->integerType(), |
73 |
|
d_nodeManager->mkNode(kind::PLUS, |
74 |
|
d_nodeManager->mkConst(Rational(1)), |
75 |
|
d_nodeManager->mkConst(Rational(0)))), |
76 |
2 |
IllegalArgumentException); |
77 |
|
} |
78 |
|
} // namespace test |
79 |
41170 |
} // namespace cvc5 |