1
1
/* ******************************************************************\
2
2
3
- Module: Unit tests for has_subtype in
4
- solvers/refinement/string_refinement.cpp
3
+ Module: Unit tests for has_subtype in expr_util.cpp
5
4
6
5
Author: Diffblue Ltd.
7
6
10
9
#include < testing-utils/catch.hpp>
11
10
12
11
#include < util/c_types.h>
13
- #include < solvers/refinement/string_refinement.h>
12
+ #include < util/expr_util.h>
13
+ #include < util/namespace.h>
14
+ #include < util/symbol_table.h>
15
+
14
16
#include < java_bytecode/java_types.h>
15
17
16
18
// Curryfied version of type comparison.
@@ -23,12 +25,15 @@ static std::function<bool(const typet &)> is_type(const typet &t1)
23
25
24
26
SCENARIO (" has_subtype" , " [core][solvers][refinement][string_refinement]" )
25
27
{
28
+ const symbol_tablet symbol_table;
29
+ const namespacet ns (symbol_table);
30
+
26
31
const typet char_type = java_char_type ();
27
32
const typet int_type = java_int_type ();
28
33
const typet bool_type = java_boolean_type ();
29
34
30
- REQUIRE (has_subtype (char_type, is_type (char_type)));
31
- REQUIRE_FALSE (has_subtype (char_type, is_type (int_type)));
35
+ REQUIRE (has_subtype (char_type, is_type (char_type), ns ));
36
+ REQUIRE_FALSE (has_subtype (char_type, is_type (int_type), ns ));
32
37
33
38
GIVEN (" a struct with char and int fields" )
34
39
{
@@ -37,12 +42,12 @@ SCENARIO("has_subtype", "[core][solvers][refinement][string_refinement]")
37
42
struct_type.components ().emplace_back (" int_field" , int_type);
38
43
THEN (" char and int are subtypes" )
39
44
{
40
- REQUIRE (has_subtype (struct_type, is_type (char_type)));
41
- REQUIRE (has_subtype (struct_type, is_type (int_type)));
45
+ REQUIRE (has_subtype (struct_type, is_type (char_type), ns ));
46
+ REQUIRE (has_subtype (struct_type, is_type (int_type), ns ));
42
47
}
43
48
THEN (" bool is not a subtype" )
44
49
{
45
- REQUIRE_FALSE (has_subtype (struct_type, is_type (bool_type)));
50
+ REQUIRE_FALSE (has_subtype (struct_type, is_type (bool_type), ns ));
46
51
}
47
52
}
48
53
@@ -51,11 +56,11 @@ SCENARIO("has_subtype", "[core][solvers][refinement][string_refinement]")
51
56
pointer_typet ptr_type = pointer_type (char_type);
52
57
THEN (" char is a subtype" )
53
58
{
54
- REQUIRE (has_subtype (ptr_type, is_type (char_type)));
59
+ REQUIRE (has_subtype (ptr_type, is_type (char_type), ns ));
55
60
}
56
61
THEN (" int is not a subtype" )
57
62
{
58
- REQUIRE_FALSE (has_subtype (ptr_type, is_type (int_type)));
63
+ REQUIRE_FALSE (has_subtype (ptr_type, is_type (int_type), ns ));
59
64
}
60
65
}
61
66
}
0 commit comments