CbmRoot
Loading...
Searching...
No Matches
_GTestCbmCut.cxx
Go to the documentation of this file.
1/* Copyright (C) 2016-2020 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Dario Ramirez [committer] */
4
5#include "CbmCut.h"
6#include "gtest/gtest.h"
7
8TEST(_GTestCbmCut, DefConstructor)
9{
10 CbmCut<float> cut;
11 EXPECT_EQ(false, cut.GetMinState());
12 EXPECT_EQ(false, cut.GetMaxState());
13}
14
15TEST(_GTestCbmCut, ParConstructor)
16{
17 float min = -100;
18 float max = +100;
19 CbmCut<float> cut(min, max);
20 EXPECT_EQ(true, cut.GetMinState());
21 EXPECT_EQ(true, cut.GetMaxState());
22 EXPECT_EQ(min, cut.GetMin());
23 EXPECT_EQ(max, cut.GetMax());
24}
25
26TEST(_GTestCbmCut, CheckOnDefConstructor)
27{
28 CbmCut<float> cut;
29 for (float i = -1e+6; i < 1e+6; i++) {
30 EXPECT_EQ(true, cut.Check(i));
31 }
32}
33
34TEST(_GTestCbmCut, CheckCase1)
35{
36 float min = -100;
37 float max = +100;
38 CbmCut<float> cut(min, max);
39 for (float i = -1e+6; i < 1e+6; i++) {
40 if (i < min || i > max) {
41 EXPECT_EQ(false, cut.Check(i));
42 }
43 else {
44 EXPECT_EQ(true, cut.Check(i));
45 }
46 }
47}
48
49TEST(_GTestCbmCut, CheckCase2)
50{
51 float min = +100;
52 float max = -100;
53 CbmCut<float> cut(min, max);
54 for (float i = -1e+6; i < 1e+6; i++) {
55 if (i <= max || i >= min) {
56 EXPECT_EQ(true, cut.Check(i));
57 }
58 else {
59 EXPECT_EQ(false, cut.Check(i));
60 }
61 }
62}
friend fscal max(fscal x, fscal y)
friend fscal min(fscal x, fscal y)
TEST(_GTestCbmCut, DefConstructor)
T GetMax() const
Definition CbmCut.h:78
T GetMin() const
Definition CbmCut.h:77
bool Check(T a) const
Check if the T is inside the configured ranges [min, max].
Definition CbmCut.h:45
bool GetMaxState() const
Definition CbmCut.h:80
bool GetMinState() const
Definition CbmCut.h:79