 |
DAS
3.0
Das Analysis System
|
#include <boost/test/included/unit_test.hpp>
#include <boost/exception/all.hpp>
#include <boost/property_tree/info_parser.hpp>
#include "test.h"
#include "UserInfo.h"
◆ BOOST_TEST_MODULE
#define BOOST_TEST_MODULE testUserInfo |
◆ BOOST_AUTO_TEST_CASE() [1/5]
BOOST_AUTO_TEST_CASE |
( |
arithmetic |
| ) |
|
26 float myFloat = 3.1415;
27 double myDouble = 3.141592404915836;
28 BOOST_TEST_MESSAGE(
"Setting elements" );
29 BOOST_REQUIRE_NO_THROW( userinfo.
Set<
bool >(
"closure",
"arithmetic",
"myBool" , myBool ) );
30 BOOST_REQUIRE_NO_THROW( userinfo.
Set<
int >(
"closure",
"arithmetic",
"myInt" , myInt ) );
31 BOOST_REQUIRE_NO_THROW( userinfo.
Set<
float >(
"closure",
"arithmetic",
"myFloat" , myFloat ) );
32 BOOST_REQUIRE_NO_THROW( userinfo.
Set<
double>(
"closure",
"arithmetic",
"myDouble", myDouble) );
33 BOOST_TEST_MESSAGE(
"Getting existing elements" );
34 BOOST_TEST( myBool == userinfo.
Get<
bool >(
"closure",
"arithmetic",
"myBool" ) );
35 BOOST_TEST( myInt == userinfo.
Get<
int >(
"closure",
"arithmetic",
"myInt" ) );
36 BOOST_TEST( myFloat == userinfo.
Get<
float >(
"closure",
"arithmetic",
"myFloat" ) );
37 BOOST_TEST( myDouble == userinfo.
Get<
double>(
"closure",
"arithmetic",
"myDouble") );
38 BOOST_TEST_MESSAGE(
"Testing wrong calls of getters" );
39 BOOST_REQUIRE_THROW( userinfo.
Get<
double>(
"closure",
"arithmetic",
"" ), wrapexcept<invalid_argument> );
40 BOOST_REQUIRE_THROW( userinfo.
Get<
double>(
"closure",
"arithmetic",
"myBool" ), wrapexcept<invalid_argument> );
41 BOOST_REQUIRE_THROW( userinfo.
Set<
double>(
"closure",
"arithmetic",
"myBool", myDouble), wrapexcept<invalid_argument> );
42 BOOST_TEST_MESSAGE(
"Finding objects" );
43 BOOST_REQUIRE_THROW( userinfo.
Find(
"closure",
"arithmetic",
""), wrapexcept<invalid_argument> );
45 BOOST_TEST( userinfo.
Find(
"closure",
"arithmetic",
"sine") ==
false );
47 BOOST_TEST( userinfo.
Find(
"closure",
"trigonometry",
"sine") ==
false );
50 BOOST_TEST( userinfo.
List(
"closure",
"trigonometry",
"sine") !=
nullptr );
54 BOOST_REQUIRE_THROW(
UserInfo(l).MkPtree(), wrapexcept<invalid_argument> );
◆ BOOST_AUTO_TEST_CASE() [2/5]
BOOST_AUTO_TEST_CASE |
( |
hashing |
| ) |
|
113 userinfo1.
Set<
int>(
"test", 1);
114 userinfo2.
Set<
int>(
"test", 1);
117 BOOST_TEST( Hash(userinfo1) == Hash(userinfo2) );
118 userinfo2.
Set<
int>(
"test", 2);
119 BOOST_TEST( Hash(userinfo1) != Hash(userinfo2) );
◆ BOOST_AUTO_TEST_CASE() [3/5]
BOOST_AUTO_TEST_CASE |
( |
literal |
| ) |
|
61 const char * myConstChar =
"hello, world";
62 string myString =
"Darwin";
63 fs::path myPath =
"example.info";
64 BOOST_REQUIRE_NO_THROW( userinfo.
Set<
const char *>(
"closure",
"literals",
"myConstChar", myConstChar) );
65 BOOST_REQUIRE_NO_THROW( userinfo.
Set<
string >(
"closure",
"literals",
"myString" , myString ) );
66 BOOST_REQUIRE_NO_THROW( userinfo.
Set<fs::path >(
"closure",
"literals",
"myPath" , myPath ) );
67 BOOST_TEST( strcmp(myConstChar, userinfo.
Get<
const char *>(
"closure",
"literals",
"myConstChar")) == 0 );
68 BOOST_TEST( myString == userinfo.
Get<
string >(
"closure",
"literals",
"myString" ) );
69 BOOST_TEST( myPath == userinfo.
Get<fs::path >(
"closure",
"literals",
"myPath" ) );
70 BOOST_REQUIRE_THROW( userinfo.
Get<
const char *>(
"this",
"does",
"not",
"exist"), wrapexcept<invalid_argument> );
◆ BOOST_AUTO_TEST_CASE() [4/5]
BOOST_AUTO_TEST_CASE |
( |
loading |
| ) |
|
93 BOOST_REQUIRE_NO_THROW( userinfo.
Set<
const char *>(
"corrections",
"JES",
"nominal") );
94 BOOST_REQUIRE_NO_THROW( userinfo.
Set<
const char *>(
"corrections",
"JES",
"JESup" ) );
95 BOOST_REQUIRE_NO_THROW( userinfo.
Set<
const char *>(
"corrections",
"JES",
"JESdn" ) );
96 BOOST_REQUIRE_NO_THROW( userinfo.
Set<
int> (
"answer", 42 ) );
97 BOOST_REQUIRE_NO_THROW( userinfo.
Set<
float>(
"pi" , 3.1415f) );
106 BOOST_REQUIRE_NO_THROW( reconstructed.Write(ss2,
UserInfo::INFO) );
107 BOOST_REQUIRE( ss.str() == ss2.str() );
◆ BOOST_AUTO_TEST_CASE() [5/5]
BOOST_AUTO_TEST_CASE |
( |
writing |
| ) |
|
77 BOOST_REQUIRE_NO_THROW( userinfo.
Set<
const char *>(
"corrections",
"JES",
"nominal") );
78 BOOST_REQUIRE_NO_THROW( userinfo.
Set<
const char *>(
"corrections",
"JES",
"JESup" ) );
79 BOOST_REQUIRE_NO_THROW( userinfo.
Set<
const char *>(
"corrections",
"JES",
"JESdn" ) );
81 BOOST_REQUIRE_NO_THROW( userinfo.
Write(
"test.info") );
82 BOOST_REQUIRE_NO_THROW( userinfo.
Write(
"test.json") );
83 BOOST_REQUIRE_NO_THROW( userinfo.
Write(
"test.xml") );
84 fs::remove(
"test.info");
85 fs::remove(
"test.json");
86 fs::remove(
"test.xml");
pt
Definition: jmarExample.py:19
BOOST_TEST(gendijet.Rapidity()==1.3573785791881385)