Skip to content

Commit 785f1ce

Browse files
committed
adds static analyzers for detecting memory leaks in the unit tests, and fixes existing memory leaks with raw pointers by wrapping them in unique_ptrs
1 parent a80d0a5 commit 785f1ce

File tree

5 files changed

+165
-61
lines changed

5 files changed

+165
-61
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ project(expression_tree
77
include(CTest)
88

99
if (NOT DEFINED CMAKE_CXX_STANDARD)
10-
set(CMAKE_CXX_STANDARD 11)
10+
set(CMAKE_CXX_STANDARD 14)
1111
endif()
1212

1313
if (NOT CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "")

tests/CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
if(BUILD_TESTING)
2-
2+
33
add_executable( operators_test operators.cpp )
4+
target_link_libraries( operators_test "-fsanitize=address" )
5+
target_compile_options( operators_test PRIVATE -fsanitize=address )
46
add_test( operators_test ${EXECUTABLE_OUTPUT_PATH}/operators_test )
57

68
add_executable( expression_tree_leaf_node_test expression_tree_leaf_node.cpp )
9+
target_link_libraries( expression_tree_leaf_node_test "-fsanitize=address" )
10+
target_compile_options( expression_tree_leaf_node_test PRIVATE -fsanitize=address )
711
add_test( expression_tree_leaf_node_test ${EXECUTABLE_OUTPUT_PATH}/expression_tree_leaf_node_test )
812

913
add_executable( expression_tree_op_node_test expression_tree_op_node.cpp )
14+
target_link_libraries( expression_tree_op_node_test "-fsanitize=address" )
15+
target_compile_options( expression_tree_op_node_test PRIVATE -fsanitize=address )
1016
add_test( expression_tree_op_node_test ${EXECUTABLE_OUTPUT_PATH}/expression_tree_op_node_test )
1117

1218
endif()

0 commit comments

Comments
 (0)