Skip to content
Snippets Groups Projects
Commit 241fb7a1 authored by Frank Winklmeier's avatar Frank Winklmeier
Browse files

CppUnitSGServiceExample: delete package

parent 4df3f626
No related branches found
No related tags found
No related merge requests found
################################################################################
# Package: CppUnitSGServiceExample
################################################################################
# Declare the package name:
atlas_subdir( CppUnitSGServiceExample )
# Declare the package's dependencies:
atlas_depends_on_subdirs( PUBLIC
AtlasTest/TestTools
Control/AthenaKernel
Control/AthContainers
Control/StoreGate
GaudiKernel )
# Install files from the package:
atlas_install_headers( CppUnitSGServiceExample )
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#include <cassert>
#include <iostream>
#include <string>
#include <vector>
#include "AthContainers/DataVector.h"
#include "StoreGate/StoreGateSvc.h"
#include "AthenaKernel/getMessageSvc.h"
#include "GaudiKernel/MsgStream.h"
using namespace std;
struct SimpleTestStruct {
int m_int;
float m_float;
string m_string;
virtual ~SimpleTestStruct()
{
// cout << " ----> Destructor of SimpleTestStruct called for " << this << endl;
}
SimpleTestStruct() : m_int(1), m_float(2.), m_string("SimpleString") { }
SimpleTestStruct(int j) : m_int(j), m_float(2.), m_string("SimpleString") { }
SimpleTestStruct(const SimpleTestStruct& aaa) :
m_int(aaa.m_int), m_float(2.),
m_string("SimpleString") { }
void foo() { /* cout << "foo called" << m_int << endl; */}
void fooMessageSvc() {
MsgStream log( Athena::getMessageSvc(), "SimpleDataVector" );
log << MSG::INFO
<< "In SimpleDataVector Gaudi message service is called -" << endl
<< "and it prints the value of integer data member:" << m_int
<< endmsg;
}
};
class SimpleTestContainer : public DataVector<SimpleTestStruct>
{
public:
SimpleTestContainer() : DataVector<SimpleTestStruct>() { };
virtual ~SimpleTestContainer() {}
};
#empty file
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#include"CppUnitSGServiceExample/SimpleDataVector.h"
#include<cppunit/extensions/HelperMacros.h>
#include<cppunit/Exception.h>
#include<iostream>
/** Class to test the "SimpleDataVector.h" class
* StoreGate service required
*
* Use the HelperMacros.h header file to establish in a easy
* way the "SimpleDataVectorTest" test suite in which you can
* place all the tests concerning the tested class
*/
class SimpleDataVectorTest : public CppUnit::TestFixture
{
/// Definition of the unit test suite "SimpleDataVectorTest"
CPPUNIT_TEST_SUITE( SimpleDataVectorTest );
CPPUNIT_TEST( testSDV );
CPPUNIT_TEST( testSDV_false_negative );
CPPUNIT_TEST_SUITE_END();
private:
public:
void setUp()
{
}
void tearDown()
{
}
/// the test
void testSDV()
{
std::cout << " " << std::endl;
std::cout << "================================================================" << std::endl;
std::cout << "This is a simple CppUnit test of class SimpleDataVector." << std::endl;
std::cout << "The CppUnit test driver with StoreGate service is used." << std::endl;
std::cout << "CppUnit tests can be included in ATLAS nightlies." << std::endl;
std::cout << "Details in http://atlas.web.cern.ch/Atlas/GROUPS/SOFTWARE/" << std::endl;
std::cout << "OO/dist/nightlies/nicoswww/cppunit_testing.html" << std::endl;
std::cout << "================================================================" << std::endl;
typedef DataVector<int> IntVector;
IntVector intV;
CPPUNIT_ASSERT(intV.empty());
intV.reserve(10);
CPPUNIT_ASSERT(intV.capacity() == 10);
unsigned int i;
const unsigned int IFILL(3);
for (i=0; i<IFILL; ++i) intV.push_back(new int(i));
CPPUNIT_ASSERT (IFILL == intV.size());
CPPUNIT_ASSERT(distance(intV.begin(), intV.end()) == (int)IFILL);
CPPUNIT_ASSERT(*(intV.front()) == 0);
CPPUNIT_ASSERT(2 == *(intV.back()));
intV.front() = new int(7);
CPPUNIT_ASSERT(7 == *(intV.front()));
*(intV.back()) = 3;
DataVector<SimpleTestStruct>* aa = new DataVector<SimpleTestStruct>();
aa->push_back(new SimpleTestStruct());
aa->push_back(new SimpleTestStruct(9));
CPPUNIT_ASSERT(2 == aa->size());
DataVector<SimpleTestStruct>::iterator iter = aa->begin();
int n = 0;
for (; iter != aa->end(); iter++) {
(*iter)->foo();
(*iter)->fooMessageSvc();
n++;
}
CPPUNIT_ASSERT(2 == n);
delete aa;
}
void testSDV_false_negative()
{
DataVector<SimpleTestStruct>* aa = new DataVector<SimpleTestStruct>();
aa->push_back(new SimpleTestStruct(9));
CPPUNIT_ASSERT_MESSAGE( "This test fails intentionally", 2 == aa->size());
delete aa;
}
};
/// Registration of the test suite "SimpleDataVectorTest", so it
/// will be recognized by the main test program which drives the
/// different tests.
CPPUNIT_TEST_SUITE_REGISTRATION(SimpleDataVectorTest);
/// CppUnit test-driver common for all the cppunit test classes.
#include <TestTools/CppUnit_SGtestdriver.cxx>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment