diff options
author | Billy Robert O'Neal III <bion@microsoft.com> | 2018-04-26 22:18:33 +0000 |
---|---|---|
committer | Billy Robert O'Neal III <bion@microsoft.com> | 2018-04-26 22:18:33 +0000 |
commit | c3ae85dbcf1bc6eb5b8b5cb4b28b92396b73dfa7 (patch) | |
tree | 39f34d54364054e92f4b859a5ecc575c8e7075af /test | |
parent | a5996e8dc96c57bbd34334387fc9ea26091d22e9 (diff) | |
download | external_libcxx-c3ae85dbcf1bc6eb5b8b5cb4b28b92396b73dfa7.tar.gz external_libcxx-c3ae85dbcf1bc6eb5b8b5cb4b28b92396b73dfa7.tar.bz2 external_libcxx-c3ae85dbcf1bc6eb5b8b5cb4b28b92396b73dfa7.zip |
[libcxx] [test] Remove non-portable assertions from filebuf tests
seekoff.pass.cpp:
libc++'s tests are asserting things about the buffer passed to pubsetbuf. [filebuf.virtuals]/12 says that what the filebuf does with the buffer you give it is completely implementation defined. The MSVC++ implementation takes that buffer and hands it off to the CRT (by calling ::setvbuf) and the CRT doesn't necessarily follow the pattern this test wants.
This change simply makes asserts against the buffer's contents use LIBCPP_ASSERT instead of assert.
pbackfail.pass.cpp:
libc++'s tests are asserting about what characters will and will not be available in the putback area. [filebuf.virtuals]/9 says "The function can alter the number of putback positions available as a result of any call." This change LIBCPP_ASSERTS libc++'s behavior, but checks invariants of the putback area independently.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@330999 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r-- | test/std/input.output/file.streams/fstreams/filebuf.virtuals/pbackfail.pass.cpp | 20 | ||||
-rw-r--r-- | test/std/input.output/file.streams/fstreams/filebuf.virtuals/seekoff.pass.cpp | 8 |
2 files changed, 18 insertions, 10 deletions
diff --git a/test/std/input.output/file.streams/fstreams/filebuf.virtuals/pbackfail.pass.cpp b/test/std/input.output/file.streams/fstreams/filebuf.virtuals/pbackfail.pass.cpp index 4419cb51a..3ac505e52 100644 --- a/test/std/input.output/file.streams/fstreams/filebuf.virtuals/pbackfail.pass.cpp +++ b/test/std/input.output/file.streams/fstreams/filebuf.virtuals/pbackfail.pass.cpp @@ -11,11 +11,11 @@ // int_type pbackfail(int_type c = traits::eof()); -// This test is not entirely portable - #include <fstream> #include <cassert> +#include "test_macros.h" + template <class CharT> struct test_buf : public std::basic_filebuf<CharT> @@ -41,7 +41,12 @@ int main() assert(f.is_open()); assert(f.sbumpc() == '1'); assert(f.sgetc() == '2'); - assert(f.pbackfail('a') == -1); + typename test_buf<char>::int_type pbackResult = f.pbackfail('a'); + LIBCPP_ASSERT(pbackResult == -1); + if (pbackResult != -1) { + assert(f.sbumpc() == 'a'); + assert(f.sgetc() == '2'); + } } { test_buf<char> f; @@ -49,8 +54,11 @@ int main() assert(f.is_open()); assert(f.sbumpc() == '1'); assert(f.sgetc() == '2'); - assert(f.pbackfail('a') == 'a'); - assert(f.sbumpc() == 'a'); - assert(f.sgetc() == '2'); + typename test_buf<char>::int_type pbackResult = f.pbackfail('a'); + LIBCPP_ASSERT(pbackResult == 'a'); + if (pbackResult != -1) { + assert(f.sbumpc() == 'a'); + assert(f.sgetc() == '2'); + } } } diff --git a/test/std/input.output/file.streams/fstreams/filebuf.virtuals/seekoff.pass.cpp b/test/std/input.output/file.streams/fstreams/filebuf.virtuals/seekoff.pass.cpp index eb15facad..d2780c627 100644 --- a/test/std/input.output/file.streams/fstreams/filebuf.virtuals/seekoff.pass.cpp +++ b/test/std/input.output/file.streams/fstreams/filebuf.virtuals/seekoff.pass.cpp @@ -14,11 +14,11 @@ // pos_type seekpos(pos_type sp, // ios_base::openmode which = ios_base::in | ios_base::out); -// This test is not entirely portable - #include <fstream> #include <cassert> +#include "test_macros.h" + int main() { { @@ -30,7 +30,7 @@ int main() | std::ios_base::trunc) != 0); assert(f.is_open()); f.sputn("abcdefghijklmnopqrstuvwxyz", 26); - assert(buf[0] == 'v'); + LIBCPP_ASSERT(buf[0] == 'v'); pos_type p = f.pubseekoff(-15, std::ios_base::cur); assert(p == 11); assert(f.sgetc() == 'l'); @@ -51,7 +51,7 @@ int main() | std::ios_base::trunc) != 0); assert(f.is_open()); f.sputn(L"abcdefghijklmnopqrstuvwxyz", 26); - assert(buf[0] == L'v'); + LIBCPP_ASSERT(buf[0] == L'v'); pos_type p = f.pubseekoff(-15, std::ios_base::cur); assert(p == 11); assert(f.sgetc() == L'l'); |