Browse Source

[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.
Marcin Siodelski 10 years ago
parent
commit
337f52213d
1 changed files with 6 additions and 4 deletions
  1. 6 4
      src/lib/util/tests/pid_file_unittest.cc

+ 6 - 4
src/lib/util/tests/pid_file_unittest.cc

@@ -14,7 +14,9 @@
 
 #include <util/pid_file.h>
 #include <gtest/gtest.h>
+#include <fstream>
 #include <signal.h>
+#include <stdint.h>
 
 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();