home bbs files messages ]

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,828 of 33,346   
   =?UTF-8?Q?Tobias=20M=C3=BCller?= to Balog Pal   
   Re: Unit Testing Frameworks (was Re: Sin   
   26 Jan 13 19:01:43   
   
   l-september.org> 1a4815a6   
   From: troplin@bluewin.ch   
      
   Balog Pal  wrote:   
   > On 1/24/2013 8:23 AM, Tobias Müller wrote:   
   >> System calls are a good example. They are not really singletons, but the   
   >> same problems apply.   
   >   
   [snip: trolling]   
   >   
   > As following the arguments we should abandon the use of most free   
   > functions ans function-based APIs. Directly. Instead fill all our   
   > classes with pointers to those functions and use only those pointers for   
   > calls.   
      
   Ok let me repeat.   
   For me, there are two kinds of dependencies:   
   1. "normal" dependencies that i consider implementation details.   
   2. interactions with some sort of environment. Those should be made visible   
   in the interface.   
      
   For the first category, it's enough to test the interface of the class/unit   
   that has to be tested. The dependency is just considered a part of it.   
   For such dependencies, calling free functions or singletons is no problem   
   at all.   
   But singletons are most often used for the second category.   
      
   For the second category, your suggestion with the function pointers goes   
   IMO into the right direction.   
   But this is C++, not C. We can use templates like  the allocators in std::   
   containers.   
      
   >> So consider a unit test with where malloc or new deliberately fails at some   
   >> point.   
   >> In the case of not using DI (read "Allocators") the unittest itself cannot   
   >> dynamically allocate memory without failing or having side effects on the   
   >> actual test.   
   >   
   > Well, a plenty of people already demonstrated that this is NOT TRUE, but   
   > the rest just keep repeating the false claim. :(   
      
   I gave an example and the answer was essentially: You can also do it with   
   link time substitution if you use an ugly hack.   
      
   Tobi   
      
      
   --   
         [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
         [ comp.lang.c++.moderated.    First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca