Afficher un message
Vieux 30/06/2008, 20h20   #9
1230987za@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: c++ class design: where to put debug purpose utility class?

Hi,

Here is more realistic capture of my problem, the original post is
over-simplified, but I do learn a lot from your guys' discussion,

class repo {
public:
repo();

/**
* Add one repo search path, if the path satisfies all the
requirements, this path will be stored internally.
*
* @returns 0 if succeeds
*/
int addSearchPath(string path);

/**
* Retrieve all the item from all the search paths
*/
std::vector<item> getAllItems();

private:
vector<string> pathList;

};

Given the above class, my unit test is to cover addSearchPath(), so
I can do either of the followings:
1. Just use the 2 public functions since they are the real API that
customer code will use.
2. Unit test code accesses the private data directly to verify
addSearchPath().

I guess James Kanze would suggest #1, but for my case I lean to #2.
The reason is unit test using #1 requires quite a bit setup for class
item while this unit test just want to test addSearchPath() does cover
all the requirements for a valid search path, so #1 seems to me too
much academic.

#2 serves my purpose very well and I do not want to add more API to
return the internal private data, I will use #define private public
trick.

Please throw your bricks.
  Réponse avec citation
 
Page generated in 0,05665 seconds with 9 queries