Sunday, August 2, 2009

Simple unit test problem?

I cant figure this out, I got it wrong on a assignment I wont get credit for it now but its driving me crazy can you figure this out?





1) Look at the implementation of RemoveWhitespace





2) Implement unit tests in individual .cpp/.h files under the 'Test/' folder.





3) Edit Test.cpp to execute your set of unit tests. Eg:





#include "Test.h"


#include "RemoveWhitespace.h"





// individual tests


#include "Tests/Example.h"


#include "Tests/EmptyInput.h"





void FullTest( ResultVec%26amp; results )


{


std::string testName;


bool result;





RemovesSpaces( testName, result );


results.push_back( ResultVec::value_type( testName, result ) );





EmptyInput( testName, result );


results.push_back( ResultVec::value_type( testName, result ) );





//...


}





Unit testfunctions should conform to the style:





void TestFunction( std::string%26amp; testName, bool%26amp; result );





Each function should fill out the test name and result so they can


be added to the result vector as shown above.

Simple unit test problem?
I'm not to sure what you would have directly wrong, but a case I would check for would be if the string was all spaces to begin with. Also, a string that has single spaces versus a string with more than one space between characters. A lot of this depends on what kind of input you expect.


No comments:

Post a Comment