summaryrefslogtreecommitdiffstats
path: root/libcxx/test/input.output/file.streams/fstreams/ofstream.assign
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx/test/input.output/file.streams/fstreams/ofstream.assign')
-rw-r--r--libcxx/test/input.output/file.streams/fstreams/ofstream.assign/member_swap.pass.cpp27
-rw-r--r--libcxx/test/input.output/file.streams/fstreams/ofstream.assign/move_assign.pass.cpp14
-rw-r--r--libcxx/test/input.output/file.streams/fstreams/ofstream.assign/nonmember_swap.pass.cpp27
3 files changed, 38 insertions, 30 deletions
diff --git a/libcxx/test/input.output/file.streams/fstreams/ofstream.assign/member_swap.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/ofstream.assign/member_swap.pass.cpp
index 1f3f457fb73..7800c1abe8b 100644
--- a/libcxx/test/input.output/file.streams/fstreams/ofstream.assign/member_swap.pass.cpp
+++ b/libcxx/test/input.output/file.streams/fstreams/ofstream.assign/member_swap.pass.cpp
@@ -19,9 +19,12 @@
int main()
{
+ char temp1[L_tmpnam], temp2[L_tmpnam];
+ tmpnam(temp1);
+ tmpnam(temp2);
{
- std::ofstream fs1("test1.dat");
- std::ofstream fs2("test2.dat");
+ std::ofstream fs1(temp1);
+ std::ofstream fs2(temp2);
fs1 << 3.25;
fs2 << 4.5;
fs1.swap(fs2);
@@ -29,26 +32,26 @@ int main()
fs2 << ' ' << 4.5;
}
{
- std::ifstream fs("test1.dat");
+ std::ifstream fs(temp1);
double x = 0;
fs >> x;
assert(x == 3.25);
fs >> x;
assert(x == 4.5);
}
- remove("test1.dat");
+ remove(temp1);
{
- std::ifstream fs("test2.dat");
+ std::ifstream fs(temp2);
double x = 0;
fs >> x;
assert(x == 4.5);
fs >> x;
assert(x == 3.25);
}
- remove("test2.dat");
+ remove(temp2);
{
- std::wofstream fs1("test1.dat");
- std::wofstream fs2("test2.dat");
+ std::wofstream fs1(temp1);
+ std::wofstream fs2(temp2);
fs1 << 3.25;
fs2 << 4.5;
fs1.swap(fs2);
@@ -56,21 +59,21 @@ int main()
fs2 << ' ' << 4.5;
}
{
- std::wifstream fs("test1.dat");
+ std::wifstream fs(temp1);
double x = 0;
fs >> x;
assert(x == 3.25);
fs >> x;
assert(x == 4.5);
}
- remove("test1.dat");
+ remove(temp1);
{
- std::wifstream fs("test2.dat");
+ std::wifstream fs(temp2);
double x = 0;
fs >> x;
assert(x == 4.5);
fs >> x;
assert(x == 3.25);
}
- remove("test2.dat");
+ remove(temp2);
}
diff --git a/libcxx/test/input.output/file.streams/fstreams/ofstream.assign/move_assign.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/ofstream.assign/move_assign.pass.cpp
index 55aa3a2084a..7f80cfcc512 100644
--- a/libcxx/test/input.output/file.streams/fstreams/ofstream.assign/move_assign.pass.cpp
+++ b/libcxx/test/input.output/file.streams/fstreams/ofstream.assign/move_assign.pass.cpp
@@ -20,31 +20,33 @@
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ char temp[L_tmpnam];
+ tmpnam(temp);
{
- std::ofstream fso("test.dat");
+ std::ofstream fso(temp);
std::ofstream fs;
fs = move(fso);
fs << 3.25;
}
{
- std::ifstream fs("test.dat");
+ std::ifstream fs(temp);
double x = 0;
fs >> x;
assert(x == 3.25);
}
- remove("test.dat");
+ remove(temp);
{
- std::wofstream fso("test.dat");
+ std::wofstream fso(temp);
std::wofstream fs;
fs = move(fso);
fs << 3.25;
}
{
- std::wifstream fs("test.dat");
+ std::wifstream fs(temp);
double x = 0;
fs >> x;
assert(x == 3.25);
}
- remove("test.dat");
+ remove(temp);
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
diff --git a/libcxx/test/input.output/file.streams/fstreams/ofstream.assign/nonmember_swap.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/ofstream.assign/nonmember_swap.pass.cpp
index 8834cf39c62..24deafdcf5c 100644
--- a/libcxx/test/input.output/file.streams/fstreams/ofstream.assign/nonmember_swap.pass.cpp
+++ b/libcxx/test/input.output/file.streams/fstreams/ofstream.assign/nonmember_swap.pass.cpp
@@ -20,9 +20,12 @@
int main()
{
+ char temp1[L_tmpnam], temp2[L_tmpnam];
+ tmpnam(temp1);
+ tmpnam(temp2);
{
- std::ofstream fs1("test1.dat");
- std::ofstream fs2("test2.dat");
+ std::ofstream fs1(temp1);
+ std::ofstream fs2(temp2);
fs1 << 3.25;
fs2 << 4.5;
swap(fs1, fs2);
@@ -30,26 +33,26 @@ int main()
fs2 << ' ' << 4.5;
}
{
- std::ifstream fs("test1.dat");
+ std::ifstream fs(temp1);
double x = 0;
fs >> x;
assert(x == 3.25);
fs >> x;
assert(x == 4.5);
}
- remove("test1.dat");
+ remove(temp1);
{
- std::ifstream fs("test2.dat");
+ std::ifstream fs(temp2);
double x = 0;
fs >> x;
assert(x == 4.5);
fs >> x;
assert(x == 3.25);
}
- remove("test2.dat");
+ remove(temp2);
{
- std::wofstream fs1("test1.dat");
- std::wofstream fs2("test2.dat");
+ std::wofstream fs1(temp1);
+ std::wofstream fs2(temp2);
fs1 << 3.25;
fs2 << 4.5;
swap(fs1, fs2);
@@ -57,21 +60,21 @@ int main()
fs2 << ' ' << 4.5;
}
{
- std::wifstream fs("test1.dat");
+ std::wifstream fs(temp1);
double x = 0;
fs >> x;
assert(x == 3.25);
fs >> x;
assert(x == 4.5);
}
- remove("test1.dat");
+ remove(temp1);
{
- std::wifstream fs("test2.dat");
+ std::wifstream fs(temp2);
double x = 0;
fs >> x;
assert(x == 4.5);
fs >> x;
assert(x == 3.25);
}
- remove("test2.dat");
+ remove(temp2);
}
OpenPOWER on IntegriCloud