草庐IT

test_forward

全部标签

unit-testing - Jacoco 如何获得测试覆盖率或忽略 Kotlin 数据类

Jacoco显示Kotlin数据类的覆盖率为0%。如何配置它来测量覆盖率或完全忽略数据类? 最佳答案 我正在寻找针对数据模型类的自动生成代码的相同测试覆盖率问题的解决方案,但偶然发现了以下问题:Kotlin+JaCoCo:TuningCompilertoSkipGeneratedCode解决方案:将JaCoCo插件更新到0.8.2即可解决您的问题。JaCoCo在0.8.2版本中已经解决了这个问题,请阅读更新日志-使用运行时可见和不可见注释注释的类和方法,其简单名称为Generated在生成报告期间被过滤掉(GitHub#731)。K

c++ - 了解 std::forward

为什么编译器无法推导出std::forward的模板参数?我的意思是:#include#includestructX{};structA{A(constX&){std::coutT*factory(Arg&&a){returnnewT(std::forward(a));//----------^^^^^^^^^^^^^^^error:can'tdeducetemplateparameter}intmain(){factory(foo());}我知道这是一个设计选择(由于std::forward定义中的std::remove_reference)以避免用户忘记指定类型.我无法得到的是:为

c++ - 为什么 valgrind 没有在我的 "test"程序中检测到内存泄漏?

整个测试代码包含在main.cpp中如下:#includeusingstd::cout;usingstd::endl;voidf(inti){int*pi=newint;*pi=i;std::cout我编译时没有优化-O0(来自EclipseQt项目):g++-c-pipe-O0-Wall-W-D_REENTRANT-DQT_NO_DEBUG-DQT_GUI_LIB-DQT_CORE_LIB-DQT_SHARED-I/usr/share/qt4/mkspecs/linux-g++-I.-I/usr/include/qt4/QtCore-I/usr/include/qt4/QtGui-I

c++ - 将 std::forward 与 auto&& 一起使用是正确的做法吗

尝试了解将std::forward与auto&&变量一起使用是否是传递这些变量以允许移动的正确方法。假设有一个函数:voidmoveWidget(Widget&&w);调用者-引用右值和左值的两个变量:Widgetw;auto&&uniRefLV=w;//lvalueinitialiser,//uniRefLV'stypeisWidget&auto&&uniRefRV=std::move(w);//rvalueinitialiser,//uniRefRV'stypeisWidget&&我们知道auto&&类型的变量是通用引用,因为发生了类型推导。这意味着uniRefRV和uniRefL

c++ - boost 测试不 init_unit_test_suite

我运行这段代码#defineBOOST_TEST_MAIN#defineBOOST_TEST_DYN_LINK#include#include#include#includeusingnamespaceboost::unit_test;usingnamespacestd;voidTestFoo(){BOOST_CHECK(0==0);}test_suite*init_unit_test_suite(intargc,char*argv[]){std::coutadd(BOOST_TEST_CASE(&TestFoo));returnmaster_test_suite;}但是在运行时它说T

c++ - "The C++ compiler "/usr/bin/c++ "is not able to compile a simple test program."尝试安装 OpenCV 时

我正尝试按照此link在我的Mac上安装OpenCV但是,当我在终端上键入cmake-G"UnixMakefiles"..时,会打印出此错误。--TheCXXcompileridentificationisunknown--TheCcompileridentificationisunknown--CheckforworkingCXXcompiler:/usr/bin/c++--CheckforworkingCXXcompiler:/usr/bin/c++--brokenCMakeErrorat/opt/local/share/cmake-3.0/Modules/CMakeTestCXX

c++ - std::apply forward parameters 如何在没有显式 std::forward 的情况下应用?

考虑std::apply的可能实现:namespacedetail{templateconstexprdecltype(auto)apply_impl(F&&f,Tuple&&t,std::index_sequence){returnstd::invoke(std::forward(f),std::get(std::forward(t))...);}}//namespacedetailtemplateconstexprdecltype(auto)apply(F&&f,Tuple&&t){returndetail::apply_impl(std::forward(f),std::forw

c++ - forward<T>(a) 和 (T&&)(a) 有什么区别

templatevoidouter(T&&t){inner(forward(t));}templatevoidouter(T&&t){inner((T&&)(t));}有什么区别? 最佳答案 没有实际区别。std::forward(v)指定为static_cast(v).§20.2.3[forward]templateT&&forward(typenameremove_reference::type&t)noexcept;templateT&&forward(typenameremove_reference::type&&t)noe

c++ - 我什么时候应该 std::forward 一个函数调用?

我在EffectiveModernC++中看到的一段代码巧妙地实现了instrumentationrationale创建一个功能计时器:autotimeFuncInvocation=[](auto&&func,auto&&...params){starttimer;std::forward(func)(std::forward(params)...);stoptimerandrecordelapsedtime;};我的问题是关于std::forward(func)(...据我了解,我们实际上是将函数转换为其原始类型,但是为什么需要这样做?它看起来像一个简单的打电话就可以了。还有其他我们

c++ - 在 C++ 中将通用构造函数分配给成员变量时的 std::move 或 std::forward

考虑以下类foo1和foo2templatestructfoo1{Tt_;foo1(T&&t):t_{std::move(t)}{}};templatestructfoo2{foo1t_;foo2(T&&t):t_{std::forward(t)}{}};foo1的构造函数总是这样吗?表示初始化成员变量的正确方式T?即通过使用std::move.foo2的构造函数总是这样吗?表示初始化成员变量的正确方式foo1由于需要转发给foo1的构造函数?即通过使用std::forward.更新以下示例因foo1而失败使用std::move:templatefoo1make_foo1(T&&t){