Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed use of '#define private public' for testing #11610

Merged
merged 1 commit into from
Oct 4, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions DataFormats/Common/interface/DataFrame.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef DataFormats_Common_DataFrame_h
#define DataFormats_Common_DataFrame_h

class TestDataFrame;
namespace edm {

class DataFrameContainer;
Expand Down Expand Up @@ -63,6 +64,9 @@ namespace edm {
size_type size() const { return m_size; }

private:
//for testing
friend class ::TestDataFrame;

data_type * data() {
return const_cast<data_type *>(m_data);
}
Expand Down
5 changes: 5 additions & 0 deletions DataFormats/Common/interface/DataFrameContainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include<vector>
#include<algorithm>

class TestDataFrame;

namespace edm {

/** an optitimized container that linearized a "vector of vector".
Expand Down Expand Up @@ -183,6 +185,9 @@ namespace edm {
// DataContainer const & data() const { return m_data;}

private:
//for testing
friend class ::TestDataFrame;

// subdetector id (as returned by DetId::subdetId())
int m_subdetId;

Expand Down
8 changes: 8 additions & 0 deletions DataFormats/Common/interface/DetSetVectorNew.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#include<vector>
#include <cassert>

class TestDetSet;

namespace edm { namespace refhelper { template<typename T> struct FindForNewDetSetVector; } }

//FIXME remove New when ready
Expand Down Expand Up @@ -203,6 +205,9 @@ namespace edmNew {
data_type & back() { return v.m_data.back();}

private:
//for testing
friend class ::TestDetSet;

DetSetVector<T> & v;
typename DetSetVector<T>::Item & item;
bool saveEmpty;
Expand Down Expand Up @@ -420,6 +425,9 @@ namespace edmNew {
void updateImpl(Item & item);

private:
//for testing
friend class ::TestDetSet;

// subdetector id (as returned by DetId::subdetId())
int m_subdetId;

Expand Down
5 changes: 5 additions & 0 deletions DataFormats/Common/interface/MapOfVectors.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include <boost/range/iterator_range.hpp>
#include <boost/iterator/iterator_facade.hpp>

class TestMapOfVectors;

namespace edm {

/* a linearized read-only map-of vectors
Expand Down Expand Up @@ -147,6 +149,9 @@ namespace edm {
}

private:
//for testing
friend class ::TestMapOfVectors;

std::vector<K> m_keys;
std::vector<size_type> m_offsets;
std::vector<T> m_data;
Expand Down
2 changes: 0 additions & 2 deletions DataFormats/Common/test/DataFrame_t.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
#include "Utilities/Testing/interface/CppUnit_testdriver.icpp"
#include "cppunit/extensions/HelperMacros.h"

#define private public
#include "DataFormats/Common/interface/DataFrame.h"
#include "DataFormats/Common/interface/DataFrameContainer.h"
#undef private
#include <vector>
#include <algorithm>
#include <cstdlib>
Expand Down
2 changes: 0 additions & 2 deletions DataFormats/Common/test/DetSetNew_t.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
#include "Utilities/Testing/interface/CppUnit_testdriver.icpp"
#include "cppunit/extensions/HelperMacros.h"

#define private public
#include "DataFormats/Common/interface/DetSetNew.h"
#include "DataFormats/Common/interface/DetSetVectorNew.h"
#include "DataFormats/Common/interface/DetSetAlgorithm.h"
#include "DataFormats/Common/interface/DetSet2RangeMap.h"
#undef private

#include "FWCore/Utilities/interface/EDMException.h"

Expand Down
2 changes: 0 additions & 2 deletions DataFormats/Common/test/MapOfVectors_t.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#include "Utilities/Testing/interface/CppUnit_testdriver.icpp"
#include "cppunit/extensions/HelperMacros.h"

#define private public
#include "DataFormats/Common/interface/MapOfVectors.h"
#undef private

#include<vector>
#include<algorithm>
Expand Down
23 changes: 22 additions & 1 deletion DataFormats/Provenance/interface/IndexIntoFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,13 @@ The interface is too complex for general use.
#include <set>
#include <vector>

class TestIndexIntoFile;
class TestIndexIntoFile1;
class TestIndexIntoFile2;
class TestIndexIntoFile3;
class TestIndexIntoFile4;
class TestIndexIntoFile5;

namespace edm {

class ProcessHistoryRegistry;
Expand Down Expand Up @@ -336,6 +343,7 @@ namespace edm {
}

private:

// All Runs, Lumis, and Events associated with the same
// ProcessHistory and Run in the same input file are processed
// contiguously. This parameter establishes the default order
Expand Down Expand Up @@ -757,7 +765,12 @@ namespace edm {
void copyPosition(IndexIntoFileItr const& position);

private:

//for testing
friend class ::TestIndexIntoFile;
friend class ::TestIndexIntoFile3;
friend class ::TestIndexIntoFile4;
friend class ::TestIndexIntoFile5;

// The rest of these are intended to be used only by code which tests
// this class.
IndexIntoFile const* indexIntoFile() const { return impl_->indexIntoFile(); }
Expand Down Expand Up @@ -1016,6 +1029,14 @@ namespace edm {

private:

//for testing
friend class ::TestIndexIntoFile;
friend class ::TestIndexIntoFile1;
friend class ::TestIndexIntoFile2;
friend class ::TestIndexIntoFile3;
friend class ::TestIndexIntoFile4;
friend class ::TestIndexIntoFile5;

/// This function will automatically get called when needed.
/// It depends only on the fact that the persistent data has been filled already.
void fillRunOrLumiIndexes() const;
Expand Down
3 changes: 0 additions & 3 deletions DataFormats/Provenance/test/indexIntoFile1_t.cppunit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@
#include "DataFormats/Provenance/interface/ProcessHistory.h"
#include "DataFormats/Provenance/interface/ProcessHistoryRegistry.h"

// This is very ugly, but I am told OK for white box unit tests
#define private public
#include "DataFormats/Provenance/interface/IndexIntoFile.h"
#undef private

#include <string>
#include <iostream>
Expand Down
3 changes: 0 additions & 3 deletions DataFormats/Provenance/test/indexIntoFile2_t.cppunit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@
#include "DataFormats/Provenance/interface/ProcessHistory.h"
#include "DataFormats/Provenance/interface/ProcessHistoryRegistry.h"

// This is very ugly, but I am told OK for white box unit tests
#define private public
#include "DataFormats/Provenance/interface/IndexIntoFile.h"
#undef private

#include <string>
#include <iostream>
Expand Down
3 changes: 0 additions & 3 deletions DataFormats/Provenance/test/indexIntoFile3_t.cppunit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@
#include "DataFormats/Provenance/interface/ProcessHistory.h"
#include "DataFormats/Provenance/interface/ProcessHistoryRegistry.h"

// This is very ugly, but I am told OK for white box unit tests
#define private public
#include "DataFormats/Provenance/interface/IndexIntoFile.h"
#undef private

#include <string>
#include <iostream>
Expand Down
3 changes: 0 additions & 3 deletions DataFormats/Provenance/test/indexIntoFile4_t.cppunit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@
#include "DataFormats/Provenance/interface/ProcessHistory.h"
#include "DataFormats/Provenance/interface/ProcessHistoryRegistry.h"

// This is very ugly, but I am told OK for white box unit tests
#define private public
#include "DataFormats/Provenance/interface/IndexIntoFile.h"
#undef private

#include <string>
#include <iostream>
Expand Down
3 changes: 0 additions & 3 deletions DataFormats/Provenance/test/indexIntoFile5_t.cppunit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@
#include "DataFormats/Provenance/interface/ProcessHistory.h"
#include "DataFormats/Provenance/interface/ProcessHistoryRegistry.h"

// This is very ugly, but I am told OK for white box unit tests
#define private public
#include "DataFormats/Provenance/interface/IndexIntoFile.h"
#undef private

#include <string>
#include <iostream>
Expand Down
3 changes: 0 additions & 3 deletions DataFormats/Provenance/test/indexIntoFile_t.cppunit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@
#include "DataFormats/Provenance/interface/ProcessHistory.h"
#include "DataFormats/Provenance/interface/ProcessHistoryRegistry.h"

// This is very ugly, but I am told OK for white box unit tests
#define private public
#include "DataFormats/Provenance/interface/IndexIntoFile.h"
#undef private

#include <string>
#include <iostream>
Expand Down
4 changes: 4 additions & 0 deletions FWCore/Framework/interface/Event.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ For its usage, see "FWCore/Framework/interface/PrincipalGetAdapter.h"
#include <typeinfo>
#include <vector>

class testEventGetRefBeforePut;

namespace edm {

class BranchDescription;
Expand Down Expand Up @@ -229,6 +231,8 @@ namespace edm {
productGetter() const;

private:
//for testing
friend class ::testEventGetRefBeforePut;

EventPrincipal const&
eventPrincipal() const;
Expand Down
3 changes: 0 additions & 3 deletions FWCore/Framework/test/event_getrefbeforeput_t.cppunit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ Test of the EventPrincipal class.
#include <string>
#include <typeinfo>

//have to do this evil in order to access commit_ member function
#define private public
#include "FWCore/Framework/interface/Event.h"
#undef private

class testEventGetRefBeforePut: public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(testEventGetRefBeforePut);
Expand Down
4 changes: 4 additions & 0 deletions FWCore/PluginManager/interface/CacheParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ If a space exists in either of these three fields, it will be replaced with a %,
#include "FWCore/PluginManager/interface/PluginInfo.h"

// forward declarations
class TestCacheParser;

namespace edmplugin {
class CacheParser
{
Expand All @@ -59,6 +61,8 @@ class CacheParser
static void read(std::istream&, LoadableToPlugins& oOut);
static void write(LoadableToPlugins& iIn, std::ostream&);
private:
//for testing
friend class ::TestCacheParser;
CacheParser(const CacheParser&); // stop default

const CacheParser& operator=(const CacheParser&); // stop default
Expand Down
1 change: 0 additions & 1 deletion FWCore/PluginManager/test/cacheparser_t.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include <sstream>

// user include files
#define private public
#include "FWCore/PluginManager/interface/CacheParser.h"

class TestCacheParser : public CppUnit::TestFixture
Expand Down
7 changes: 7 additions & 0 deletions FWCore/ServiceRegistry/interface/ServiceToken.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
// user include files

// forward declarations
class testServicesManager;
class TestServicesManagerOrder;

namespace edm {
class ServiceRegistry;
class ActivityRegistry;
Expand All @@ -38,6 +41,10 @@ namespace edm {
{
friend class edm::ServiceRegistry;
friend class edm::serviceregistry::ServicesManager;
//for testing
friend class ::testServicesManager;
friend class ::TestServicesManagerOrder;

public:
ServiceToken() {}
//virtual ~ServiceToken();
Expand Down
14 changes: 9 additions & 5 deletions FWCore/ServiceRegistry/test/servicesmanager_order.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,20 @@
#include "FWCore/ServiceRegistry/interface/ServiceWrapper.h"
#include "FWCore/Utilities/interface/Exception.h"

//NOTE: I need to open a 'back door' so I can test ServiceManager 'inheritance'
#define private public
#include "FWCore/ServiceRegistry/interface/ServiceToken.h"
#undef private

#include <cstdlib>
#include <vector>
#include <memory>
#include <iostream>

class TestServicesManagerOrder {
public:
static edm::ServiceToken makeToken(std::shared_ptr<edm::serviceregistry::ServicesManager> iManager) {
return edm::ServiceToken(iManager);
}
};

int main() try {
using namespace edm::serviceregistry;

Expand Down Expand Up @@ -47,7 +51,7 @@ int main() try {
auto wrapper = std::make_shared<ServiceWrapper<Service0> >(s0);
legacy->put(wrapper);
legacy->copySlotsFrom(ar);
edm::ServiceToken legacyToken(legacy);
edm::ServiceToken legacyToken = TestServicesManagerOrder::makeToken(legacy);

std::vector<edm::ParameterSet> vps1;

Expand All @@ -72,7 +76,7 @@ int main() try {
vps1.push_back(ps2);

auto legacy2 = std::make_shared<ServicesManager>(legacyToken, kTokenOverrides, vps1);
edm::ServiceToken legacyToken2(legacy2);
edm::ServiceToken legacyToken2 = TestServicesManagerOrder::makeToken(legacy2);


ServicesManager sm(legacyToken2, kOverlapIsError, vps);
Expand Down
3 changes: 0 additions & 3 deletions FWCore/ServiceRegistry/test/servicesmanager_t.cppunit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
* Created by Chris Jones on 9/5/05.
*
*/
//NOTE: I need to open a 'back door' so I can test ServiceManager 'inheritance'
#define private public
#include "FWCore/ServiceRegistry/interface/ServiceToken.h"
#undef private

#include "FWCore/ServiceRegistry/interface/ServicesManager.h"
#include "FWCore/ServiceRegistry/interface/ActivityRegistry.h"
Expand Down
6 changes: 5 additions & 1 deletion FWCore/Utilities/interface/EDGetToken.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ namespace edm {
bool isUninitialized() const { return m_value == s_uninitializedValue; }

private:

//for testing
friend class TestEDGetToken;

static const unsigned int s_uninitializedValue = 0xFFFFFFFF;

explicit EDGetToken(unsigned int iValue) : m_value(iValue) { }
Expand All @@ -71,6 +73,8 @@ namespace edm {
bool isUninitialized() const { return m_value == s_uninitializedValue; }

private:
//for testing
friend class TestEDGetToken;

static const unsigned int s_uninitializedValue = 0xFFFFFFFF;

Expand Down
Loading