diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2015-09-06 18:46:46 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2015-09-06 18:46:46 +0000 |
commit | 61b9a7258a7693d7f3674a5a1daf7b036ff1d382 (patch) | |
tree | ec41ed70ffca97240e76f9a78bb2dedba28f310c /test/libcxx/selftest/test_macros.pass.cpp | |
parent | f857581820d15e410e9945d2fcd5f7163be25a96 (diff) |
Notes
Diffstat (limited to 'test/libcxx/selftest/test_macros.pass.cpp')
-rw-r--r-- | test/libcxx/selftest/test_macros.pass.cpp | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/test/libcxx/selftest/test_macros.pass.cpp b/test/libcxx/selftest/test_macros.pass.cpp new file mode 100644 index 0000000000000..2c8ed4f454a7e --- /dev/null +++ b/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(); +} |