summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/input.output/iostream.format
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2016-04-29 07:23:20 +0000
committerEric Fiselier <eric@efcs.ca>2016-04-29 07:23:20 +0000
commit3ed9f6ebdeebcf770e20843bfb875f1f3c5f28f0 (patch)
tree61dc8d94c72526919b54333d5c0641892d484051 /libcxx/test/std/input.output/iostream.format
parent1a5799fe3e28d3c2c8a683cc6e49ccf7ba1d4893 (diff)
downloadbcm5719-llvm-3ed9f6ebdeebcf770e20843bfb875f1f3c5f28f0.tar.gz
bcm5719-llvm-3ed9f6ebdeebcf770e20843bfb875f1f3c5f28f0.zip
Fix PR21428 for long. Buffer was one byte too small in octal formatting case. Rename previously added test
llvm-svn: 268009
Diffstat (limited to 'libcxx/test/std/input.output/iostream.format')
-rw-r--r--libcxx/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minus1.pass.cpp (renamed from libcxx/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minus1.pass)40
1 files changed, 31 insertions, 9 deletions
diff --git a/libcxx/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minus1.pass b/libcxx/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minus1.pass.cpp
index 5f5a859cb29..c9b61725324 100644
--- a/libcxx/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minus1.pass
+++ b/libcxx/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minus1.pass.cpp
@@ -21,9 +21,10 @@
// Testing to make sure that the max length values are correctly inserted
-#include <iostream>
-#include <cctype>
#include <sstream>
+#include <ios>
+#include <cctype>
+#include <cstdint>
#include <cassert>
template <typename T>
@@ -31,7 +32,6 @@ void test_octal(const char *expected)
{
std::stringstream ss;
ss << std::oct << static_cast<T>(-1);
-
assert(ss.str() == expected);
}
@@ -40,8 +40,6 @@ void test_dec(const char *expected)
{
std::stringstream ss;
ss << std::dec << static_cast<T>(-1);
-
-// std::cout << ss.str() << " " << expected << std::endl;
assert(ss.str() == expected);
}
@@ -50,22 +48,32 @@ void test_hex(const char *expected)
{
std::stringstream ss;
ss << std::hex << static_cast<T>(-1);
-
+
std::string str = ss.str();
for (size_t i = 0; i < str.size(); ++i )
str[i] = std::toupper(str[i]);
-
+
assert(str == expected);
}
int main(int argc, char* argv[])
{
+
test_octal<uint16_t>( "177777");
test_octal< int16_t>( "177777");
test_octal<uint32_t>( "37777777777");
test_octal< int32_t>( "37777777777");
test_octal<uint64_t>("1777777777777777777777");
test_octal< int64_t>("1777777777777777777777");
+ test_octal<uint64_t>("1777777777777777777777");
+ if (sizeof(long) == sizeof(int64_t)) {
+ test_octal< unsigned long>("1777777777777777777777");
+ test_octal< long>("1777777777777777777777");
+ }
+ if (sizeof(long long) == sizeof(int64_t)) {
+ test_octal< unsigned long long>("1777777777777777777777");
+ test_octal< long long>("1777777777777777777777");
+ }
test_dec<uint16_t>( "65535");
test_dec< int16_t>( "-1");
@@ -73,6 +81,14 @@ int main(int argc, char* argv[])
test_dec< int32_t>( "-1");
test_dec<uint64_t>("18446744073709551615");
test_dec< int64_t>( "-1");
+ if (sizeof(long) == sizeof(int64_t)) {
+ test_dec<unsigned long>("18446744073709551615");
+ test_dec< long>( "-1");
+ }
+ if (sizeof(long long) == sizeof(int64_t)) {
+ test_dec<unsigned long long>("18446744073709551615");
+ test_dec< long long>( "-1");
+ }
test_hex<uint16_t>( "FFFF");
test_hex< int16_t>( "FFFF");
@@ -80,6 +96,12 @@ int main(int argc, char* argv[])
test_hex< int32_t>( "FFFFFFFF");
test_hex<uint64_t>("FFFFFFFFFFFFFFFF");
test_hex< int64_t>("FFFFFFFFFFFFFFFF");
-
- return 0;
+ if (sizeof(long) == sizeof(int64_t)) {
+ test_hex<unsigned long>("FFFFFFFFFFFFFFFF");
+ test_hex< long>("FFFFFFFFFFFFFFFF");
+ }
+ if (sizeof(long long) == sizeof(int64_t)) {
+ test_hex<unsigned long long>("FFFFFFFFFFFFFFFF");
+ test_hex< long long>("FFFFFFFFFFFFFFFF");
+ }
}
OpenPOWER on IntegriCloud