File tree Expand file tree Collapse file tree 4 files changed +30
-1
lines changed
include/clang/Interpreter Expand file tree Collapse file tree 4 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -117,6 +117,9 @@ namespace Cpp {
117
117
}
118
118
};
119
119
120
+ // /\returns the version string information of the library.
121
+ std::string GetVersion ();
122
+
120
123
// / Enables or disables the debugging printouts on stderr.
121
124
// / Debugging output can be enabled also by the environment variable
122
125
// / CPPINTEROP_EXTRA_INTERPRETER_ARGS. For example,
Original file line number Diff line number Diff line change @@ -115,6 +115,19 @@ namespace Cpp {
115
115
116
116
#undef DEBUG_TYPE
117
117
118
+ std::string GetVersion () {
119
+ const char * const VERSION = " 1.0~dev" ;
120
+ std::string fullVersion = " CppInterOp version" ;
121
+ fullVersion += VERSION;
122
+ fullVersion += " \n (based on "
123
+ #ifdef USE_CLING
124
+ " cling " ;
125
+ #else
126
+ " clang-repl" ;
127
+ #endif // USE_CLING
128
+ return fullVersion + " [" + clang::getClangFullVersion () + " ])\n " ;
129
+ }
130
+
118
131
void EnableDebugOutput (bool value/* =true*/ ) {
119
132
llvm::DebugFlag = value;
120
133
}
Original file line number Diff line number Diff line change @@ -7,6 +7,12 @@ if (NOT TARGET gtest)
7
7
include (GoogleTest )
8
8
endif ()
9
9
10
+ set (gtest_libs gtest gtest_main )
11
+ # Clang prior than clang13 (I think) merges both gmock into gtest.
12
+ if (TARGET gmock )
13
+ list (APPEND gtest_libs gmock gmock_main )
14
+ endif ()
15
+
10
16
add_custom_target (CppInterOpUnitTests )
11
17
set_target_properties (CppInterOpUnitTests PROPERTIES FOLDER "CppInterOp tests" )
12
18
add_dependencies (CppInterOpUnitTests clangCppInterOp )
@@ -18,7 +24,7 @@ function(add_cppinterop_unittest name)
18
24
target_include_directories (${name} PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${GTEST_INCLUDE_DIR} )
19
25
set_property (TARGET ${name} PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} )
20
26
21
- target_link_libraries (${name} PUBLIC ${ARG_LIBRARIES} gtest gtest_main pthread )
27
+ target_link_libraries (${name} PUBLIC ${ARG_LIBRARIES} ${gtest_libs} pthread )
22
28
23
29
add_test (NAME cppinterop-${name} COMMAND ${name} )
24
30
set_tests_properties (cppinterop-${name} PROPERTIES
Original file line number Diff line number Diff line change 1
1
#include " clang/Interpreter/CppInterOp.h"
2
2
3
+ #include < gmock/gmock.h>
3
4
#include " gtest/gtest.h"
4
5
6
+ using ::testing::StartsWith;
7
+
8
+ TEST (InterpreterTest, Version) {
9
+ EXPECT_THAT (Cpp::GetVersion (), StartsWith (" CppInterOp version" ));
10
+ }
11
+
5
12
TEST (InterpreterTest, DebugFlag) {
6
13
EXPECT_FALSE (Cpp::IsDebugOutputEnabled ());
7
14
std::string cerrs;
You can’t perform that action at this time.
0 commit comments