Handling of white-space in DataLog::Combine

The Combine method cannot handle white-space. Adding a comment to
the header file saying this, and modifying the unittests. Also,
adding a new unittest to test the method.

Review URL: http://webrtc-codereview.appspot.com/217001

git-svn-id: http://webrtc.googlecode.com/svn/trunk@760 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
henrik.lundin@webrtc.org
2011-10-18 05:45:08 +00:00
parent 929789b528
commit 5dedd0ee38
2 changed files with 10 additions and 3 deletions

View File

@ -283,9 +283,11 @@ void DataLog::ReturnLog() {
std::string DataLog::Combine(const std::string& table_name, int table_id) { std::string DataLog::Combine(const std::string& table_name, int table_id) {
std::stringstream ss; std::stringstream ss;
std::string combined_id; std::string combined_id = table_name;
ss << table_name << "_" << table_id; std::string number_suffix;
ss >> combined_id; ss << "_" << table_id;
ss >> number_suffix;
combined_id += number_suffix;
std::transform(combined_id.begin(), combined_id.end(), combined_id.begin(), std::transform(combined_id.begin(), combined_id.end(), combined_id.begin(),
::tolower); ::tolower);
return combined_id; return combined_id;

View File

@ -121,6 +121,11 @@ TEST(TestDataLog, CreateReturnTest) {
ASSERT_LT(DataLog::AddTable(DataLog::Combine("table failure", 1)), 0); ASSERT_LT(DataLog::AddTable(DataLog::Combine("table failure", 1)), 0);
} }
TEST(TestDataLog, VerifyCombineMethod) {
EXPECT_EQ(std::string("a proper table_1"),
DataLog::Combine("a proper table", 1));
}
TEST(TestDataLog, VerifySingleTable) { TEST(TestDataLog, VerifySingleTable) {
DataLog::CreateLog(); DataLog::CreateLog();
DataLog::AddTable(DataLog::Combine("table", 1)); DataLog::AddTable(DataLog::Combine("table", 1));