FakeContainerTest.cpp 1.18 KB
Newer Older
1
2
3
4
5
6
7
#include <amdis/AMDiS.hpp>
#include <amdis/common/FakeContainer.hpp>

#include "Tests.hpp"

using namespace AMDiS;

8
void test1()
9
{
10
11
12
  FakeContainer<int,1> vec1;
  FakeContainer<int,1> vec2(vec1);
  FakeContainer<int,1> vec3(std::move(vec2));
13

14
15
  FakeContainer<int,1> vec4 = vec1;
  FakeContainer<int,1> vec5 = std::move(vec3);
16
17
18
19
20
21
22
23
24
25
26

  vec1.reserve(7);
  vec1.resize(1);
  vec4.resize(1);

  vec1[0] = 0.0;
  vec4[1] = vec1[0];

  vec1.push_back(42);
  vec1.emplace_back(42);

27
  AMDIS_TEST(!vec1.empty());
28
29

  vec1.front() = 1;
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
}


void test2()
{
  constexpr auto bitSet = FakeContainer<bool,true>{};

  // The bitset is not empty
  AMDIS_TEST(!bitSet.empty());

  // All entries are true
  std::size_t i = 0;
  for (auto it = bitSet.begin(); i < 10; ++it, ++i)
    AMDIS_TEST(*it);

  for (i = 0; i < 10; ++i) {
    AMDIS_TEST(bitSet[i]);
    AMDIS_TEST(bitSet.at(i));
  }

  // The front entry is true
  AMDIS_TEST(bitSet.front());

  // resize has not effect
  AMDIS_TEST(!bitSet.empty());

  // use bitset element as template parameter
  auto iconst = std::integral_constant<bool, bitSet[0]>{};
}


int main(int argc, char** argv)
{
  Environment env(argc, argv);

  test1();
  test2();
67

68
  return report_errors();
69
}