Skip to content

Commit f60d8c8

Browse files
author
thk123
committed
Unit utility for symbol types
1 parent 21a33fa commit f60d8c8

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

unit/testing-utils/require_type.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,3 +289,19 @@ require_type::require_java_non_generic_class(const typet &class_type)
289289

290290
return java_class_type;
291291
}
292+
293+
/// Verify a given type is a symbol type, optionally with a specific identifier
294+
/// \param type: The type to check
295+
/// \param identifier: The identifier the symbol type should have
296+
/// \return The cast version of the input type
297+
const symbol_typet &
298+
require_type::require_symbol(const typet &type, const irep_idt &identifier)
299+
{
300+
REQUIRE(type.id() == ID_symbol);
301+
const symbol_typet &result = to_symbol_type(type);
302+
if(identifier != "")
303+
{
304+
REQUIRE(result.get_identifier() == identifier);
305+
}
306+
return result;
307+
}

unit/testing-utils/require_type.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ namespace require_type
2525
pointer_typet
2626
require_pointer(const typet &type, const optionalt<typet> &subtype);
2727

28+
const symbol_typet &
29+
require_symbol(const typet &type, const irep_idt &identifier = "");
30+
2831
struct_typet::componentt require_component(
2932
const struct_typet &struct_type,
3033
const irep_idt &component_name);

0 commit comments

Comments
 (0)