Re: c++ class design: where to put debug purpose utility class?
On Jun 30, 8:51 pm, Phlip <phlip2...@gmail.com> wrote:
std::vector<item> getAllItems();
private:
vector<string> pathList;
I would typedef every template instantiation, partly because
it's self-documenting, and because declaring the instantiation
point carefully can avoid obscure bugs in template expansion.
For a simple case like this, I don't know, but in general, yes.
Given the above class, my unit test is to cover addSearchPath()
What is the effect the added search path will have on other,
external objects?
Recall this is not "unit" testing - you are allowed to use
more than one object at a time!
The original question was about unit testing, so it is unit
testing. Not that that prevents him from using other objects.
, 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().
3 - detect the effect the added search path will have on behavior.
I guess James Kanze would suggest #1, but for my case I lean to #2.
He is discussing unit testing, not TDD...
Obviously, since the original poster apparently already has a
design, and knows what the class is supposed to do. Regardless
of how you arrive at the design, you need unit tests. (It was
my impression that TDD was supposed to give them to you as a
result of the design.)
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34