MCPcopy Create free account
hub / github.com/boostorg/filesystem / temp_directory_path_tests

Function temp_directory_path_tests

test/operations_test.cpp:2706–2864  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2704};
2705
2706void temp_directory_path_tests()
2707{
2708 {
2709 cout << "temp_directory_path_tests..." << endl;
2710 cout << " temp_directory_path() is " << fs::temp_directory_path() << endl;
2711
2712#if defined(BOOST_FILESYSTEM_WINDOWS_API)
2713
2714 //**************************************************************************************//
2715 // Bug in GCC 4.9 getenv() when !defined(__GXX_EXPERIMENTAL_CXX0X__) makes these
2716 // tests meaningless, so skip them
2717 //**************************************************************************************//
2718
2719#if defined(__CYGWIN__) && !defined(__GXX_EXPERIMENTAL_CXX0X__) && __GNUC__ == 4
2720 cout << "Bug in GCC 4.9 getenv() when !defined(__GXX_EXPERIMENTAL_CXX0X__) makes these"
2721 "tests meaningless, so skip them"
2722 << endl;
2723 return;
2724#endif
2725 // Test ticket #5300, temp_directory_path failure on Windows with path length > 130.
2726 // (This test failed prior to the fix being applied.)
2727 {
2728 const wchar_t long_name[] =
2729 L"12345678901234567890123456789012345678901234567890"
2730 L"12345678901234567890123456789012345678901234567890"
2731 L"12345678901234567890123456789012345678901234567890#" // total 151 chars
2732 ;
2733 fs::path p(temp_dir);
2734 p /= long_name;
2735 fs::create_directory(p);
2736
2737 guarded_env_var tmp_guard("TMP", p.string().c_str());
2738 error_code ec;
2739 fs::path tmp_path = fs::temp_directory_path(ec);
2740 BOOST_TEST(!ec);
2741 BOOST_TEST_EQ(p, tmp_path);
2742 fs::remove(p);
2743 }
2744
2745 // Test ticket #10388, null character at end of filesystem::temp_directory_path path
2746 {
2747 guarded_env_var tmp_guard("TMP", fs::initial_path().string().c_str());
2748
2749 error_code ec;
2750 fs::path tmp_path = fs::temp_directory_path(ec);
2751 BOOST_TEST_EQ(tmp_path, fs::initial_path());
2752 }
2753
2754#endif
2755 BOOST_TEST(!fs::temp_directory_path().empty());
2756 BOOST_TEST(exists(fs::temp_directory_path()));
2757 fs::path ph = fs::temp_directory_path() / fs::unique_path("temp_directory_path_test_%%%%_%%%%.txt");
2758 {
2759 if (exists(ph))
2760 remove(ph);
2761 std::ofstream f(BOOST_FILESYSTEM_C_STR(ph));
2762 f << "passed";
2763 }

Callers 1

cpp_mainFunction · 0.85

Calls 10

equivalentFunction · 0.85
stringMethod · 0.80
temp_directory_pathFunction · 0.50
create_directoryFunction · 0.50
removeFunction · 0.50
initial_pathFunction · 0.50
existsFunction · 0.50
unique_pathFunction · 0.50
c_strMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected