#include #include "converters.h" using namespace std; void TestStringToInt(string s, int value); void TestIntToString(string s, int value); int main() { TestIntToString("345", 345); TestIntToString("0", 0); TestIntToString("12345", 12345); TestIntToString("fred4", 4); /* TestStringToInt("345", 345); TestStringToInt("0", 0); TestStringToInt("12345", 12345); TestStringToInt("fred4", 4); */ for(int i =0; i < 10; ++i) { string newString{IntegerToString(i)}; if (StringToInteger(newString) != i) { cout << " error for " << i << endl; } } return 0; } void TestIntToString(string s, int value) { string newString {IntegerToString(value)}; if (newString != s) { cout << "Bad conversion of " << value << " got " << newString << " but wanted " << s << endl; } } void TestStringToInt(string s, int value){ int lastValue{0}; lastValue = StringToInteger(s); if(lastValue != value) { cout << lastValue << " is not " << value << " when converting " << s << endl; } /*else { cout << s << " = " << lastvalue << endl; } */ }