Make all fstream tests use tmpnam if creating files, rather than

hard-coded names.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@135444 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Sean Hunt
2011-07-18 23:51:21 +00:00
parent e6440c6fa2
commit 13aaf422e4
24 changed files with 205 additions and 156 deletions

View File

@@ -20,10 +20,12 @@
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
char temp[L_tmpnam];
tmpnam(temp);
{
std::filebuf f;
assert(f.open("test.dat", std::ios_base::out | std::ios_base::in
| std::ios_base::trunc) != 0);
assert(f.open(temp, std::ios_base::out | std::ios_base::in
| std::ios_base::trunc) != 0);
assert(f.is_open());
assert(f.sputn("123", 3) == 3);
f.pubseekoff(1, std::ios_base::beg);
@@ -34,11 +36,11 @@ int main()
assert(f2.is_open());
assert(f2.sgetc() == '2');
}
remove("test.dat");
remove(temp);
{
std::wfilebuf f;
assert(f.open("test.dat", std::ios_base::out | std::ios_base::in
| std::ios_base::trunc) != 0);
assert(f.open(temp, std::ios_base::out | std::ios_base::in
| std::ios_base::trunc) != 0);
assert(f.is_open());
assert(f.sputn(L"123", 3) == 3);
f.pubseekoff(1, std::ios_base::beg);
@@ -49,6 +51,6 @@ int main()
assert(f2.is_open());
assert(f2.sgetc() == L'2');
}
remove("test.dat");
remove(temp);
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}