File: Test_Test.cpp

package info (click to toggle)
pymol 2.5.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 42,288 kB
  • sloc: cpp: 476,472; python: 76,538; ansic: 29,510; javascript: 6,792; sh: 47; makefile: 24
file content (59 lines) | stat: -rw-r--r-- 1,170 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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
#include <algorithm>
#include <numeric>

#include "Test.h"

using namespace pymol::test;

namespace {
struct MyTestClass
{
  int i;
  float f;
  double d;
  bool b;
  int* p;
  int a[16];
};
}
// Creates a non-zero buffer
template <const int N> std::array<int, N> nonZeroBuffer()
{
  std::array<int, N> buffer;
  std::iota(buffer.begin(), buffer.end(), 1);
  return buffer;
}

TEST_CASE("ZeroStruct", "[TEST]")
{
  MyTestClass obj{}; // Uniform Initialization required
  REQUIRE(isStructZero(obj));
  obj.i = 1;
  REQUIRE(!isStructZero(obj));
}

TEST_CASE("isArrayZero", "[TEST]"){
  std::array<int, 10> a{}; //Uniform Initialization required
  REQUIRE(isArrayZero(a.data(), a.size()));
  a[0] = 1;
  REQUIRE(!isArrayZero(a.data(), a.size()));
}

TEST_CASE("isArrayEqual", "[TEST]")
{
  std::array<int, 4> a{1, 2, 3, 4};
  int b[4] = {1, 2, 3, 4};
  static_assert(a.size() == (sizeof(b)/sizeof(*b)), "Arrays not equal size!");
  REQUIRE(isArrayEqual(a.data(), b, a.size()));
  a[0] = 2;
  REQUIRE(!isArrayEqual(a.data(), b, a.size()));
}

TEST_CASE("isNullptr", "[TEST]")
{
  int a = 1;
  int* p = nullptr;
  REQUIRE(isNullptr(p));
  p = &a;
  REQUIRE(!isNullptr(p));
}