Skip to content

Commit 2297093

Browse files
author
Luca Geretti
committed
Add test for stack_trace(), rename utility.cpp into stack_trace.cpp
1 parent 4ea1d9b commit 2297093

File tree

4 files changed

+63
-1
lines changed

4 files changed

+63
-1
lines changed

source/utility/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
set(LIBRARY_NAME ariadne-utility)
22

33
add_library(${LIBRARY_NAME} OBJECT
4-
utility.cpp
4+
stack_trace.cpp
55
)
66

77
foreach(WARN ${LIBRARY_EXCLUSIVE_WARN})

tests/utility/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
set(UNIT_TESTS
22
test_array
33
test_container
4+
test_stack_trace
45
)
56

67
foreach(TEST ${UNIT_TESTS})

tests/utility/test_stack_trace.cpp

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/***************************************************************************
2+
* test_stack_trace.cpp
3+
*
4+
* Copyright 2009-21 Luca Geretti
5+
*
6+
****************************************************************************/
7+
8+
/*
9+
* This file is part of Ariadne.
10+
*
11+
* Ariadne is free software: you can redistribute it and/or modify
12+
* it under the terms of the GNU General Public License as published by
13+
* the Free Software Foundation, either version 3 of the License, or
14+
* (at your option) any later version.
15+
*
16+
* Ariadne is distributed in the hope that it will be useful,
17+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19+
* GNU General Public License for more details.
20+
*
21+
* You should have received a copy of the GNU General Public License
22+
* along with Ariadne. If not, see <https://www.gnu.org/licenses/>.
23+
*/
24+
25+
#include <iostream>
26+
27+
#include "config.hpp"
28+
#include "utility/stack_trace.hpp"
29+
30+
#include "../test.hpp"
31+
32+
using namespace Ariadne;
33+
34+
struct TestClass {
35+
Void method() {
36+
stack_trace();
37+
}
38+
};
39+
40+
class TestStackTrace {
41+
public:
42+
43+
Void test_free_function() {
44+
stack_trace();
45+
}
46+
47+
Void test_class_method() {
48+
TestClass().method();
49+
}
50+
51+
Void test() {
52+
ARIADNE_TEST_CALL(test_free_function());
53+
ARIADNE_TEST_CALL(test_class_method());
54+
}
55+
56+
};
57+
58+
Int main() {
59+
TestStackTrace().test();
60+
return ARIADNE_TEST_FAILURES;
61+
}

0 commit comments

Comments
 (0)