Source

mana-core-sgcomps / test / SGFolder_test.cxx

The default branch has multiple heads

Full commit
/** @file SGFolder_test.cxx
 * @brief unit test for SG::Folder
 * @author ATLAS Collaboration
 */
#undef NDEBUG

#include <algorithm>
#include <cassert>
#include <iostream>
#include <string>
#include "TestTools/initGaudi.h"
#include "GaudiKernel/ToolHandle.h"

// TEST_FOOBAR_H

#include "CLIDSvc/CLASS_DEF.h"
struct Foo{
  void doNothing() const {};
};
CLASS_DEF( Foo, 8101, 0) 
struct Bar{
  void doNothing() const {};
};
CLASS_DEF( Bar, 8107, 0) 

// TEST_FOOBAR_H


#include "SGTools/SGIFolder.h"

class ISvcLocator;

using namespace std;

int main () {
  cerr << "*** SG::Folder_test starts ***" <<endl;
  ISvcLocator* pDummy;
  if (!Athena_test::initGaudi("SGFolder_test.txt", pDummy)) {
    std::cerr << " This test cannot be run without init Gaudi" << endl;
    return -1;
  }
  ToolHandle<SG::IFolder> pFolder("SG::Folder/MyFolder");
  assert( pFolder.retrieve().isSuccess() );
  //this of course depends on the job opts
  assert( 4 == std::distance(pFolder->begin(), pFolder->end()) );

  assert( (pFolder->add("Bar", "abcd")).isSuccess() );
  assert( (pFolder->add("cucu", "")).isFailure() );
  assert( (pFolder->add(56789401, "34")).isFailure() ); 
  assert( 5 == std::distance(pFolder->begin(), pFolder->end()) );

  SG::IFolder::const_iterator i(pFolder->begin()), iEnd(pFolder->end());
  while (i != iEnd) {
    cout << i->id() << "/" << i->key() << endl;
    ++i;
  }
  cerr << "*** SG::Folder_test OK ***" <<endl;
  return 0;

}