草庐IT

test_value

全部标签

c++ - 如何使用模板函数作为 Boost::Unit-test 的自定义谓词

我正在尝试为BOOST_CHECK_PREDICATE构建自定义谓词,其中谓词本身是一个模板函数。我的示例如下所示:#defineBOOST_TEST_MODULEModule#defineBOOST_TEST_MAIN#include//custompredicatetemplateboolis_close_enough(constU&a,constV&b){returnstd::abs(a-b)使用MSVisualC++2010编译会出现以下错误:3>..\boost_test\testSystem.cpp(42):errorC2780:'boolboost::test_tools

c++ - 测试 C++ 代码 : Using test libraries

我学习C++有一段时间了,但这是我第一次接触C++项目(宠物配置解析器库)。我正在使用GoogleC++TestingFramework来测试这个。但我不知道我这样做是否正确。目前,我已经剥离了这个Google测试库的一些部分并将其放入我的项目Test/googletest目录中。它工作正常,但我想知道我是否应该这样做。我在我的项目中包含了测试框架的源代码,它将与我的代码一起发布。这让我感到不舒服。我浏览了someC++projectsonGitHub,试图看看其他人如何处理这个问题。有些有自定义框架,大多数根本不测试代码就解决了整个问题。我想知道我是否做对了,或者我怎样才能采用一种测

c++ - 将 STL 容器与 boost 范围适配器一起使用时出现 value_type 错误

我一直在尝试了解boost范围适配器的使用,但我发现的所有工作示例仅使用具有基本类型的STL容器,例如std::list并尝试使用我自己的类(class)会使一切分崩离析。#defineBOOST_RESULT_OF_USE_DECLTYPE#include#include#include#include#include#include#include#include#includestructThing{Thing():_id(0),_name(""){}std::size_t_id;std::string_name;};intmain(){std::vectorinput;std:

c++ - 如何通过命令行运行 Google Test?

我有一个启动并运行GoogleTest的示例项目。我有一个简单的测试类,如下所示:#includeTEST(FirstTest,TestNumberOne){EXPECT_NE(2,1);}这是在我电脑上的目录/home/dave/Desktop/sandbox/black-test/src/code/Tester.cpp我在使用Ubuntu的Eclipse中工作。测试类在Eclipse中运行良好(右键单击,以C++运行)。但是我找不到关于如何通过命令提示符运行的文档?其次,大多数为C++进行单元测试的人是将他们的测试项目与生产代码分开还是耦合(就像大多数Java项目一样)?

c++ - GCC Address Sanitizer - 将库函数列入黑名单(特别是 boost::test)

我所有的单元测试代码都基于boost::test。我刚刚尝试了GCCAddresssanitizer,它报告了boost::test的一些问题:==25309==ERROR:AddressSanitizer:heap-use-after-freeonaddress0xf5801344atpc0x8259412bp0xff9966c8sp0xff9966bcREADofsize4at0xf5801344threadT0#00x8259411inboost::unit_test::framework::run(unsignedlong,bool)../common/lib/boost/bo

maven无法解决org.junit.test

我正在尝试通过命令行中的Groovy编译和运行单元测试。项目中的包装结构不遵循命名约定-这是我目前无法更改的。这些课程被组织为:src/abc/def/SomeClass.groovysrc/abc/tests/def/TestSomeClass.groovy当我跑步时mvntest,消息是:无法解析类org.junit.test和无法解析类org.junit.assert在课堂里src/abc/tests/def/TestSomeClass.groovy.我的pom是:4.0.0org.codehaus.mojomy-project1.0org.codehaus.gmavenplusgmav

Invalid value type for attribute ‘factoryBeanObjectType‘: java.lang.String

ErrorstartingApplicationContext.Todisplaytheconditionevaluationreportre-runyourapplicationwith'debug'enabled.2024-01-05T17:04:00.527+08:00ERROR201118---[solve][main]o.s.boot.SpringApplication:Applicationrunfailedjava.lang.IllegalArgumentException:Invalidvaluetypeforattribute'factoryBeanObjectType':j

c++ - Eigen 与 -O3 警告 : argument 1 value ‘X’ exceeds maximum object size Y

发生了什么当我按照教程onEigenwebsite尝试将Eigen::Vector3f添加到std::vector中时像这样:#include#include#includetemplateusingEigenStdVector=std::vector>;intmain(){EigenStdVectorvec;vec.emplace_back(1.0f,1.0f,1.0f);std::cerr我收到以下警告:Infileincludedfrom/usr/include/eigen3/Eigen/Core:349:0,from/home/igor/Code/eigen_example/e

c++ - Boost::Test——Main() 的生成?

我对设置boost测试库有点困惑。这是我的代码:#include"stdafx.h"#defineBOOST_TEST_DYN_LINK#defineBOOST_TEST_MODULEpevUnitTest#includeBOOST_AUTO_TEST_CASE(TesterTest){BOOST_CHECK(true);}我的编译器生成非常有用的错误消息:1>MSVCRTD.lib(wcrtexe.obj):errorLNK2019:unresolvedexternalsymbol_wmainreferencedinfunction___tmainCRTStartup1>C:\Use

c++ - 有没有办法使用 boost::program_options::parse_config_file 在 INI 文件中包含多个 "name=value"行?

我希望能够使用boost::program_options在INI文件中指定多个name=value行。有点像[list.names]name=valuename=value2name=value3有没有办法用boost::program_options实现这个?如果我尝试它,我会得到一个多次出现的错误如果没有,还有哪些其他库可用? 最佳答案 指定字段的值为std::vector在options_description:namespacepo=boost::program_options;po::options_descriptio