summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/input.output/string.streams/stringbuf
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2017-12-19 23:33:16 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2017-12-19 23:33:16 +0000
commit22c651c5770572641eaa16423b19e867f5f61d6b (patch)
treedd81257e2d9e5b0a97fd44be0a6bd7dce443644c /libcxx/test/std/input.output/string.streams/stringbuf
parent7e13aef4281a275b8884bf14d1bdd6c7e0e9375c (diff)
downloadbcm5719-llvm-22c651c5770572641eaa16423b19e867f5f61d6b.tar.gz
bcm5719-llvm-22c651c5770572641eaa16423b19e867f5f61d6b.zip
libcxx: Fix for basic_stringbuf::seekoff() after r320604.
As a result of this change, the basic_stringbuf constructor that takes a mode ends up leaving __hm_ set to 0, causing the comparison "__hm_ - __str_.data() < __noff" in seekoff() to succeed, which caused the function to incorrectly return -1. The fix is to account for the possibility of __hm_ being 0 when computing the distance from __hm_ to the start of the string. Differential Revision: https://reviews.llvm.org/D41319 llvm-svn: 321124
Diffstat (limited to 'libcxx/test/std/input.output/string.streams/stringbuf')
-rw-r--r--libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/seekoff.pass.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/seekoff.pass.cpp b/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/seekoff.pass.cpp
index 6d20db13189..8ec69cb24b6 100644
--- a/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/seekoff.pass.cpp
+++ b/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/seekoff.pass.cpp
@@ -21,6 +21,30 @@
int main()
{
{
+ std::stringbuf sb(std::ios_base::in);
+ assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == -1);
+ assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == -1);
+ assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == -1);
+ assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in | std::ios_base::out) == -1);
+ assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in | std::ios_base::out) == -1);
+ assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in | std::ios_base::out) == -1);
+ assert(sb.pubseekoff(0, std::ios_base::beg, std::ios_base::in) == 0);
+ assert(sb.pubseekoff(0, std::ios_base::cur, std::ios_base::in) == 0);
+ assert(sb.pubseekoff(0, std::ios_base::end, std::ios_base::in) == 0);
+ }
+ {
+ std::stringbuf sb(std::ios_base::out);
+ assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == -1);
+ assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == -1);
+ assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == -1);
+ assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in | std::ios_base::out) == -1);
+ assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in | std::ios_base::out) == -1);
+ assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in | std::ios_base::out) == -1);
+ assert(sb.pubseekoff(0, std::ios_base::beg, std::ios_base::out) == 0);
+ assert(sb.pubseekoff(0, std::ios_base::cur, std::ios_base::out) == 0);
+ assert(sb.pubseekoff(0, std::ios_base::end, std::ios_base::out) == 0);
+ }
+ {
std::stringbuf sb("0123456789", std::ios_base::in);
assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == -1);
assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == -1);
OpenPOWER on IntegriCloud