/srv/osrm/osrm-backend/third_party/fmt-9.1.0/test
NameSizeModeActions
add-subdirectory-test/-0755rm
compile-error-test/-0755rm
cuda-test/-0755rm
find-package-test/-0755rm
fuzzing/-0755rm
gtest/-0755rm
static-export-test/-0755rm
args-test.cc51960644editdlrm
assert-test.cc8520644editdlrm
chrono-test.cc255370644editdlrm
CMakeLists.txt90880644editdlrm
color-test.cc32780644editdlrm
compile-fp-test.cc28210644editdlrm
compile-test.cc142650644editdlrm
core-test.cc321790644editdlrm
detect-stdfs.cc6070644editdlrm
enforce-checks-test.cc16610644editdlrm
format-impl-test.cc177870644editdlrm
format-test.cc938280644editdlrm
gtest-extra-test.cc138960644editdlrm
gtest-extra.cc19830644editdlrm
gtest-extra.h76990644editdlrm
header-only-test.cc2530644editdlrm
mock-allocator.h15540644editdlrm
module-test.cc179430644editdlrm
noexception-test.cc4370644editdlrm
os-test.cc152050644editdlrm
ostream-test.cc99790644editdlrm
posix-mock-test.cc117140644editdlrm
posix-mock.h16550644editdlrm
printf-test.cc207440644editdlrm
ranges-odr-test.cc4540644editdlrm
ranges-test.cc129460644editdlrm
scan-test.cc27960644editdlrm
scan.h67950644editdlrm
std-test.cc28000644editdlrm
test-assert.h11130644editdlrm
test-main.cc12100644editdlrm
unicode-test.cc13140644editdlrm
util.cc11520644editdlrm
util.h21160644editdlrm
xchar-test.cc188870644editdlrm
Edit: /srv/osrm/osrm-backend/third_party/fmt-9.1.0/test/gtest-extra.cc (1983B)
// Formatting library for C++ - custom Google Test assertions // // Copyright (c) 2012 - present, Victor Zverovich // All rights reserved. // // For the license information refer to format.h. #include "gtest-extra.h" #if FMT_USE_FCNTL using fmt::file; output_redirect::output_redirect(FILE* f) : file_(f) { flush(); int fd = FMT_POSIX(fileno(f)); // Create a file object referring to the original file. original_ = file::dup(fd); // Create a pipe. file write_end; file::pipe(read_end_, write_end); // Connect the passed FILE object to the write end of the pipe. write_end.dup2(fd); } output_redirect::~output_redirect() noexcept { try { restore(); } catch (const std::exception& e) { std::fputs(e.what(), stderr); } } void output_redirect::flush() { int result = 0; do { result = fflush(file_); } while (result == EOF && errno == EINTR); if (result != 0) throw fmt::system_error(errno, "cannot flush stream"); } void output_redirect::restore() { if (original_.descriptor() == -1) return; // Already restored. flush(); // Restore the original file. original_.dup2(FMT_POSIX(fileno(file_))); original_.close(); } std::string output_redirect::restore_and_read() { // Restore output. restore(); // Read everything from the pipe. std::string content; if (read_end_.descriptor() == -1) return content; // Already read. enum { BUFFER_SIZE = 4096 }; char buffer[BUFFER_SIZE]; size_t count = 0; do { count = read_end_.read(buffer, BUFFER_SIZE); content.append(buffer, count); } while (count != 0); read_end_.close(); return content; } std::string read(file& f, size_t count) { std::string buffer(count, '\0'); size_t n = 0, offset = 0; do { n = f.read(&buffer[offset], count - offset); // We can't read more than size_t bytes since count has type size_t. offset += n; } while (offset < count && n != 0); buffer.resize(offset); return buffer; } #endif // FMT_USE_FCNTL