Belle II Software development
eventExtraInfo.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#include <framework/dataobjects/EventExtraInfo.h>
10
11#include <gtest/gtest.h>
12
13#include <stdexcept>
14
15using namespace std;
16using namespace Belle2;
17
18TEST(EventExtraInfoTest, GetAddHasTest)
19{
20
21 EventExtraInfo eventExtraInfo;
22 EXPECT_FALSE(eventExtraInfo.hasExtraInfo("a"));
23 EXPECT_THROW(eventExtraInfo.getExtraInfo("a"), std::runtime_error);
24 EXPECT_NO_THROW(eventExtraInfo.addExtraInfo("a", 3));
25 EXPECT_FLOAT_EQ(eventExtraInfo.getExtraInfo("a"), 3);
26 EXPECT_TRUE(eventExtraInfo.hasExtraInfo("a"));
27 EXPECT_THROW(eventExtraInfo.addExtraInfo("a", 4), std::out_of_range);
28 EXPECT_NO_THROW(eventExtraInfo.setExtraInfo("a", 4));
29 EXPECT_FLOAT_EQ(eventExtraInfo.getExtraInfo("a"), 4);
30
31 EXPECT_FALSE(eventExtraInfo.hasExtraInfo("b"));
32 EXPECT_THROW(eventExtraInfo.getExtraInfo("b"), std::runtime_error);
33 EXPECT_NO_THROW(eventExtraInfo.addExtraInfo("b", 3.7));
34 EXPECT_FLOAT_EQ(eventExtraInfo.getExtraInfo("b"), 3.7);
35 EXPECT_TRUE(eventExtraInfo.hasExtraInfo("b"));
36 EXPECT_THROW(eventExtraInfo.addExtraInfo("b", 4.6), std::out_of_range);
37 EXPECT_FLOAT_EQ(eventExtraInfo.getExtraInfo("b"), 3.7);
38
39 EXPECT_FLOAT_EQ(eventExtraInfo.getExtraInfo("a"), 4);
40}
Class to stores ExtraInfo of the whole event.
Abstract base class for different kinds of events.
STL namespace.