2016-03-31 21:32:24
- 问题 用github上的开源项目catch作为我的单元测试工具 (类似Junit),但通过g++ -g 编译、file filename 载入,list查看代码时,发现全是 catch.hpp中的内容。 函数所在文件16.cpp内容如下:
#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file
#include "catch.hpp"
template<class T>
void p(const T &t)
{
typename T::const_iterator it=t.begin();
for(typename T::size_type i=0;i<t.size();i++)
{
std::cout<<*it<<std::endl;
std::advance(it,i);
}
}
TEST_CASE("16.1.4","输出")
{
std::vector<int> s;
s.push_back(1);
s.push_back(2);
s.push_back(2);
s.push_back(2);
p(s);
}
命令(部分)提示如下:
(gdb) l 1
1 /*
2 * Catch v1.3.3
3 * Generated: 2016-01-22 07:51:36.661106
4 * ---------------------------------------------
5 * This file has been merged from multiple headers. Please don't edit it directly
6 * Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.
7 *
8 * Distributed under the Boost Software License, Version 1.0. (See accompanying
9 * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
10 */
(gdb)
11 #ifndef TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED
12 #define TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED
13
14 #define TWOBLUECUBES_CATCH_HPP_INCLUDED
15
16 #ifdef __clang__
17 # pragma clang system_header
18 #elif defined __GNUC__
19 # pragma GCC system_header
20 #endif
(gdb)
用 l p查找函数p :
(gdb) l p
Function "p" not defined.
(gdb)
- 解决 用 b 16.cpp:10设置在第10行设置断点 ,便可以进入文件16.cpp