summaryrefslogtreecommitdiff
path: root/test/unit/expr/node_manager_white.h
blob: 2bda4d2f035bb325ceeedf41132b7c603785db7a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*********************                                                        */
/*! \file node_manager_white.h
 ** \verbatim
 ** Top contributors (to current version):
 **   Morgan Deters, Tim King
 ** This file is part of the CVC4 project.
 ** Copyright (c) 2009-2016 by the authors listed in the file AUTHORS
 ** in the top-level source directory) and their institutional affiliations.
 ** All rights reserved.  See the file COPYING in the top-level source
 ** directory for licensing information.\endverbatim
 **
 ** \brief White box testing of CVC4::NodeManager.
 **
 ** White box testing of CVC4::NodeManager.
 **/

#include <cxxtest/TestSuite.h>

#include <string>

#include "expr/node_manager.h"
#include "util/integer.h"
#include "util/rational.h"

using namespace CVC4;
using namespace CVC4::expr;

class NodeManagerWhite : public CxxTest::TestSuite {

  NodeManager* d_nm;
  NodeManagerScope* d_scope;

public:

  void setUp() {
    d_nm = new NodeManager(NULL);
    d_scope = new NodeManagerScope(d_nm);
  }

  void tearDown() {
    delete d_scope;
    delete d_nm;
  }

  void testMkConstRational() {
    Rational i("3");
    Node n = d_nm->mkConst(i);
    Node m = d_nm->mkConst(i);
    TS_ASSERT_EQUALS(n.getId(), m.getId());
  }

  void testOversizedNodeBuilder() {
    NodeBuilder<> nb;

    TS_ASSERT_THROWS_NOTHING(nb.realloc(15));
    TS_ASSERT_THROWS_NOTHING(nb.realloc(25));
    TS_ASSERT_THROWS_NOTHING(nb.realloc(256));
#ifdef CVC4_ASSERTIONS
    TS_ASSERT_THROWS(nb.realloc(100), AssertionException);
#endif /* CVC4_ASSERTIONS */
    TS_ASSERT_THROWS_NOTHING(nb.realloc(257));
    TS_ASSERT_THROWS_NOTHING(nb.realloc(4000));
    TS_ASSERT_THROWS_NOTHING(nb.realloc(20000));
    TS_ASSERT_THROWS_NOTHING(nb.realloc(60000));
    TS_ASSERT_THROWS_NOTHING(nb.realloc(65535));
    TS_ASSERT_THROWS_NOTHING(nb.realloc(65536));
    TS_ASSERT_THROWS_NOTHING(nb.realloc(67108863));
#ifdef CVC4_ASSERTIONS
    TS_ASSERT_THROWS(nb.realloc(67108863), AssertionException);
#endif /* CVC4_ASSERTIONS */
  }
};
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback