From: Marcin Siodelski Date: Wed, 28 Jan 2015 19:54:06 +0000 (+0100) Subject: [3687] Pass c-string to the constructor of fstream. X-Git-Tag: trac3712_base~29^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=337f52213d8fe70b97f0859672ad696eed9ae746;p=thirdparty%2Fkea.git [3687] Pass c-string to the constructor of fstream. Passing the std::string doesn't work on Linux. For some reason it works on BSD. --- diff --git a/src/lib/util/tests/pid_file_unittest.cc b/src/lib/util/tests/pid_file_unittest.cc index faaa195194..d4eb09ae94 100644 --- a/src/lib/util/tests/pid_file_unittest.cc +++ b/src/lib/util/tests/pid_file_unittest.cc @@ -14,7 +14,9 @@ #include #include +#include #include +#include namespace { using namespace isc::util; @@ -93,7 +95,7 @@ TEST_F(PIDFileTest, writeAndDelete) { pid_file.write(10); // Read the file and compare the pid - fs.open(absolutePath(TESTNAME), std::ifstream::in); + fs.open(absolutePath(TESTNAME).c_str(), std::ifstream::in); fs >> pid; EXPECT_TRUE(fs.good()); EXPECT_EQ(pid, 10); @@ -103,7 +105,7 @@ TEST_F(PIDFileTest, writeAndDelete) { pid_file.write(20); // And comapre the second pid - fs.open(absolutePath(TESTNAME), std::ifstream::in); + fs.open(absolutePath(TESTNAME).c_str(), std::ifstream::in); fs >> pid; EXPECT_TRUE(fs.good()); EXPECT_EQ(pid, 20); @@ -113,7 +115,7 @@ TEST_F(PIDFileTest, writeAndDelete) { pid_file.deleteFile(); // And verify that it's gone - fs.open(absolutePath(TESTNAME), std::ifstream::in); + fs.open(absolutePath(TESTNAME).c_str(), std::ifstream::in); EXPECT_FALSE(fs.good()); fs.close(); } @@ -172,7 +174,7 @@ TEST_F(PIDFileTest, pidGarbage) { std::ofstream fs; // Open the file and write garbage to it - fs.open(absolutePath(TESTNAME), std::ofstream::out); + fs.open(absolutePath(TESTNAME).c_str(), std::ofstream::out); fs << "text" << std::endl; fs.close();