Last active
March 15, 2018 04:17
-
-
Save jonluca/657f6950a5a4ccfea9233335b19b6082 to your computer and use it in GitHub Desktop.
Testing Two to Max Minus One
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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