Skip to content

Commit 98d5860

Browse files
author
thk123
committed
Adding utility for getting symbols out of the symbol table
1 parent f29fb54 commit 98d5860

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

unit/testing-utils/require_symbol.cpp

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*******************************************************************\
2+
3+
Module: Unit test utilities
4+
5+
Author: DiffBlue Limited. All rights reserved.
6+
7+
\*******************************************************************/
8+
9+
10+
#include "require_symbol.h"
11+
#include "catch.hpp"
12+
13+
const symbolt &require_symbol::require_symbol(
14+
const symbol_tablet &symbol_table,
15+
const irep_idt &symbol_identifier)
16+
{
17+
const symbolt *found_symbol=symbol_table.lookup(symbol_identifier);
18+
INFO("Looking for symbol: " + id2string(symbol_identifier));
19+
REQUIRE(found_symbol != nullptr);
20+
return *found_symbol;
21+
}

unit/testing-utils/require_symbol.h

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*******************************************************************\
2+
3+
Module: Unit test utilities
4+
5+
Author: DiffBlue Limited. All rights reserved.
6+
7+
\*******************************************************************/
8+
9+
#ifndef CPROVER_TESTING_UTILS_REQUIRE_SYMBOL_H
10+
#define CPROVER_TESTING_UTILS_REQUIRE_SYMBOL_H
11+
12+
#include <util/symbol.h>
13+
#include <util/symbol_table.h>
14+
15+
/// \file
16+
/// Helper functions for getting symbols from the symbol table during unit tests
17+
18+
// NOLINTNEXTLINE(readability/namespace)
19+
namespace require_symbol
20+
{
21+
const symbolt &require_symbol(
22+
const symbol_tablet &symbol_table,
23+
const irep_idt &symbol_identifier);
24+
}
25+
26+
#endif //CPROVER_TESTING_UTILS_REQUIRE_SYMBOL_H

0 commit comments

Comments
 (0)