diff options
author | Ed Schouten <ed@nuxi.nl> | 2015-03-16 17:56:04 +0000 |
---|---|---|
committer | Ed Schouten <ed@nuxi.nl> | 2015-03-16 17:56:04 +0000 |
commit | 152b6376820021154a8b6c782aec93c4b64c8f69 (patch) | |
tree | 006c4623ffb35f23862c666ee09f261b6c6248bb /libcxx | |
parent | 1d3b431c98ef13e35a06ab6e69005983e6d2a030 (diff) | |
download | bcm5719-llvm-152b6376820021154a8b6c782aec93c4b64c8f69.tar.gz bcm5719-llvm-152b6376820021154a8b6c782aec93c4b64c8f69.zip |
Don't attempt to validate the output of %p.
In one of the ostream tests we attempt to validate whether the output of
%p is correct. This is actually outside the scope of libc++, for the
%reason that the format of %p is implementation defined. Change the test
%to validate that the output of %p is non-empty and is different when
%given two unequal addresses.
Differential Revision: http://reviews.llvm.org/D8354
Reviewed by: marshall
llvm-svn: 232390
Diffstat (limited to 'libcxx')
-rw-r--r-- | libcxx/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/pointer.pass.cpp | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/libcxx/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/pointer.pass.cpp b/libcxx/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/pointer.pass.cpp index 114bba94c3f..b74d99a34ec 100644 --- a/libcxx/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/pointer.pass.cpp +++ b/libcxx/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/pointer.pass.cpp @@ -59,18 +59,27 @@ int main() assert(os.fail()); } { - testbuf<char> sb; - std::ostream os(&sb); - const void* n = 0; - os << n; - assert(os.good()); - // %p is implementation defined. - // On some platforms (Windows), it's a hex number without - // any leading 0x like prefix. - // In that format, we assume a null pointer will yield 2 '0' hex digits - // for each 8 bits of address space. - assert(sb.str() == "0x0" || sb.str() == "(nil)" || - sb.str() == std::string(sizeof(void*)*2,'0')); + testbuf<char> sb1; + std::ostream os1(&sb1); + int n1; + os1 << &n1; + assert(os1.good()); + std::string s1(sb1.str()); + + testbuf<char> sb2; + std::ostream os2(&sb2); + int n2; + os2 << &n2; + assert(os2.good()); + std::string s2(sb2.str()); + + // %p is implementation defined. Instead of validating the + // output, at least ensure that it does not generate an empty + // string. Also make sure that given two distinct addresses, the + // output of %p is different. + assert(!s1.empty()); + assert(!s2.empty()); + assert(s1 != s2); } { testbuf<char> sb; |