diff options
author | Howard Hinnant <hhinnant@apple.com> | 2010-05-11 19:42:16 +0000 |
---|---|---|
committer | Howard Hinnant <hhinnant@apple.com> | 2010-05-11 19:42:16 +0000 |
commit | 3e519524c118651123eecf60c2bbc5d65ad9bac3 (patch) | |
tree | b2dd4168cfe448920a602cd7d2e40f95da187153 /libcxx/test/language.support/support.rtti | |
parent | 9132c59d43b6c590c9bb33496eebf9f192d6857a (diff) | |
download | bcm5719-llvm-3e519524c118651123eecf60c2bbc5d65ad9bac3.tar.gz bcm5719-llvm-3e519524c118651123eecf60c2bbc5d65ad9bac3.zip |
libcxx initial import
llvm-svn: 103490
Diffstat (limited to 'libcxx/test/language.support/support.rtti')
5 files changed, 123 insertions, 0 deletions
diff --git a/libcxx/test/language.support/support.rtti/bad.cast/bad_cast.pass.cpp b/libcxx/test/language.support/support.rtti/bad.cast/bad_cast.pass.cpp new file mode 100644 index 00000000000..a4ce4180402 --- /dev/null +++ b/libcxx/test/language.support/support.rtti/bad.cast/bad_cast.pass.cpp @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. 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/language.support/support.rtti/bad.typeid/bad_typeid.pass.cpp b/libcxx/test/language.support/support.rtti/bad.typeid/bad_typeid.pass.cpp new file mode 100644 index 00000000000..7f4f818aa5b --- /dev/null +++ b/libcxx/test/language.support/support.rtti/bad.typeid/bad_typeid.pass.cpp @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. 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/language.support/support.rtti/type.info/type_info.pass.cpp b/libcxx/test/language.support/support.rtti/type.info/type_info.pass.cpp new file mode 100644 index 00000000000..d20f5243ac1 --- /dev/null +++ b/libcxx/test/language.support/support.rtti/type.info/type_info.pass.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. 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/language.support/support.rtti/type.info/type_info_hash.pass.cpp b/libcxx/test/language.support/support.rtti/type.info/type_info_hash.pass.cpp new file mode 100644 index 00000000000..00178e1c719 --- /dev/null +++ b/libcxx/test/language.support/support.rtti/type.info/type_info_hash.pass.cpp @@ -0,0 +1,23 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. 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/language.support/support.rtti/version.pass.cpp b/libcxx/test/language.support/support.rtti/version.pass.cpp new file mode 100644 index 00000000000..cd8fdaf259d --- /dev/null +++ b/libcxx/test/language.support/support.rtti/version.pass.cpp @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <typeinfo> + +#include <typeinfo> + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() +{ +} |