Skip to content

Instantly share code, notes, and snippets.

@jonluca
Last active March 15, 2018 04:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonluca/657f6950a5a4ccfea9233335b19b6082 to your computer and use it in GitHub Desktop.
Save jonluca/657f6950a5a4ccfea9233335b19b6082 to your computer and use it in GitHub Desktop.
Testing Two to Max Minus One
void setVarToOne(int* mVar){
if(mVar) *mVar = 1;
}
std::srand(time(0));
int mVar = 0;
setVarToOne(&mVar);
ASSERTEQ(mVar,1); //true
int anotherVar = 0;
setVarToOne(&anotherVar);
setVarToOne(&anotherVar);
ASSERTEQ(anotherVar,1); //true
int garbageVal;
setVarToOne(&garbageVal);
ASSERTEQ(garbageVal,1); //true
for(int i = 0; i < 500; i++){
int rand = std::rand();
setVarToOne(&rand);
ASSERTEQ(rand,1); //true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment