This is an archive of the discontinued LLVM Phabricator instance.

[libcxx] [test] Portability fix of std::basic_filebuf::overflow() test.
Needs ReviewPublic

Authored by amakc11 on Jan 10 2020, 9:42 AM.

Details

Summary

The standard specifies the behavior of std::basic_filebuf::overflow() as follows: "Behaves according to the description of basic_­streambuf<charT, traits>​::​overflow(c), except that the behavior of “consuming characters” is performed by first converting". The behavior of basic_­streambuf<charT, traits>​::​overflow(c) is specified as follows: "Let r be the number of characters in the pending sequence not consumed. If r is nonzero then pbase() and pptr() are set so that: pptr() - pbase() == r and the r characters starting at pbase() are the associated output stream. In case r is zero (all characters of the pending sequence have been consumed) then either pbase() is set to nullptr, or pbase() and pptr() are both set to the same non-null value". It means that in general the post-condition of this method is (pptr() == pbase()) || (pbase() == nullptr) || (pptr() - pbase() == r). This patch adds this post-condition check and marks other checks as libc++ specific making the test more portable.

BTW, methods pptr(), pbase() and epptr() return pointers, but this test compares their results with zero instead of nullptr. This is also fixed.

Diff Detail

Event Timeline

amakc11 created this revision.Jan 10 2020, 9:42 AM
Herald added a project: Restricted Project. · View Herald Transcript
amakc11 updated this revision to Diff 239165.Jan 20 2020, 10:27 AM

The first parameter of pubsetbuf method is also a pointer, so zero is changed to` nullptr`. Missed this in the original patch.