Project
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
Vertex.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
14
15#define BOOST_TEST_MODULE Test MCHContour Vertex
16#define BOOST_TEST_MAIN
17#define BOOST_TEST_DYN_LINK
18
19#include <boost/test/unit_test.hpp>
20#include <boost/test/data/test_case.hpp>
21#include "../include/MCHContour/Vertex.h"
22
23using namespace o2::mch::contour;
24
25BOOST_AUTO_TEST_SUITE(o2_mch_contour)
26BOOST_AUTO_TEST_SUITE(vertex)
27
29{
30 Vertex<int> v1{12, 0};
31 Vertex<int> v2{12, 20};
33 Vertex<int> v3{0, 0};
34 BOOST_TEST(isVertical(v1, v3) == false);
35}
36
38{
39 Vertex<int> v1{0, 12};
40 Vertex<int> v2{20, 12};
42 Vertex<int> v3{0, 0};
43 BOOST_TEST(isHorizontal(v1, v3) == false);
44}
45
47{
48 Vertex<double> a{0.0, 1.0};
49 Vertex<double> b{0.0, 1.0 + 1E-6};
50 BOOST_TEST(a == b);
51}
52
53BOOST_AUTO_TEST_CASE(DistancePointToSegmentWhereBasePointIsWithinSegment)
54{
55 Vertex<double> p0{0.0, 0.0};
56 Vertex<double> p1{6.0, 0.0};
57 double d = squaredDistanceOfPointToSegment(Vertex<double>{1.5, 3.5}, p0, p1);
58 BOOST_CHECK_EQUAL(d, 12.25);
59}
60
61BOOST_AUTO_TEST_CASE(DistancePointToSegmentWhereBasePointIsLeftOfSegment)
62{
63 Vertex<double> p0{0.0, 0.0};
64 Vertex<double> p1{6.0, 0.0};
65
66 double d = squaredDistanceOfPointToSegment(Vertex<double>{-3.0, 3.0}, p0, p1);
67 BOOST_CHECK_EQUAL(d, 18.0);
68}
69
70BOOST_AUTO_TEST_CASE(DistancePointToSegmentWhereBasePointIsRightOfSegment)
71{
72 Vertex<double> p0{0.0, 0.0};
73 Vertex<double> p1{6.0, 0.0};
74
75 double d = squaredDistanceOfPointToSegment(Vertex<double>{8.0, 2.0}, p0, p1);
76 BOOST_CHECK_EQUAL(d, 8.0);
77}
78BOOST_AUTO_TEST_SUITE_END()
79BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(Vertical)
Definition Vertex.cxx:28
uint64_t vertex
Definition RawEventData.h:9
constexpr int p1()
constexpr to accelerate the coordinates changing
GLboolean GLboolean GLboolean b
Definition glcorearb.h:1233
GLfloat GLfloat v1
Definition glcorearb.h:812
GLfloat GLfloat GLfloat GLfloat v3
Definition glcorearb.h:814
GLboolean GLboolean GLboolean GLboolean a
Definition glcorearb.h:1233
GLfloat GLfloat GLfloat v2
Definition glcorearb.h:813
auto squaredDistanceOfPointToSegment(const Vertex< T > &p, const Vertex< T > &p0, const Vertex< T > &p1) -> decltype(p0.x *p1.x)
Definition Vertex.h:117
bool isHorizontal(const Vertex< T > &a, const Vertex< T > &b)
Definition Vertex.h:92
bool isVertical(const Vertex< T > &a, const Vertex< T > &b)
Definition Vertex.h:86
BOOST_TEST(digits==digitsD, boost::test_tools::per_element())
BOOST_CHECK_EQUAL(triggersD.size(), triggers.size())