Belle II Software  release-05-02-19
sandBox4Testing.h
1 #include <framework/logging/Logger.h>
2 #include <gtest/gtest.h>
3 #include <vector>
4 
5 namespace Belle2 {
12  template <int Verbosity> class VerbosityClass {
13  public:
14  VerbosityClass() /*: state(Verbosity)*/ {}
15 
16 
19  {
20  double bla = 5;
21 
23  }
24 
26  static inline void GiveVerboseOutput(double& result) { /*state = */result++; }
27  protected:
28  };
29 
30 
32  class SandBox4TestingTest : public ::testing::Test {
33  public:
34 
36  bool doStuffHere(std::vector<double> testVector = { 42})
37  {
38  if (testVector[0] == 42) return true;
39  return false;
40  }
41 
42  protected:
43  };
44 
46  TEST_F(SandBox4TestingTest, testingVerbosityViaTemplates)
47  {
48  VerbosityClass<4> class4;
49  VerbosityClass<1> class1;
50 
51  class4.SomeCleverMethod();
52  class1.SomeCleverMethod();
53  }
54 
56  TEST_F(SandBox4TestingTest, JustSomePlayingAroundWithfunction)
57  {
58  EXPECT_TRUE(doStuffHere());
59  EXPECT_FALSE(doStuffHere({23}));
60 
61  if (doStuffHere() == false) {
62  B2WARNING("it didn't work!");
63  } else {
64  B2WARNING("yay, it worked!");
65  }
66  }
67 
68 
70  TEST_F(SandBox4TestingTest, TestIsNanAndIsInfBehavior)
71  {
72  EXPECT_TRUE(std::isinf(1. / 0.));
73  EXPECT_FALSE(std::isnan(1. / 0.));
74  EXPECT_TRUE(std::isnan(std::sqrt(-1)));
75  EXPECT_FALSE(std::isinf(std::sqrt(-1)));
76  EXPECT_TRUE(std::isnan(0. / 0.));
77  EXPECT_FALSE(std::isinf(0. / 0.));
78 
79 // EXPECT_FALSE(std::isnan(std::pow(0.,0.))); // this should be nan, but actually it is implementation dependent, therefore here we get for 0^0 = 1, which is mathematically not correct
80  EXPECT_FALSE(std::isinf(std::pow(0., 0.)));
81  }
83 } // namespace
Belle2::VerbosityClass::SomeCleverMethod
void SomeCleverMethod()
should behave differently for different verbosity-levels given - function
Definition: sandBox4Testing.h:18
Belle2::VerbosityClass::GiveVerboseOutput
static void GiveVerboseOutput(double &result)
do nothing relevant here just needing a dummy functhion
Definition: sandBox4Testing.h:26
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TEST_F
TEST_F(GlobalLabelTest, LargeNumberOfTimeDependentParameters)
Test large number of time-dep params for registration and retrieval.
Definition: globalLabel.cc:65
Belle2::VerbosityClass
should behave differently for different verbosity-levels given - class
Definition: sandBox4Testing.h:12
Belle2::SandBox4TestingTest::doStuffHere
bool doStuffHere(std::vector< double > testVector={ 42})
just a small dummy-function to test the expected behavior
Definition: sandBox4Testing.h:36
Belle2::SandBox4TestingTest
Testing autoAssignment of vectors for functions.
Definition: sandBox4Testing.h:32