Belle II Software  release-05-01-25
MatcherInterface.test.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2016 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Nils Braun *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <tracking/trackFindingCDC/collectors/matchers/MatcherInterface.h>
12 
13 #include <tracking/trackFindingCDC/numerics/WeightComperator.h>
14 
15 #include <gtest/gtest.h>
16 
17 using namespace Belle2;
18 using namespace TrackFindingCDC;
19 
20 namespace {
22  class SimpleMatcher : public MatcherInterface<int, double> {
23  Weight match(int& a, const double& b) override
24  {
25  return a + b;
26  }
27  };
29  TEST(TrackFindingCDCTest, matcher_interface)
30  {
31  SimpleMatcher matcher;
32 
33  std::vector<WeightedRelation<int, const double>> relations;
34 
35  std::vector<int> collectorItems = {1, 2};
36  std::vector<double> collectionItems = {2.1, 2.2, 2.3};
37 
38  std::sort(relations.begin(), relations.end());
39  matcher.apply(collectorItems, collectionItems, relations);
40 
41  std::sort(relations.begin(), relations.end(), GreaterWeight());
42 
43  ASSERT_EQ(relations.size(), 6);
44  ASSERT_EQ(relations[5].getWeight(), 3.1);
45  ASSERT_EQ(relations[4].getWeight(), 3.2);
46  ASSERT_EQ(relations[3].getWeight(), 3.3);
47  ASSERT_EQ(relations[2].getWeight(), 4.1);
48  ASSERT_EQ(relations[1].getWeight(), 4.2);
49  ASSERT_EQ(relations[0].getWeight(), 4.3);
50  }
51 }
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TEST
TEST(TestgetDetectorRegion, TestgetDetectorRegion)
Test Constructors.
Definition: utilityFunctions.cc:18