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:
53
test/std/numerics/numeric.ops/accumulate/accumulate.pass.cpp
Normal file
53
test/std/numerics/numeric.ops/accumulate/accumulate.pass.cpp
Normal file
@@ -0,0 +1,53 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <numeric>
|
||||
|
||||
// template <InputIterator Iter, MoveConstructible T>
|
||||
// requires HasPlus<T, Iter::reference>
|
||||
// && HasAssign<T, HasPlus<T, Iter::reference>::result_type>
|
||||
// T
|
||||
// accumulate(Iter first, Iter last, T init);
|
||||
|
||||
#include <numeric>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class Iter, class T>
|
||||
void
|
||||
test(Iter first, Iter last, T init, T x)
|
||||
{
|
||||
assert(std::accumulate(first, last, init) == x);
|
||||
}
|
||||
|
||||
template <class Iter>
|
||||
void
|
||||
test()
|
||||
{
|
||||
int ia[] = {1, 2, 3, 4, 5, 6};
|
||||
unsigned sa = sizeof(ia) / sizeof(ia[0]);
|
||||
test(Iter(ia), Iter(ia), 0, 0);
|
||||
test(Iter(ia), Iter(ia), 10, 10);
|
||||
test(Iter(ia), Iter(ia+1), 0, 1);
|
||||
test(Iter(ia), Iter(ia+1), 10, 11);
|
||||
test(Iter(ia), Iter(ia+2), 0, 3);
|
||||
test(Iter(ia), Iter(ia+2), 10, 13);
|
||||
test(Iter(ia), Iter(ia+sa), 0, 21);
|
||||
test(Iter(ia), Iter(ia+sa), 10, 31);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test<input_iterator<const int*> >();
|
||||
test<forward_iterator<const int*> >();
|
||||
test<bidirectional_iterator<const int*> >();
|
||||
test<random_access_iterator<const int*> >();
|
||||
test<const int*>();
|
||||
}
|
@@ -0,0 +1,55 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <numeric>
|
||||
|
||||
// template <InputIterator Iter, MoveConstructible T,
|
||||
// Callable<auto, const T&, Iter::reference> BinaryOperation>
|
||||
// requires HasAssign<T, BinaryOperation::result_type>
|
||||
// && CopyConstructible<BinaryOperation>
|
||||
// T
|
||||
// accumulate(Iter first, Iter last, T init, BinaryOperation binary_op);
|
||||
|
||||
#include <numeric>
|
||||
#include <functional>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class Iter, class T>
|
||||
void
|
||||
test(Iter first, Iter last, T init, T x)
|
||||
{
|
||||
assert(std::accumulate(first, last, init, std::multiplies<T>()) == x);
|
||||
}
|
||||
|
||||
template <class Iter>
|
||||
void
|
||||
test()
|
||||
{
|
||||
int ia[] = {1, 2, 3, 4, 5, 6};
|
||||
unsigned sa = sizeof(ia) / sizeof(ia[0]);
|
||||
test(Iter(ia), Iter(ia), 1, 1);
|
||||
test(Iter(ia), Iter(ia), 10, 10);
|
||||
test(Iter(ia), Iter(ia+1), 1, 1);
|
||||
test(Iter(ia), Iter(ia+1), 10, 10);
|
||||
test(Iter(ia), Iter(ia+2), 1, 2);
|
||||
test(Iter(ia), Iter(ia+2), 10, 20);
|
||||
test(Iter(ia), Iter(ia+sa), 1, 720);
|
||||
test(Iter(ia), Iter(ia+sa), 10, 7200);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test<input_iterator<const int*> >();
|
||||
test<forward_iterator<const int*> >();
|
||||
test<bidirectional_iterator<const int*> >();
|
||||
test<random_access_iterator<const int*> >();
|
||||
test<const int*>();
|
||||
}
|
@@ -0,0 +1,115 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <numeric>
|
||||
|
||||
// template <InputIterator InIter,
|
||||
// OutputIterator<auto, const InIter::value_type&> OutIter>
|
||||
// requires HasMinus<InIter::value_type, InIter::value_type>
|
||||
// && Constructible<InIter::value_type, InIter::reference>
|
||||
// && OutputIterator<OutIter,
|
||||
// HasMinus<InIter::value_type, InIter::value_type>::result_type>
|
||||
// && MoveAssignable<InIter::value_type>
|
||||
// OutIter
|
||||
// adjacent_difference(InIter first, InIter last, OutIter result);
|
||||
|
||||
#include <numeric>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class InIter, class OutIter>
|
||||
void
|
||||
test()
|
||||
{
|
||||
int ia[] = {15, 10, 6, 3, 1};
|
||||
int ir[] = {15, -5, -4, -3, -2};
|
||||
const unsigned s = sizeof(ia) / sizeof(ia[0]);
|
||||
int ib[s] = {0};
|
||||
OutIter r = std::adjacent_difference(InIter(ia), InIter(ia+s), OutIter(ib));
|
||||
assert(base(r) == ib + s);
|
||||
for (unsigned i = 0; i < s; ++i)
|
||||
assert(ib[i] == ir[i]);
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
class Y;
|
||||
|
||||
class X
|
||||
{
|
||||
int i_;
|
||||
|
||||
X& operator=(const X&);
|
||||
public:
|
||||
explicit X(int i) : i_(i) {}
|
||||
X(const X& x) : i_(x.i_) {}
|
||||
X& operator=(X&& x)
|
||||
{
|
||||
i_ = x.i_;
|
||||
x.i_ = -1;
|
||||
return *this;
|
||||
}
|
||||
|
||||
friend X operator-(const X& x, const X& y) {return X(x.i_ - y.i_);}
|
||||
|
||||
friend class Y;
|
||||
};
|
||||
|
||||
class Y
|
||||
{
|
||||
int i_;
|
||||
|
||||
Y& operator=(const Y&);
|
||||
public:
|
||||
explicit Y(int i) : i_(i) {}
|
||||
Y(const Y& y) : i_(y.i_) {}
|
||||
void operator=(const X& x) {i_ = x.i_;}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
test<input_iterator<const int*>, output_iterator<int*> >();
|
||||
test<input_iterator<const int*>, forward_iterator<int*> >();
|
||||
test<input_iterator<const int*>, bidirectional_iterator<int*> >();
|
||||
test<input_iterator<const int*>, random_access_iterator<int*> >();
|
||||
test<input_iterator<const int*>, int*>();
|
||||
|
||||
test<forward_iterator<const int*>, output_iterator<int*> >();
|
||||
test<forward_iterator<const int*>, forward_iterator<int*> >();
|
||||
test<forward_iterator<const int*>, bidirectional_iterator<int*> >();
|
||||
test<forward_iterator<const int*>, random_access_iterator<int*> >();
|
||||
test<forward_iterator<const int*>, int*>();
|
||||
|
||||
test<bidirectional_iterator<const int*>, output_iterator<int*> >();
|
||||
test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
|
||||
test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
|
||||
test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
|
||||
test<bidirectional_iterator<const int*>, int*>();
|
||||
|
||||
test<random_access_iterator<const int*>, output_iterator<int*> >();
|
||||
test<random_access_iterator<const int*>, forward_iterator<int*> >();
|
||||
test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
|
||||
test<random_access_iterator<const int*>, random_access_iterator<int*> >();
|
||||
test<random_access_iterator<const int*>, int*>();
|
||||
|
||||
test<const int*, output_iterator<int*> >();
|
||||
test<const int*, forward_iterator<int*> >();
|
||||
test<const int*, bidirectional_iterator<int*> >();
|
||||
test<const int*, random_access_iterator<int*> >();
|
||||
test<const int*, int*>();
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
X x[3] = {X(1), X(2), X(3)};
|
||||
Y y[3] = {Y(1), Y(2), Y(3)};
|
||||
std::adjacent_difference(x, x+3, y);
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,118 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <numeric>
|
||||
|
||||
// template <InputIterator InIter,
|
||||
// OutputIterator<auto, const InIter::value_type&> OutIter,
|
||||
// Callable<auto, const InIter::value_type&, const InIter::value_type&> BinaryOperation>
|
||||
// requires Constructible<InIter::value_type, InIter::reference>
|
||||
// && OutputIterator<OutIter, BinaryOperation::result_type>
|
||||
// && MoveAssignable<InIter::value_type>
|
||||
// && CopyConstructible<BinaryOperation>
|
||||
// OutIter
|
||||
// adjacent_difference(InIter first, InIter last, OutIter result, BinaryOperation binary_op);
|
||||
|
||||
#include <numeric>
|
||||
#include <functional>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class InIter, class OutIter>
|
||||
void
|
||||
test()
|
||||
{
|
||||
int ia[] = {15, 10, 6, 3, 1};
|
||||
int ir[] = {15, 25, 16, 9, 4};
|
||||
const unsigned s = sizeof(ia) / sizeof(ia[0]);
|
||||
int ib[s] = {0};
|
||||
OutIter r = std::adjacent_difference(InIter(ia), InIter(ia+s), OutIter(ib),
|
||||
std::plus<int>());
|
||||
assert(base(r) == ib + s);
|
||||
for (unsigned i = 0; i < s; ++i)
|
||||
assert(ib[i] == ir[i]);
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
class Y;
|
||||
|
||||
class X
|
||||
{
|
||||
int i_;
|
||||
|
||||
X& operator=(const X&);
|
||||
public:
|
||||
explicit X(int i) : i_(i) {}
|
||||
X(const X& x) : i_(x.i_) {}
|
||||
X& operator=(X&& x)
|
||||
{
|
||||
i_ = x.i_;
|
||||
x.i_ = -1;
|
||||
return *this;
|
||||
}
|
||||
|
||||
friend X operator-(const X& x, const X& y) {return X(x.i_ - y.i_);}
|
||||
|
||||
friend class Y;
|
||||
};
|
||||
|
||||
class Y
|
||||
{
|
||||
int i_;
|
||||
|
||||
Y& operator=(const Y&);
|
||||
public:
|
||||
explicit Y(int i) : i_(i) {}
|
||||
Y(const Y& y) : i_(y.i_) {}
|
||||
void operator=(const X& x) {i_ = x.i_;}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
test<input_iterator<const int*>, output_iterator<int*> >();
|
||||
test<input_iterator<const int*>, forward_iterator<int*> >();
|
||||
test<input_iterator<const int*>, bidirectional_iterator<int*> >();
|
||||
test<input_iterator<const int*>, random_access_iterator<int*> >();
|
||||
test<input_iterator<const int*>, int*>();
|
||||
|
||||
test<forward_iterator<const int*>, output_iterator<int*> >();
|
||||
test<forward_iterator<const int*>, forward_iterator<int*> >();
|
||||
test<forward_iterator<const int*>, bidirectional_iterator<int*> >();
|
||||
test<forward_iterator<const int*>, random_access_iterator<int*> >();
|
||||
test<forward_iterator<const int*>, int*>();
|
||||
|
||||
test<bidirectional_iterator<const int*>, output_iterator<int*> >();
|
||||
test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
|
||||
test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
|
||||
test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
|
||||
test<bidirectional_iterator<const int*>, int*>();
|
||||
|
||||
test<random_access_iterator<const int*>, output_iterator<int*> >();
|
||||
test<random_access_iterator<const int*>, forward_iterator<int*> >();
|
||||
test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
|
||||
test<random_access_iterator<const int*>, random_access_iterator<int*> >();
|
||||
test<random_access_iterator<const int*>, int*>();
|
||||
|
||||
test<const int*, output_iterator<int*> >();
|
||||
test<const int*, forward_iterator<int*> >();
|
||||
test<const int*, bidirectional_iterator<int*> >();
|
||||
test<const int*, random_access_iterator<int*> >();
|
||||
test<const int*, int*>();
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
X x[3] = {X(1), X(2), X(3)};
|
||||
Y y[3] = {Y(1), Y(2), Y(3)};
|
||||
std::adjacent_difference(x, x+3, y, std::minus<X>());
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,82 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <numeric>
|
||||
|
||||
// template <InputIterator Iter1, InputIterator Iter2, MoveConstructible T>
|
||||
// requires HasMultiply<Iter1::reference, Iter2::reference>
|
||||
// && HasPlus<T, HasMultiply<Iter1::reference, Iter2::reference>::result_type>
|
||||
// && HasAssign<T,
|
||||
// HasPlus<T,
|
||||
// HasMultiply<Iter1::reference,
|
||||
// Iter2::reference>::result_type>::result_type>
|
||||
// T
|
||||
// inner_product(Iter1 first1, Iter1 last1, Iter2 first2, T init);
|
||||
|
||||
#include <numeric>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class Iter1, class Iter2, class T>
|
||||
void
|
||||
test(Iter1 first1, Iter1 last1, Iter2 first2, T init, T x)
|
||||
{
|
||||
assert(std::inner_product(first1, last1, first2, init) == x);
|
||||
}
|
||||
|
||||
template <class Iter1, class Iter2>
|
||||
void
|
||||
test()
|
||||
{
|
||||
int a[] = {1, 2, 3, 4, 5, 6};
|
||||
int b[] = {6, 5, 4, 3, 2, 1};
|
||||
unsigned sa = sizeof(a) / sizeof(a[0]);
|
||||
test(Iter1(a), Iter1(a), Iter2(b), 0, 0);
|
||||
test(Iter1(a), Iter1(a), Iter2(b), 10, 10);
|
||||
test(Iter1(a), Iter1(a+1), Iter2(b), 0, 6);
|
||||
test(Iter1(a), Iter1(a+1), Iter2(b), 10, 16);
|
||||
test(Iter1(a), Iter1(a+2), Iter2(b), 0, 16);
|
||||
test(Iter1(a), Iter1(a+2), Iter2(b), 10, 26);
|
||||
test(Iter1(a), Iter1(a+sa), Iter2(b), 0, 56);
|
||||
test(Iter1(a), Iter1(a+sa), Iter2(b), 10, 66);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test<input_iterator<const int*>, input_iterator<const int*> >();
|
||||
test<input_iterator<const int*>, forward_iterator<const int*> >();
|
||||
test<input_iterator<const int*>, bidirectional_iterator<const int*> >();
|
||||
test<input_iterator<const int*>, random_access_iterator<const int*> >();
|
||||
test<input_iterator<const int*>, const int*>();
|
||||
|
||||
test<forward_iterator<const int*>, input_iterator<const int*> >();
|
||||
test<forward_iterator<const int*>, forward_iterator<const int*> >();
|
||||
test<forward_iterator<const int*>, bidirectional_iterator<const int*> >();
|
||||
test<forward_iterator<const int*>, random_access_iterator<const int*> >();
|
||||
test<forward_iterator<const int*>, const int*>();
|
||||
|
||||
test<bidirectional_iterator<const int*>, input_iterator<const int*> >();
|
||||
test<bidirectional_iterator<const int*>, forward_iterator<const int*> >();
|
||||
test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*> >();
|
||||
test<bidirectional_iterator<const int*>, random_access_iterator<const int*> >();
|
||||
test<bidirectional_iterator<const int*>, const int*>();
|
||||
|
||||
test<random_access_iterator<const int*>, input_iterator<const int*> >();
|
||||
test<random_access_iterator<const int*>, forward_iterator<const int*> >();
|
||||
test<random_access_iterator<const int*>, bidirectional_iterator<const int*> >();
|
||||
test<random_access_iterator<const int*>, random_access_iterator<const int*> >();
|
||||
test<random_access_iterator<const int*>, const int*>();
|
||||
|
||||
test<const int*, input_iterator<const int*> >();
|
||||
test<const int*, forward_iterator<const int*> >();
|
||||
test<const int*, bidirectional_iterator<const int*> >();
|
||||
test<const int*, random_access_iterator<const int*> >();
|
||||
test<const int*, const int*>();
|
||||
}
|
@@ -0,0 +1,85 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <numeric>
|
||||
|
||||
// template <InputIterator Iter1, InputIterator Iter2, MoveConstructible T,
|
||||
// class BinaryOperation1,
|
||||
// Callable<auto, Iter1::reference, Iter2::reference> BinaryOperation2>
|
||||
// requires Callable<BinaryOperation1, const T&, BinaryOperation2::result_type>
|
||||
// && HasAssign<T, BinaryOperation1::result_type>
|
||||
// && CopyConstructible<BinaryOperation1>
|
||||
// && CopyConstructible<BinaryOperation2>
|
||||
// T
|
||||
// inner_product(Iter1 first1, Iter1 last1, Iter2 first2,
|
||||
// T init, BinaryOperation1 binary_op1, BinaryOperation2 binary_op2);
|
||||
|
||||
#include <numeric>
|
||||
#include <functional>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class Iter1, class Iter2, class T>
|
||||
void
|
||||
test(Iter1 first1, Iter1 last1, Iter2 first2, T init, T x)
|
||||
{
|
||||
assert(std::inner_product(first1, last1, first2, init,
|
||||
std::multiplies<int>(), std::plus<int>()) == x);
|
||||
}
|
||||
|
||||
template <class Iter1, class Iter2>
|
||||
void
|
||||
test()
|
||||
{
|
||||
int a[] = {1, 2, 3, 4, 5, 6};
|
||||
int b[] = {6, 5, 4, 3, 2, 1};
|
||||
unsigned sa = sizeof(a) / sizeof(a[0]);
|
||||
test(Iter1(a), Iter1(a), Iter2(b), 1, 1);
|
||||
test(Iter1(a), Iter1(a), Iter2(b), 10, 10);
|
||||
test(Iter1(a), Iter1(a+1), Iter2(b), 1, 7);
|
||||
test(Iter1(a), Iter1(a+1), Iter2(b), 10, 70);
|
||||
test(Iter1(a), Iter1(a+2), Iter2(b), 1, 49);
|
||||
test(Iter1(a), Iter1(a+2), Iter2(b), 10, 490);
|
||||
test(Iter1(a), Iter1(a+sa), Iter2(b), 1, 117649);
|
||||
test(Iter1(a), Iter1(a+sa), Iter2(b), 10, 1176490);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test<input_iterator<const int*>, input_iterator<const int*> >();
|
||||
test<input_iterator<const int*>, forward_iterator<const int*> >();
|
||||
test<input_iterator<const int*>, bidirectional_iterator<const int*> >();
|
||||
test<input_iterator<const int*>, random_access_iterator<const int*> >();
|
||||
test<input_iterator<const int*>, const int*>();
|
||||
|
||||
test<forward_iterator<const int*>, input_iterator<const int*> >();
|
||||
test<forward_iterator<const int*>, forward_iterator<const int*> >();
|
||||
test<forward_iterator<const int*>, bidirectional_iterator<const int*> >();
|
||||
test<forward_iterator<const int*>, random_access_iterator<const int*> >();
|
||||
test<forward_iterator<const int*>, const int*>();
|
||||
|
||||
test<bidirectional_iterator<const int*>, input_iterator<const int*> >();
|
||||
test<bidirectional_iterator<const int*>, forward_iterator<const int*> >();
|
||||
test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*> >();
|
||||
test<bidirectional_iterator<const int*>, random_access_iterator<const int*> >();
|
||||
test<bidirectional_iterator<const int*>, const int*>();
|
||||
|
||||
test<random_access_iterator<const int*>, input_iterator<const int*> >();
|
||||
test<random_access_iterator<const int*>, forward_iterator<const int*> >();
|
||||
test<random_access_iterator<const int*>, bidirectional_iterator<const int*> >();
|
||||
test<random_access_iterator<const int*>, random_access_iterator<const int*> >();
|
||||
test<random_access_iterator<const int*>, const int*>();
|
||||
|
||||
test<const int*, input_iterator<const int*> >();
|
||||
test<const int*, forward_iterator<const int*> >();
|
||||
test<const int*, bidirectional_iterator<const int*> >();
|
||||
test<const int*, random_access_iterator<const int*> >();
|
||||
test<const int*, const int*>();
|
||||
}
|
38
test/std/numerics/numeric.ops/numeric.iota/iota.pass.cpp
Normal file
38
test/std/numerics/numeric.ops/numeric.iota/iota.pass.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <numeric>
|
||||
|
||||
// template <class ForwardIterator, class T>
|
||||
// void iota(ForwardIterator first, ForwardIterator last, T value);
|
||||
|
||||
#include <numeric>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class InIter>
|
||||
void
|
||||
test()
|
||||
{
|
||||
int ia[] = {1, 2, 3, 4, 5};
|
||||
int ir[] = {5, 6, 7, 8, 9};
|
||||
const unsigned s = sizeof(ia) / sizeof(ia[0]);
|
||||
std::iota(InIter(ia), InIter(ia+s), 5);
|
||||
for (unsigned i = 0; i < s; ++i)
|
||||
assert(ia[i] == ir[i]);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test<forward_iterator<int*> >();
|
||||
test<bidirectional_iterator<int*> >();
|
||||
test<random_access_iterator<int*> >();
|
||||
test<int*>();
|
||||
}
|
@@ -0,0 +1,70 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <numeric>
|
||||
|
||||
// template <InputIterator InIter, OutputIterator<auto, const InIter::value_type&> OutIter>
|
||||
// requires HasPlus<InIter::value_type, InIter::reference>
|
||||
// && HasAssign<InIter::value_type,
|
||||
// HasPlus<InIter::value_type, InIter::reference>::result_type>
|
||||
// && Constructible<InIter::value_type, InIter::reference>
|
||||
// OutIter
|
||||
// partial_sum(InIter first, InIter last, OutIter result);
|
||||
|
||||
#include <numeric>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class InIter, class OutIter>
|
||||
void
|
||||
test()
|
||||
{
|
||||
int ia[] = {1, 2, 3, 4, 5};
|
||||
int ir[] = {1, 3, 6, 10, 15};
|
||||
const unsigned s = sizeof(ia) / sizeof(ia[0]);
|
||||
int ib[s] = {0};
|
||||
OutIter r = std::partial_sum(InIter(ia), InIter(ia+s), OutIter(ib));
|
||||
assert(base(r) == ib + s);
|
||||
for (unsigned i = 0; i < s; ++i)
|
||||
assert(ib[i] == ir[i]);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test<input_iterator<const int*>, output_iterator<int*> >();
|
||||
test<input_iterator<const int*>, forward_iterator<int*> >();
|
||||
test<input_iterator<const int*>, bidirectional_iterator<int*> >();
|
||||
test<input_iterator<const int*>, random_access_iterator<int*> >();
|
||||
test<input_iterator<const int*>, int*>();
|
||||
|
||||
test<forward_iterator<const int*>, output_iterator<int*> >();
|
||||
test<forward_iterator<const int*>, forward_iterator<int*> >();
|
||||
test<forward_iterator<const int*>, bidirectional_iterator<int*> >();
|
||||
test<forward_iterator<const int*>, random_access_iterator<int*> >();
|
||||
test<forward_iterator<const int*>, int*>();
|
||||
|
||||
test<bidirectional_iterator<const int*>, output_iterator<int*> >();
|
||||
test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
|
||||
test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
|
||||
test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
|
||||
test<bidirectional_iterator<const int*>, int*>();
|
||||
|
||||
test<random_access_iterator<const int*>, output_iterator<int*> >();
|
||||
test<random_access_iterator<const int*>, forward_iterator<int*> >();
|
||||
test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
|
||||
test<random_access_iterator<const int*>, random_access_iterator<int*> >();
|
||||
test<random_access_iterator<const int*>, int*>();
|
||||
|
||||
test<const int*, output_iterator<int*> >();
|
||||
test<const int*, forward_iterator<int*> >();
|
||||
test<const int*, bidirectional_iterator<int*> >();
|
||||
test<const int*, random_access_iterator<int*> >();
|
||||
test<const int*, int*>();
|
||||
}
|
@@ -0,0 +1,72 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <numeric>
|
||||
|
||||
// template<InputIterator InIter,
|
||||
// OutputIterator<auto, const InIter::value_type&> OutIter,
|
||||
// Callable<auto, const InIter::value_type&, InIter::reference> BinaryOperation>
|
||||
// requires HasAssign<InIter::value_type, BinaryOperation::result_type>
|
||||
// && Constructible<InIter::value_type, InIter::reference>
|
||||
// && CopyConstructible<BinaryOperation>
|
||||
// OutIter
|
||||
// partial_sum(InIter first, InIter last, OutIter result, BinaryOperation binary_op);
|
||||
|
||||
#include <numeric>
|
||||
#include <functional>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class InIter, class OutIter>
|
||||
void
|
||||
test()
|
||||
{
|
||||
int ia[] = {1, 2, 3, 4, 5};
|
||||
int ir[] = {1, -1, -4, -8, -13};
|
||||
const unsigned s = sizeof(ia) / sizeof(ia[0]);
|
||||
int ib[s] = {0};
|
||||
OutIter r = std::partial_sum(InIter(ia), InIter(ia+s), OutIter(ib), std::minus<int>());
|
||||
assert(base(r) == ib + s);
|
||||
for (unsigned i = 0; i < s; ++i)
|
||||
assert(ib[i] == ir[i]);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test<input_iterator<const int*>, output_iterator<int*> >();
|
||||
test<input_iterator<const int*>, forward_iterator<int*> >();
|
||||
test<input_iterator<const int*>, bidirectional_iterator<int*> >();
|
||||
test<input_iterator<const int*>, random_access_iterator<int*> >();
|
||||
test<input_iterator<const int*>, int*>();
|
||||
|
||||
test<forward_iterator<const int*>, output_iterator<int*> >();
|
||||
test<forward_iterator<const int*>, forward_iterator<int*> >();
|
||||
test<forward_iterator<const int*>, bidirectional_iterator<int*> >();
|
||||
test<forward_iterator<const int*>, random_access_iterator<int*> >();
|
||||
test<forward_iterator<const int*>, int*>();
|
||||
|
||||
test<bidirectional_iterator<const int*>, output_iterator<int*> >();
|
||||
test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
|
||||
test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
|
||||
test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
|
||||
test<bidirectional_iterator<const int*>, int*>();
|
||||
|
||||
test<random_access_iterator<const int*>, output_iterator<int*> >();
|
||||
test<random_access_iterator<const int*>, forward_iterator<int*> >();
|
||||
test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
|
||||
test<random_access_iterator<const int*>, random_access_iterator<int*> >();
|
||||
test<random_access_iterator<const int*>, int*>();
|
||||
|
||||
test<const int*, output_iterator<int*> >();
|
||||
test<const int*, forward_iterator<int*> >();
|
||||
test<const int*, bidirectional_iterator<int*> >();
|
||||
test<const int*, random_access_iterator<int*> >();
|
||||
test<const int*, int*>();
|
||||
}
|
20
test/std/numerics/numeric.ops/version.pass.cpp
Normal file
20
test/std/numerics/numeric.ops/version.pass.cpp
Normal file
@@ -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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <numeric>
|
||||
|
||||
#include <numeric>
|
||||
|
||||
#ifndef _LIBCPP_VERSION
|
||||
#error _LIBCPP_VERSION not defined
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
Reference in New Issue
Block a user