diff options
author | Eric Fiselier <eric@efcs.ca> | 2015-05-27 00:28:30 +0000 |
---|---|---|
committer | Eric Fiselier <eric@efcs.ca> | 2015-05-27 00:28:30 +0000 |
commit | 6871bcb1226d0821973a0e5ba6b939c69cb04c02 (patch) | |
tree | 0880f2ac62ae28276bfd2bdeb4a54067beb58814 /libcxx/test/libcxx/selftest | |
parent | 17f9b4469e71544ef62059c7c7d99ee684cb323b (diff) | |
download | bcm5719-llvm-6871bcb1226d0821973a0e5ba6b939c69cb04c02.tar.gz bcm5719-llvm-6871bcb1226d0821973a0e5ba6b939c69cb04c02.zip |
Add test macros header to remove dependance on __config macros.
llvm-svn: 238267
Diffstat (limited to 'libcxx/test/libcxx/selftest')
-rw-r--r-- | libcxx/test/libcxx/selftest/test_macros.pass.cpp | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/libcxx/test/libcxx/selftest/test_macros.pass.cpp b/libcxx/test/libcxx/selftest/test_macros.pass.cpp new file mode 100644 index 00000000000..2c8ed4f454a --- /dev/null +++ b/libcxx/test/libcxx/selftest/test_macros.pass.cpp @@ -0,0 +1,58 @@ +//===----------------------------------------------------------------------===// +// +// 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 the "test_macros.h" header. +#include "test_macros.h" + +#ifndef TEST_STD_VER +#error TEST_STD_VER must be defined +#endif + +#ifndef TEST_DECLTYPE +#error TEST_DECLTYPE must be defined +#endif + +#ifndef TEST_NOEXCEPT +#error TEST_NOEXCEPT must be defined +#endif + +#ifndef TEST_STATIC_ASSERT +#error TEST_STATIC_ASSERT must be defined +#endif + +template <class T, class U> +struct is_same { enum { value = 0 }; }; + +template <class T> +struct is_same<T, T> { enum { value = 1 }; }; + +int foo() { return 0; } + +void test_noexcept() TEST_NOEXCEPT +{ +} + +void test_decltype() +{ + typedef TEST_DECLTYPE(foo()) MyType; + TEST_STATIC_ASSERT((is_same<MyType, int>::value), "is same"); +} + +void test_static_assert() +{ + TEST_STATIC_ASSERT((is_same<int, int>::value), "is same"); + TEST_STATIC_ASSERT((!is_same<int, long>::value), "not same"); +} + +int main() +{ + test_noexcept(); + test_decltype(); + test_static_assert(); +} |