Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

b2 unit-test '\0' output cache #199

Open
fasxmut opened this issue Nov 11, 2022 · 0 comments
Open

b2 unit-test '\0' output cache #199

fasxmut opened this issue Nov 11, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@fasxmut
Copy link

fasxmut commented Nov 11, 2022

If there is a '\0' outputed, the rest information will be not outputed.

I first found it when I printed char std::array and std::vector.

test.cpp

#include <boost/assert.hpp>
#include <array>
#include <vector>
#include <iostream>

int main()
{
	std::array<char, 13> array{"Hello Boost!"};
	BOOST_ASSERT(array[12] == '\0');
	for (auto & x: array)
		std::cout << x;
	std::cout << std::endl; // This '\n' is not outputed.
	std::cout << "Hello C++!\n"; // This is not printed.
}

jamroot

import testing ;

unit-test test : test.cpp : <cxxstd>20 ;

output:

$ b2
...found 13 targets...
...updating 3 targets...
gcc.compile.c++ bin/gcc-12/debug/cxxstd-20-iso/test.o
gcc.link bin/gcc-12/debug/cxxstd-20-iso/test
testing.unit-test bin/gcc-12/debug/cxxstd-20-iso/test.passed
Hello Boost!...updated 3 targets...

If I use boost::unit_test, it gives the similar result, and the nice colorful "No errors detected" is not printed, because everything after '\0' are not printed.

Another example using boost::unit_test

test.cpp

#define BOOST_TEST_MODULE test.cpp
#include <boost/test/unit_test.hpp>
#include <array>
#include <vector>
#include <iostream>

BOOST_AUTO_TEST_CASE(case01)
{
	std::array<char, 13> array{"Hello Boost!"};
	BOOST_CHECK_EQUAL(array[12], '\0');
	for (auto & x: array)
		std::cout << x;
	std::cout << std::endl; // This '\n' is not outputed.
	std::cout << "Hello C++!\n"; // This is not printed.
}

jamroot

import testing ;

unit-test test : test.cpp : <cxxstd>20 <define>BOOST_TEST_DYN_LINK
	<linkflags>-lboost_unit_test_framework ;

output:

$ b2
...found 13 targets...
...updating 7 targets...
gcc.compile.c++ bin/gcc-12/debug/cxxstd-20-iso/test.o
gcc.link bin/gcc-12/debug/cxxstd-20-iso/test
testing.unit-test bin/gcc-12/debug/cxxstd-20-iso/test.passed
Running 1 test case...
Hello Boost!...updated 7 targets...
@fasxmut fasxmut added the bug Something isn't working label Nov 11, 2022
@grafikrobot grafikrobot moved this to 🔖 Ready in BFG Tasks Dec 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: 🔖 Ready
Development

No branches or pull requests

1 participant