File: test_mem.cpp

package info (click to toggle)
boolector 3.2.4-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 20,744 kB
  • sloc: ansic: 83,136; cpp: 18,159; sh: 3,668; python: 2,889; makefile: 210
file content (63 lines) | stat: -rw-r--r-- 1,487 bytes parent folder | download
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
/*  Boolector: Satisfiability Modulo Theories (SMT) solver.
 *
 *  Copyright (C) 2007-2021 by the authors listed in the AUTHORS file.
 *
 *  This file is part of Boolector.
 *  See COPYING for more information on using this software.
 */

#include "test.h"

extern "C" {
#include "utils/btormem.h"
}

class TestMem : public TestMm
{
 protected:
};

TEST_F (TestMem, new_delete_mem_mgr) {}

TEST_F (TestMem, malloc)
{
  int32_t *test = NULL;
  test          = (int32_t *) btor_mem_malloc (d_mm, sizeof (int32_t));
  ASSERT_NE (test, nullptr);
  *test = 3;
  btor_mem_free (d_mm, test, sizeof (int32_t));
}

TEST_F (TestMem, realloc)
{
  int32_t *test = NULL;
  test          = (int32_t *) btor_mem_malloc (d_mm, sizeof (int32_t));
  ASSERT_NE (test, nullptr);
  test[0] = 3;
  test    = (int32_t *) btor_mem_realloc (
      d_mm, test, sizeof (int32_t), sizeof (int32_t) * 2);
  ASSERT_EQ (test[0], 3);
  test[1] = 5;
  ASSERT_EQ (test[0], 3);
  ASSERT_EQ (test[1], 5);
  btor_mem_free (d_mm, test, sizeof (int32_t) * 2);
}

TEST_F (TestMem, calloc)
{
  int32_t *test = NULL;
  test          = (int32_t *) btor_mem_calloc (d_mm, sizeof (int32_t), 4);
  ASSERT_NE (test, nullptr);
  ASSERT_EQ (test[0], 0);
  ASSERT_EQ (test[1], 0);
  ASSERT_EQ (test[2], 0);
  ASSERT_EQ (test[3], 0);
  btor_mem_free (d_mm, test, sizeof (int32_t) * 4);
}

TEST_F (TestMem, strdup)
{
  char *test = btor_mem_strdup (d_mm, "test");
  ASSERT_EQ (strcmp (test, "test"), 0);
  btor_mem_freestr (d_mm, test);
}