summaryrefslogtreecommitdiffstats
path: root/libcxx/test/diagnostics/std.exceptions/overflow.error/overflow_error.pass.cpp
diff options
context:
space:
mode:
authorHoward Hinnant <hhinnant@apple.com>2010-05-11 19:42:16 +0000
committerHoward Hinnant <hhinnant@apple.com>2010-05-11 19:42:16 +0000
commit3e519524c118651123eecf60c2bbc5d65ad9bac3 (patch)
treeb2dd4168cfe448920a602cd7d2e40f95da187153 /libcxx/test/diagnostics/std.exceptions/overflow.error/overflow_error.pass.cpp
parent9132c59d43b6c590c9bb33496eebf9f192d6857a (diff)
downloadbcm5719-llvm-3e519524c118651123eecf60c2bbc5d65ad9bac3.tar.gz
bcm5719-llvm-3e519524c118651123eecf60c2bbc5d65ad9bac3.zip
libcxx initial import
llvm-svn: 103490
Diffstat (limited to 'libcxx/test/diagnostics/std.exceptions/overflow.error/overflow_error.pass.cpp')
-rw-r--r--libcxx/test/diagnostics/std.exceptions/overflow.error/overflow_error.pass.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/libcxx/test/diagnostics/std.exceptions/overflow.error/overflow_error.pass.cpp b/libcxx/test/diagnostics/std.exceptions/overflow.error/overflow_error.pass.cpp
new file mode 100644
index 00000000000..2d795c36e4e
--- /dev/null
+++ b/libcxx/test/diagnostics/std.exceptions/overflow.error/overflow_error.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test overflow_error
+
+#include <stdexcept>
+#include <type_traits>
+#include <cstring>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ static_assert((std::is_base_of<std::runtime_error, std::overflow_error>::value),
+ "std::is_base_of<std::runtime_error, std::overflow_error>::value");
+ static_assert(std::is_polymorphic<std::overflow_error>::value,
+ "std::is_polymorphic<std::overflow_error>::value");
+ {
+ const char* msg = "overflow_error message";
+ std::overflow_error e(msg);
+ assert(std::strcmp(e.what(), msg) == 0);
+ std::overflow_error e2(e);
+ assert(std::strcmp(e2.what(), msg) == 0);
+ e2 = e;
+ assert(std::strcmp(e2.what(), msg) == 0);
+ }
+ {
+ std::string msg("another overflow_error message");
+ std::overflow_error e(msg);
+ assert(e.what() == msg);
+ std::overflow_error e2(e);
+ assert(e2.what() == msg);
+ e2 = e;
+ assert(e2.what() == msg);
+ }
+}
OpenPOWER on IntegriCloud