summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/language.support/support.rtti
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx/test/std/language.support/support.rtti')
-rw-r--r--libcxx/test/std/language.support/support.rtti/bad.cast/bad_cast.pass.cpp27
-rw-r--r--libcxx/test/std/language.support/support.rtti/bad.typeid/bad_typeid.pass.cpp27
-rw-r--r--libcxx/test/std/language.support/support.rtti/type.info/type_info.pass.cpp26
-rw-r--r--libcxx/test/std/language.support/support.rtti/type.info/type_info_hash.pass.cpp23
-rw-r--r--libcxx/test/std/language.support/support.rtti/version.pass.cpp20
5 files changed, 123 insertions, 0 deletions
diff --git a/libcxx/test/std/language.support/support.rtti/bad.cast/bad_cast.pass.cpp b/libcxx/test/std/language.support/support.rtti/bad.cast/bad_cast.pass.cpp
new file mode 100644
index 00000000000..448ffba2c2b
--- /dev/null
+++ b/libcxx/test/std/language.support/support.rtti/bad.cast/bad_cast.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test bad_cast
+
+#include <typeinfo>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+ static_assert((std::is_base_of<std::exception, std::bad_cast>::value),
+ "std::is_base_of<std::exception, std::bad_cast>::value");
+ static_assert(std::is_polymorphic<std::bad_cast>::value,
+ "std::is_polymorphic<std::bad_cast>::value");
+ std::bad_cast b;
+ std::bad_cast b2 = b;
+ b2 = b;
+ const char* w = b2.what();
+ assert(w);
+}
diff --git a/libcxx/test/std/language.support/support.rtti/bad.typeid/bad_typeid.pass.cpp b/libcxx/test/std/language.support/support.rtti/bad.typeid/bad_typeid.pass.cpp
new file mode 100644
index 00000000000..190aebe5497
--- /dev/null
+++ b/libcxx/test/std/language.support/support.rtti/bad.typeid/bad_typeid.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test bad_typeid
+
+#include <typeinfo>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+ static_assert((std::is_base_of<std::exception, std::bad_typeid>::value),
+ "std::is_base_of<std::exception, std::bad_typeid>::value");
+ static_assert(std::is_polymorphic<std::bad_typeid>::value,
+ "std::is_polymorphic<std::bad_typeid>::value");
+ std::bad_typeid b;
+ std::bad_typeid b2 = b;
+ b2 = b;
+ const char* w = b2.what();
+ assert(w);
+}
diff --git a/libcxx/test/std/language.support/support.rtti/type.info/type_info.pass.cpp b/libcxx/test/std/language.support/support.rtti/type.info/type_info.pass.cpp
new file mode 100644
index 00000000000..2616865e6da
--- /dev/null
+++ b/libcxx/test/std/language.support/support.rtti/type.info/type_info.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test type_info
+
+#include <typeinfo>
+#include <cstring>
+#include <cassert>
+
+int main()
+{
+ const std::type_info& t1 = typeid(int);
+ const std::type_info& t2 = typeid(int);
+ assert(t1 == t2);
+ const std::type_info& t3 = typeid(short);
+ assert(t1 != t3);
+ assert(!t1.before(t2));
+ assert(strcmp(t1.name(), t2.name()) == 0);
+ assert(strcmp(t1.name(), t3.name()) != 0);
+}
diff --git a/libcxx/test/std/language.support/support.rtti/type.info/type_info_hash.pass.cpp b/libcxx/test/std/language.support/support.rtti/type.info/type_info_hash.pass.cpp
new file mode 100644
index 00000000000..c91a21ff2da
--- /dev/null
+++ b/libcxx/test/std/language.support/support.rtti/type.info/type_info_hash.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test type_info
+
+#include <typeinfo>
+#include <cstring>
+#include <cassert>
+
+int main()
+{
+ const std::type_info& t1 = typeid(int);
+ const std::type_info& t2 = typeid(int);
+ const std::type_info& t3 = typeid(short);
+ assert(t1.hash_code() == t2.hash_code());
+ assert(t1.hash_code() != t3.hash_code());
+}
diff --git a/libcxx/test/std/language.support/support.rtti/version.pass.cpp b/libcxx/test/std/language.support/support.rtti/version.pass.cpp
new file mode 100644
index 00000000000..0a9ece34f97
--- /dev/null
+++ b/libcxx/test/std/language.support/support.rtti/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <typeinfo>
+
+#include <typeinfo>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
OpenPOWER on IntegriCloud