If you class has a function template (public, protected or private) you can specialize this function template with some custom type and gain access to it. With protected or private you have to trix around. With public it is pretty straight forward:

class my_class
{
  public:
    template<class T>
    void some_entry_point();

   private:
    void my_secret_function()
    {
       //...
    }
};


// test code:

namespace
{
   struct my_secret_type_to_specialize_entry_point {};
}

template<>
void my_class::some_entry_point<my_secret_type_to_specialize_entry_point>()
{
  // run the test here
}


BOOST_AUTO_TEST(...)
{
  my_class mc;

  mc.template some_entry_point<my_secret_type_to_specialize_entry_point>();
}


That's it ;) This point is well covered in one of the H. Sutter's exceptional C++ books and might be available on the Guru of the Week website (http://www.gotw.ca/gotw).



Regards,
Ovanes

On Tue, Jun 8, 2010 at 9:54 PM, <hmiller@hiwaay.net> wrote:
Is their a good strategy for testing private methods in a class using Boost?  I am looking for something that is non-intrusive to the developed code, but I can't think of any good ways without modifying the code under test.
Thanks,
Herb Miller