File: TestNavigationState.cpp

package info (click to toggle)
vecgeom 1.2.8%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 24,016 kB
  • sloc: cpp: 88,803; ansic: 6,888; python: 1,035; sh: 582; sql: 538; makefile: 23
file content (102 lines) | stat: -rw-r--r-- 2,878 bytes parent folder | download | duplicates (2)
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#include "VecGeom/navigation/NavStatePath.h"
#include "VecGeom/base/Global.h"
#include <iostream>
#ifdef NDEBUG
#undef NDEBUG
#endif
#include <cassert>
using namespace vecgeom;

void NavStateUnitTest1()
{
  using NavigationState   = NavStatePath;
  NavigationState *state1 = NavigationState::MakeInstance(10);
  NavigationState *state2 = NavigationState::MakeInstance(10);
  // test - 0 ( one empty path )
  state1->Clear();
  state2->Clear();
  state2->PushIndexType(1);
  assert(state1->Distance(*state2) == 1);

  // test - 1 ( equal paths )
  state1->Clear();
  state2->Clear();
  state1->PushIndexType(1);
  state2->PushIndexType(1);
  assert(state1->RelativePath(*state2).compare("") == 0);
  assert(state1->Distance(*state2) == 0);
  std::cerr << state1->RelativePath(*state2) << "\n";

  // test - 2
  state1->Clear();
  state2->Clear();
  state1->PushIndexType(1);
  state2->PushIndexType(1);
  state2->PushIndexType(2);
  assert(state1->RelativePath(*state2).compare("/down/2") == 0);
  assert(state1->Distance(*state2) == 1);
  std::cerr << state1->RelativePath(*state2) << "\n";

  // test - 3
  state1->Clear();
  state2->Clear();
  state1->PushIndexType(1);
  state2->PushIndexType(1);
  state2->PushIndexType(2);
  state2->PushIndexType(4);
  std::cerr << state1->RelativePath(*state2) << "\n";
  std::cerr << state1->Distance(*state2) << "\n";
  assert(state1->RelativePath(*state2).compare("/down/2/down/4") == 0);
  assert(state1->Distance(*state2) == 2);

  // test - 4
  state1->Clear();
  state2->Clear();
  state1->PushIndexType(1);
  state1->PushIndexType(2);
  state1->PushIndexType(2);
  state2->PushIndexType(1);
  std::cerr << "HUHU " << state1->Distance(*state2) << "\n";
  assert(state1->Distance(*state2) == 2);
  assert(state1->RelativePath(*state2).compare("/up/up") == 0);
  std::cerr << state1->RelativePath(*state2) << "\n";

  // test - 5
  state1->Clear();
  state2->Clear();
  state1->PushIndexType(1);
  state1->PushIndexType(1);
  state1->PushIndexType(2);
  state1->PushIndexType(2);
  state2->PushIndexType(1);
  state2->PushIndexType(1);
  state2->PushIndexType(5);
  state2->PushIndexType(1);
  std::cerr << state1->RelativePath(*state2) << "\n";
  assert(state1->RelativePath(*state2).compare("/up/horiz/3/down/1") == 0);
  assert(state1->Distance(*state2) == 4);

  // test - 6
  state1->Clear();
  state2->Clear();
  state1->PushIndexType(1);
  state1->PushIndexType(1);
  state1->PushIndexType(2);
  state1->PushIndexType(2);
  state1->PushIndexType(3);

  state2->PushIndexType(1);
  state2->PushIndexType(1);
  state2->PushIndexType(5);
  state2->PushIndexType(1);
  state2->PushIndexType(1);
  std::cerr << state1->RelativePath(*state2) << "\n";
  assert(state1->RelativePath(*state2).compare("/up/up/horiz/3/down/1/down/1") == 0);
  assert(state1->Distance(*state2) == 6);
}

int main()
{
  NavStateUnitTest1();
  return 0;
}