aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/cpfile/driver.cxx9
-rw-r--r--tests/fdstream/driver.cxx3
-rw-r--r--tests/openssl/driver.cxx5
-rw-r--r--tests/process/driver.cxx12
4 files changed, 7 insertions, 22 deletions
diff --git a/tests/cpfile/driver.cxx b/tests/cpfile/driver.cxx
index 6fa1567..3a19322 100644
--- a/tests/cpfile/driver.cxx
+++ b/tests/cpfile/driver.cxx
@@ -22,14 +22,7 @@ static string
from_file (const path& f)
{
ifdstream ifs (f, ios::binary);
- string s;
-
- // Note that the eof check is important: if the stream is at eof (empty
- // file) then getline() will fail.
- //
- if (ifs.peek () != ifdstream::traits_type::eof ())
- getline (ifs, s, '\0');
-
+ string s (ifs.read_text ());
ifs.close (); // Not to miss failed close of the underlying file descriptor.
return s;
}
diff --git a/tests/fdstream/driver.cxx b/tests/fdstream/driver.cxx
index c8748b1..41a39b0 100644
--- a/tests/fdstream/driver.cxx
+++ b/tests/fdstream/driver.cxx
@@ -37,8 +37,7 @@ static const string text3 ("ABCDEF\r\nXYZ");
static string
from_stream (ifdstream& is)
{
- string s;
- getline (is, s, '\0');
+ string s (is.read_text ());
is.close (); // Not to miss failed close of the underlying file descriptor.
return s;
}
diff --git a/tests/openssl/driver.cxx b/tests/openssl/driver.cxx
index 769c77e..b0e37ae 100644
--- a/tests/openssl/driver.cxx
+++ b/tests/openssl/driver.cxx
@@ -22,10 +22,9 @@ try
{
openssl os (nullfd, path ("-"), 2, path ("openssl"), "rand", 128);
- vector<char> r
- ((istreambuf_iterator<char> (os.in)), istreambuf_iterator<char> ());
-
+ vector<char> r (os.in.read_binary ());
os.in.close ();
+
return os.wait () && r.size () == 128 ? 0 : 1;
}
catch (const system_error& e)
diff --git a/tests/process/driver.cxx b/tests/process/driver.cxx
index b154bce..4694d5b 100644
--- a/tests/process/driver.cxx
+++ b/tests/process/driver.cxx
@@ -94,9 +94,7 @@ exec (const path& p,
cwd, args.data (), pr, bin_mode (move (pr3.out_fd)).get (), -2);
ifdstream is (bin_mode (move (pr3.in_ofd)));
-
- o = vector<char> (
- (istreambuf_iterator<char> (is)), istreambuf_iterator<char> ());
+ o = is.read_binary ();
r = pr2.wait () && r;
r = pr3.wait () && r;
@@ -104,9 +102,7 @@ exec (const path& p,
else
{
ifdstream is (bin_mode (move (pr.in_ofd)));
-
- o = vector<char> (
- (istreambuf_iterator<char> (is)), istreambuf_iterator<char> ());
+ o = is.read_binary ();
}
if (err)
@@ -125,9 +121,7 @@ exec (const path& p,
if (err && !out)
{
ifdstream is (bin_mode (move (pr.in_efd)));
-
- vector<char> e
- ((istreambuf_iterator<char> (is)), istreambuf_iterator<char> ());
+ vector<char> e (is.read_binary ());
r = in == e && r;
}