mirror of
https://bitbucket.org/Mattrixwv/my-classes.git
synced 2025-12-06 18:23:57 -05:00
Added test for isPandigital
This commit is contained in:
@@ -39,14 +39,15 @@ bool testGetPermutations();
|
|||||||
bool testFindNumOccurrence();
|
bool testFindNumOccurrence();
|
||||||
bool testSplit();
|
bool testSplit();
|
||||||
bool testIsPalindrome();
|
bool testIsPalindrome();
|
||||||
|
bool testIsPandigital();
|
||||||
|
|
||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
mee::Stopwatch timer;
|
mee::Stopwatch timer;
|
||||||
bool passedTest = false;
|
bool passedTest = false;
|
||||||
bool allPassed = true;
|
bool allPassed = true;
|
||||||
std::vector<boolFn> functions { testGetPermutations, testFindNumOccurrence, testSplit, testIsPalindrome};
|
std::vector<boolFn> functions { testGetPermutations, testFindNumOccurrence, testSplit, testIsPalindrome, testIsPandigital};
|
||||||
std::vector<std::string> names { "getPermutations", "findNumOccurrence", "split", "isPalindrome"};
|
std::vector<std::string> names { "getPermutations", "findNumOccurrence", "split", "isPalindrome", "isPandigital"};
|
||||||
|
|
||||||
//Start doing tests and print out the results of each
|
//Start doing tests and print out the results of each
|
||||||
for(size_t cnt = 0;cnt < functions.size();++cnt){
|
for(size_t cnt = 0;cnt < functions.size();++cnt){
|
||||||
@@ -161,3 +162,32 @@ bool testIsPalindrome(){
|
|||||||
//If it hasn't failed a test then return true for passing all the tests
|
//If it hasn't failed a test then return true for passing all the tests
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool testIsPandigital(){
|
||||||
|
//Test 1
|
||||||
|
std::string num = "123456789";
|
||||||
|
bool correctAnswer = true;
|
||||||
|
bool answer = mee::isPandigital(num);
|
||||||
|
if(correctAnswer != answer){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Test 2
|
||||||
|
num = "123";
|
||||||
|
correctAnswer = true;
|
||||||
|
answer = mee::isPandigital(num, '1', '3');
|
||||||
|
if(correctAnswer != answer){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Test 3
|
||||||
|
num = "123";
|
||||||
|
correctAnswer = false;
|
||||||
|
answer = mee::isPandigital(num);
|
||||||
|
if(correctAnswer != answer){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//If it hasn't failed a test then return true for passing all the tests
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user