Move test into test/std subdirectory.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@224658 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <functional>
|
||||
|
||||
// divides
|
||||
|
||||
#include <functional>
|
||||
#include <type_traits>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::divides<int> F;
|
||||
const F f = F();
|
||||
static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), "");
|
||||
assert(f(36, 4) == 9);
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
typedef std::divides<> F2;
|
||||
const F2 f2 = F2();
|
||||
assert(f2(36, 4) == 9);
|
||||
assert(f2(36.0, 4) == 9);
|
||||
assert(f2(18, 4.0) == 4.5); // exact in binary
|
||||
|
||||
constexpr int foo = std::divides<int> () (3, 2);
|
||||
static_assert ( foo == 1, "" );
|
||||
|
||||
constexpr int bar = std::divides<> () (3.0, 2);
|
||||
static_assert ( bar == 1, "" );
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <functional>
|
||||
|
||||
// minus
|
||||
|
||||
#include <functional>
|
||||
#include <type_traits>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::minus<int> F;
|
||||
const F f = F();
|
||||
static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), "");
|
||||
assert(f(3, 2) == 1);
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
typedef std::minus<> F2;
|
||||
const F2 f2 = F2();
|
||||
assert(f2(3,2) == 1);
|
||||
assert(f2(3.0, 2) == 1);
|
||||
assert(f2(3, 2.5) == 0.5);
|
||||
|
||||
constexpr int foo = std::minus<int> () (3, 2);
|
||||
static_assert ( foo == 1, "" );
|
||||
|
||||
constexpr int bar = std::minus<> () (3.0, 2);
|
||||
static_assert ( bar == 1, "" );
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <functional>
|
||||
|
||||
// modulus
|
||||
|
||||
#include <functional>
|
||||
#include <type_traits>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::modulus<int> F;
|
||||
const F f = F();
|
||||
static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), "");
|
||||
assert(f(36, 8) == 4);
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
typedef std::modulus<> F2;
|
||||
const F2 f2 = F2();
|
||||
assert(f2(36, 8) == 4);
|
||||
assert(f2(36L, 8) == 4);
|
||||
assert(f2(36, 8L) == 4);
|
||||
|
||||
constexpr int foo = std::modulus<int> () (3, 2);
|
||||
static_assert ( foo == 1, "" );
|
||||
|
||||
constexpr int bar = std::modulus<> () (3L, 2);
|
||||
static_assert ( bar == 1, "" );
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <functional>
|
||||
|
||||
// multiplies
|
||||
|
||||
#include <functional>
|
||||
#include <type_traits>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::multiplies<int> F;
|
||||
const F f = F();
|
||||
static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), "");
|
||||
assert(f(3, 2) == 6);
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
typedef std::multiplies<> F2;
|
||||
const F2 f2 = F2();
|
||||
assert(f2(3,2) == 6);
|
||||
assert(f2(3.0, 2) == 6);
|
||||
assert(f2(3, 2.5) == 7.5); // exact in binary
|
||||
|
||||
constexpr int foo = std::multiplies<int> () (3, 2);
|
||||
static_assert ( foo == 6, "" );
|
||||
|
||||
constexpr int bar = std::multiplies<> () (3.0, 2);
|
||||
static_assert ( bar == 6, "" );
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <functional>
|
||||
|
||||
// negate
|
||||
|
||||
#include <functional>
|
||||
#include <type_traits>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::negate<int> F;
|
||||
const F f = F();
|
||||
static_assert((std::is_base_of<std::unary_function<int, int>, F>::value), "");
|
||||
assert(f(36) == -36);
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
typedef std::negate<> F2;
|
||||
const F2 f2 = F2();
|
||||
assert(f2(36) == -36);
|
||||
assert(f2(36L) == -36);
|
||||
assert(f2(36.0) == -36);
|
||||
|
||||
constexpr int foo = std::negate<int> () (3);
|
||||
static_assert ( foo == -3, "" );
|
||||
|
||||
constexpr int bar = std::negate<> () (3.0);
|
||||
static_assert ( bar == -3, "" );
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <functional>
|
||||
|
||||
// plus
|
||||
|
||||
#include <functional>
|
||||
#include <type_traits>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::plus<int> F;
|
||||
const F f = F();
|
||||
static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), "");
|
||||
assert(f(3, 2) == 5);
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
typedef std::plus<> F2;
|
||||
const F2 f2 = F2();
|
||||
assert(f2(3,2) == 5);
|
||||
assert(f2(3.0, 2) == 5);
|
||||
assert(f2(3, 2.5) == 5.5);
|
||||
|
||||
constexpr int foo = std::plus<int> () (3, 2);
|
||||
static_assert ( foo == 5, "" );
|
||||
|
||||
constexpr int bar = std::plus<> () (3.0, 2);
|
||||
static_assert ( bar == 5, "" );
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include <functional>
|
||||
#include <string>
|
||||
|
||||
template <class _Tp>
|
||||
struct is_transparent
|
||||
{
|
||||
private:
|
||||
struct __two {char __lx; char __lxx;};
|
||||
template <class _Up> static __two __test(...);
|
||||
template <class _Up> static char __test(typename _Up::is_transparent* = 0);
|
||||
public:
|
||||
static const bool value = sizeof(__test<_Tp>(0)) == 1;
|
||||
};
|
||||
|
||||
|
||||
int main () {
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
|
||||
static_assert ( !is_transparent<std::plus<int>>::value, "" );
|
||||
static_assert ( !is_transparent<std::plus<std::string>>::value, "" );
|
||||
static_assert ( is_transparent<std::plus<void>>::value, "" );
|
||||
static_assert ( is_transparent<std::plus<>>::value, "" );
|
||||
|
||||
static_assert ( !is_transparent<std::minus<int>>::value, "" );
|
||||
static_assert ( !is_transparent<std::minus<std::string>>::value, "" );
|
||||
static_assert ( is_transparent<std::minus<void>>::value, "" );
|
||||
static_assert ( is_transparent<std::minus<>>::value, "" );
|
||||
|
||||
static_assert ( !is_transparent<std::multiplies<int>>::value, "" );
|
||||
static_assert ( !is_transparent<std::multiplies<std::string>>::value, "" );
|
||||
static_assert ( is_transparent<std::multiplies<void>>::value, "" );
|
||||
static_assert ( is_transparent<std::multiplies<>>::value, "" );
|
||||
|
||||
static_assert ( !is_transparent<std::divides<int>>::value, "" );
|
||||
static_assert ( !is_transparent<std::divides<std::string>>::value, "" );
|
||||
static_assert ( is_transparent<std::divides<void>>::value, "" );
|
||||
static_assert ( is_transparent<std::divides<>>::value, "" );
|
||||
|
||||
static_assert ( !is_transparent<std::modulus<int>>::value, "" );
|
||||
static_assert ( !is_transparent<std::modulus<std::string>>::value, "" );
|
||||
static_assert ( is_transparent<std::modulus<void>>::value, "" );
|
||||
static_assert ( is_transparent<std::modulus<>>::value, "" );
|
||||
|
||||
static_assert ( !is_transparent<std::negate<int>>::value, "" );
|
||||
static_assert ( !is_transparent<std::negate<std::string>>::value, "" );
|
||||
static_assert ( is_transparent<std::negate<void>>::value, "" );
|
||||
static_assert ( is_transparent<std::negate<>>::value, "" );
|
||||
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user