If I call this function stringToUpper(str2) in the currencyConverter.cpp itself, its works and return upper case.
void currencyConverter::stringToUpper(string &s)
{
for(unsigned int l = 0; l < s.length(); l++)
{
s[l] = toupper(s[l]);
}
}
However I have a file named unitTest.cpp
, and it does this:
#include "unitTest.h"
#include "currencyConverter.h"
CPPUNIT_TEST_SUITE_REGISTRATION(unitTest);
unitTest::unitTest() {
}
unitTest::~unitTest() {
}
void unitTest::setUp() {
}
void unitTest::tearDown() {
}
void stringToUpper(string&);
void unitTest::testStringLowerToUpper()
{
string str = "ILOVECPLUSPLUS";
string str2 = "ilovecplusplus";
cout << "\nChecking if string 1 '" << str << "' equals string 2 '" << str2 << "'";
CPPUNIT_ASSERT_EQUAL(str,str2);
//this part i will use my stringToUpperFunction to test.
currencyConverter c;
c.stringToUpper(str2);
cout << str2 << endl;
}
When I try to print str2
, it remains as ilovecplusplus
instead of being capitalized.
Whats wrong with my code or call?