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


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@232390 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Ed Schouten 2015-03-16 17:56:04 +00:00
parent aa8a52c934
commit 061244c8fb

View File

@ -59,18 +59,27 @@ int main()
assert(os.fail()); assert(os.fail());
} }
{ {
testbuf<char> sb; testbuf<char> sb1;
std::ostream os(&sb); std::ostream os1(&sb1);
const void* n = 0; int n1;
os << n; os1 << &n1;
assert(os.good()); assert(os1.good());
// %p is implementation defined. std::string s1(sb1.str());
// On some platforms (Windows), it's a hex number without
// any leading 0x like prefix. testbuf<char> sb2;
// In that format, we assume a null pointer will yield 2 '0' hex digits std::ostream os2(&sb2);
// for each 8 bits of address space. int n2;
assert(sb.str() == "0x0" || sb.str() == "(nil)" || os2 << &n2;
sb.str() == std::string(sizeof(void*)*2,'0')); 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; testbuf<char> sb;