Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.c++.moderated    |    Moderated discussion of C++ superhackery    |    33,346 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 32,835 of 33,346    |
|    Ian Collins to tom fogal    |
|    Re: testing internal code    |
|    28 Jan 13 15:11:12    |
   
   From: ian-news@this.is.invalid   
      
   tom fogal wrote:   
   > Hi all,   
   >   
   > I often hit a problem testing code and haven't seen a good solution   
   > for it. The issue is that I typically want to test code which is not   
   > 'exposed' and I'm curious if anyone has a better solution than I do.   
      
   The best technique is to expose the functionality.   
      
   > Here's a very simplified example: a module 'A' exposes a function 'F'.   
   > Internally, 'F' calls a function 'internal', which I'd like to test.   
   > In code:   
   >   
   > A.cpp:   
   > static void internal() { ... }   
   > void F() { internal(); }   
   >   
   > (Of course, in reality this is not simple forwarding; 'F' uses   
   > 'internal' merely as a tool among a more complicated series of tasks.)   
   >   
   > I can (and of course should) test to make sure 'F' fulfills its   
   > contract, but in many cases 'F' is complex. 'internal' of course has   
   > a contract as well, and if its not fulfilling it, I don't want to   
   > bother debugging 'F' until I know that 'internal' works.   
   >   
   > The solution I currently use is to define another internal-only   
   > symbol, 'test', which uses standard
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca