BillyONeal updated this revision to Diff 141433.
BillyONeal retitled this revision from "[libcxx] [test] Remove non-portable 
assertions from filebuf's seekoff.pass.cpp test" to "[libcxx] [test] Remove 
non-portable assertions from filebuf tests".
BillyONeal edited the summary of this revision.
BillyONeal added a comment.

Added pbackfail.pass.cpp changes.


https://reviews.llvm.org/D45294

Files:
  
test/std/input.output/file.streams/fstreams/filebuf.virtuals/pbackfail.pass.cpp
  test/std/input.output/file.streams/fstreams/filebuf.virtuals/seekoff.pass.cpp


Index: 
test/std/input.output/file.streams/fstreams/filebuf.virtuals/seekoff.pass.cpp
===================================================================
--- 
test/std/input.output/file.streams/fstreams/filebuf.virtuals/seekoff.pass.cpp
+++ 
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 @@
                                                        | 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 @@
                                                        | 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');
Index: 
test/std/input.output/file.streams/fstreams/filebuf.virtuals/pbackfail.pass.cpp
===================================================================
--- 
test/std/input.output/file.streams/fstreams/filebuf.virtuals/pbackfail.pass.cpp
+++ 
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,16 +41,24 @@
         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;
         assert(f.open("underflow.dat", std::ios_base::in | std::ios_base::out) 
!= 0);
         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');
+        }
     }
 }


Index: test/std/input.output/file.streams/fstreams/filebuf.virtuals/seekoff.pass.cpp
===================================================================
--- test/std/input.output/file.streams/fstreams/filebuf.virtuals/seekoff.pass.cpp
+++ 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 @@
                                                        | 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 @@
                                                        | 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');
Index: test/std/input.output/file.streams/fstreams/filebuf.virtuals/pbackfail.pass.cpp
===================================================================
--- test/std/input.output/file.streams/fstreams/filebuf.virtuals/pbackfail.pass.cpp
+++ 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,16 +41,24 @@
         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;
         assert(f.open("underflow.dat", std::ios_base::in | std::ios_base::out) != 0);
         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');
+        }
     }
 }
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D45294: [l... Billy Robert O'Neal III via Phabricator via cfe-commits
    • [PATCH] D4529... Billy Robert O'Neal III via Phabricator via cfe-commits
    • [PATCH] D4529... Billy Robert O'Neal III via Phabricator via cfe-commits
    • [PATCH] D4529... Marshall Clow via Phabricator via cfe-commits
    • [PATCH] D4529... Billy Robert O'Neal III via Phabricator via cfe-commits

Reply via email to