diff --git a/headers/mee/stringAlgorithms.hpp b/headers/mee/stringAlgorithms.hpp index e5a3bc0..fd2d6d3 100644 --- a/headers/mee/stringAlgorithms.hpp +++ b/headers/mee/stringAlgorithms.hpp @@ -1,7 +1,7 @@ //myClasses/headers/mee/stringAlgorithms.hpp //Matthew Ellison // Created: 07-02-21 -//Modified: 07-02-21 +//Modified: 10-11-21 //This file contains declarations of functions I have created to manipulate strings /* Copyright (C) 2021 Matthew Ellison @@ -112,6 +112,11 @@ bool isPalindrome(std::string str){ //This function returns true if the string passed to it is a pandigital bool isPandigital(std::string str, char bottom, char top){ + //Return false if top < bottom + if(top < bottom){ + return false; + } + //Return false if the wrong number of characters are in the string if(str.size() != (top - bottom + 1)){ return false; diff --git a/test/mee/testStringAlgorithms.cpp b/test/mee/testStringAlgorithms.cpp index 08ed8c1..aa2e10f 100644 --- a/test/mee/testStringAlgorithms.cpp +++ b/test/mee/testStringAlgorithms.cpp @@ -1,7 +1,7 @@ //myClasses/test/mee/testStringAlgorithms.cpp //Matthew Ellison // Created: 07-02-21 -//Modified: 07-02-21 +//Modified: 10-11-21 //This file contains tests for the functions in my stringAlgorithms library /* Copyright (C) 2021 Matthew Ellison @@ -188,6 +188,14 @@ bool testIsPandigital(){ return false; } + //Test 4 + num = "123"; + correctAnswer = false; + answer = mee::isPandigital(num, '3', '1'); + if(correctAnswer != answer){ + return false; + } + //If it hasn't failed a test then return true for passing all the tests return true; }