Skip to content

Commit

Permalink
adding a test fo the calculator
Browse files Browse the repository at this point in the history
  • Loading branch information
Russell Smith committed Dec 22, 2015
1 parent 47adef5 commit 6d20009
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmt/Makefile.RootCore
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ PACKAGE_BINFLAGS =
PACKAGE_LIBFLAGS =

# the list of packages we depend on:
PACKAGE_DEP = EventLoop Ext_RestFrames SUSYTools TauAnalysisTools CommonTools xAODMissingET
PACKAGE_DEP = EventLoop Ext_RestFrames SUSYTools TauAnalysisTools CommonTools xAODMissingET Asg_GoogleTest

# the list of packages we use if present, but that we can work without :
PACKAGE_TRYDEP =
Expand Down
55 changes: 55 additions & 0 deletions test/ut_rjigsawcalculator_lvlv_test.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
//author : Russell Smith
//date : December 2015
//adapted from Code from Nils Krumnack

#include <RJigsawTools/RJigsawCalculator_lvlv.h>

#include <RootCoreUtils/Assert.h>
#include <TSystem.h>
#include <cstdlib>
#include <fstream>
#include <gtest/gtest.h>

#include <unordered_map>
#include <xAODMissingET/MissingET.h>
#include <xAODJet/JetContainer.h>

struct RJigsawCalculator_lvlv_Test : testing::Test
{
static const std::string root;

static void SetUpTestCase ()
{
// gSystem->MakeDirectory ((root + "").c_str());
// std::ofstream ((root + "/file.root_17").c_str());
// std::ofstream ((root + "/ignore").c_str());
// gSystem->MakeDirectory ((root + "/sample").c_str());
// std::ofstream ((root + "/sample/samplefile.root").c_str());
// gSystem->MakeDirectory ((root + "/deepsample").c_str());
// gSystem->MakeDirectory ((root + "/deepsample/subdir").c_str());
// std::ofstream ((root + "/deepsample/subdir/deepfile.root").c_str());
}
};
const std::string RJigsawCalculator_lvlv_Test::root = "test1";

TEST (RJigsawCalculator_lvlv_Test, clearEventTest)
{
RJigsawCalculator_lvlv calc;
calc.initialize();

std::unordered_map<std::string, double> mymap;
xAOD::JetContainer jets;
xAOD::MissingET met;


EXPECT_TRUE( calc.calculate(mymap, jets, met) == EL::StatusCode::SUCCESS ) ;//the first event is fine no matter what
EXPECT_TRUE( calc.clearEvent() == EL::StatusCode::SUCCESS );//clear event should work
EXPECT_TRUE( calc.calculate(mymap, jets, met) == EL::StatusCode::SUCCESS ) ;//after clearing everything works fine
EXPECT_TRUE( calc.calculate(mymap, jets, met) == EL::StatusCode::FAILURE ) ;//calling calculate twice fails!
}

int main (int argc, char **argv)
{
::testing::InitGoogleTest (&argc, argv);
return RUN_ALL_TESTS();
}

0 comments on commit 6d20009

Please sign in to comment.