Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 检查失败后,增压单元测试将所有控制台文本永久变为红色_C++_Unit Testing_Boost_Console_Console Application - Fatal编程技术网

C++ 检查失败后,增压单元测试将所有控制台文本永久变为红色

C++ 检查失败后,增压单元测试将所有控制台文本永久变为红色,c++,unit-testing,boost,console,console-application,C++,Unit Testing,Boost,Console,Console Application,我正在使用Boost单元测试,我有以下简单的程序: #include <iostream> #include <boost/test/included/unit_test.hpp> void test1() { std::cout << "Here's test 1" << std::endl; BOOST_CHECK_EQUAL(1, 2); } void test2() { std::cout <&l

我正在使用Boost单元测试,我有以下简单的程序:

#include <iostream>

#include <boost/test/included/unit_test.hpp>

void test1()
{
  std::cout << "Here's test 1" << std::endl;
  BOOST_CHECK_EQUAL(1, 2);
}

void test2()
{
  std::cout << "Here's test 2" << std::endl;
  BOOST_CHECK_EQUAL(1, 1);
}

boost::unit_test::test_suite*
init_unit_test_suite(int argc, char* argv[])
{
  using namespace boost::unit_test;

  test_suite* ts1 = BOOST_TEST_SUITE("test_suite1");
  ts1->add(BOOST_TEST_CASE(&test1));
  ts1->add(BOOST_TEST_CASE(&test2));

  framework::master_test_suite().add(ts1);

  return 0;
}
#包括
#包括
void test1()
{

std::cout这可能是由于终端模拟器有缺陷或终端仿真与报告的功能不匹配()

你可以试试

  • 明蒂
  • 科内姆
  • 终结者(更多信息)
如果您在IDE(例如VsCode或Clion)中使用此功能,请在其跟踪器中报告错误

至少在linux上,不存在这样的问题:

以完整输出重新测试:


我在Windows命令提示符和Windows powershell上都注意到了这个问题。正如你所说,我在Linux上没有注意到这个问题。我确实觉得奇怪,因为它们都内置在Windows中。不过,我会看看其他一些选项。这是关于兼容性的。并非所有的终端都有相同的功能ities。如果错误地假设或错误地报告它们,则会出现通信错误。例如,当您使用终端仿真器时,您经常需要设置TERM=vt100或TERM=screen-256color或TERM=os2ansi或TERM=win32等。我会比较不同的终端(可能PowerShell与您使用的其他shell在同一终端中运行)。I(想一想**我听说Windows10得到了一个全新的终端实现,比以前好多了。最后。
Running 2 test cases...
Here's test 1
c:/users/<redacted>/code/utils/cppscripts/testbed/testbed.cpp(8): error: in "test_suite1/test1": check 1 == 2 has failed [1 != 2]
Here's test 2

*** 1 failure is detected in the test module "Master Test Suite"