|
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 |
| ) |
|
24 float myFloat = 3.1415;
25 double myDouble = 3.141592404915836;
26 BOOST_REQUIRE_NO_THROW( userinfo.
Set<
bool >(
"closure",
"arithmetic",
"myBool" , myBool ) );
27 BOOST_REQUIRE_NO_THROW( userinfo.
Set<
int >(
"closure",
"arithmetic",
"myInt" , myInt ) );
28 BOOST_REQUIRE_NO_THROW( userinfo.
Set<
float >(
"closure",
"arithmetic",
"myFloat" , myFloat ) );
29 BOOST_REQUIRE_NO_THROW( userinfo.
Set<
double>(
"closure",
"arithmetic",
"myDouble", myDouble) );
30 BOOST_TEST( myBool == userinfo.
Get<
bool >(
"closure",
"arithmetic",
"myBool" ) );
31 BOOST_TEST( myInt == userinfo.
Get<
int >(
"closure",
"arithmetic",
"myInt" ) );
32 BOOST_TEST( myFloat == userinfo.
Get<
float >(
"closure",
"arithmetic",
"myFloat" ) );
33 BOOST_TEST( myDouble == userinfo.
Get<
double>(
"closure",
"arithmetic",
"myDouble") );
34 BOOST_REQUIRE_THROW( userinfo.
Get<
double>(
"closure",
"arithmetic",
"myBool" ), boost::wrapexcept<std::invalid_argument> );
35 BOOST_REQUIRE_THROW( userinfo.
Set<
double>(
"closure",
"arithmetic",
"myBool", myDouble), boost::wrapexcept<std::invalid_argument> );
37 BOOST_TEST( userinfo.
Find(
"closure",
"arithmetic",
"sine") ==
false );
38 BOOST_TEST( userinfo.
Find(
"closure",
"trigonometry",
"sine") ==
false );
◆ BOOST_AUTO_TEST_CASE() [2/5]
BOOST_AUTO_TEST_CASE |
( |
hashing |
| ) |
|
97 userinfo1.
Set<
int>(
"test", 1);
98 userinfo2.
Set<
int>(
"test", 1);
100 hash<DT::UserInfo> Hash;
101 BOOST_TEST( Hash(userinfo1) == Hash(userinfo2) );
102 userinfo2.
Set<
int>(
"test", 2);
103 BOOST_TEST( Hash(userinfo1) != Hash(userinfo2) );
◆ BOOST_AUTO_TEST_CASE() [3/5]
BOOST_AUTO_TEST_CASE |
( |
literal |
| ) |
|
45 const char * myConstChar =
"hello, world";
46 string myString =
"Darwin";
47 fs::path myPath =
"example.info";
48 BOOST_REQUIRE_NO_THROW( userinfo.
Set<
const char *>(
"closure",
"literals",
"myConstChar", myConstChar) );
49 BOOST_REQUIRE_NO_THROW( userinfo.
Set<
string >(
"closure",
"literals",
"myString" , myString ) );
50 BOOST_REQUIRE_NO_THROW( userinfo.
Set<fs::path >(
"closure",
"literals",
"myPath" , myPath ) );
51 BOOST_TEST( strcmp(myConstChar, userinfo.
Get<
const char *>(
"closure",
"literals",
"myConstChar")) == 0 );
52 BOOST_TEST( myString == userinfo.
Get<
string >(
"closure",
"literals",
"myString" ) );
53 BOOST_TEST( myPath == userinfo.
Get<fs::path >(
"closure",
"literals",
"myPath" ) );
54 BOOST_REQUIRE_THROW( userinfo.
Get<
const char *>(
"this",
"does",
"not",
"exist"), boost::wrapexcept<std::invalid_argument> );
◆ BOOST_AUTO_TEST_CASE() [4/5]
BOOST_AUTO_TEST_CASE |
( |
loading |
| ) |
|
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" ) );
80 BOOST_REQUIRE_NO_THROW( userinfo.
Set<
int> (
"answer", 42 ) );
81 BOOST_REQUIRE_NO_THROW( userinfo.
Set<
float>(
"pi" , 3.1415f) );
91 BOOST_REQUIRE( ss.str() == ss2.str() );
◆ BOOST_AUTO_TEST_CASE() [5/5]
BOOST_AUTO_TEST_CASE |
( |
writing |
| ) |
|
61 BOOST_REQUIRE_NO_THROW( userinfo.
Set<
const char *>(
"corrections",
"JES",
"nominal") );
62 BOOST_REQUIRE_NO_THROW( userinfo.
Set<
const char *>(
"corrections",
"JES",
"JESup" ) );
63 BOOST_REQUIRE_NO_THROW( userinfo.
Set<
const char *>(
"corrections",
"JES",
"JESdn" ) );
65 BOOST_REQUIRE_NO_THROW( userinfo.
Write(
"test.info") );
66 BOOST_REQUIRE_NO_THROW( userinfo.
Write(
"test.json") );
67 BOOST_REQUIRE_NO_THROW( userinfo.
Write(
"test.xml") );
68 fs::remove(
"test.info");
69 fs::remove(
"test.json");
70 fs::remove(
"test.xml");
pt
Definition: jmarExample.py:19
BOOST_TEST(gendijet.Rapidity()==1.3573785791881385)