StringUtilsTest.cpp File Reference

#include <gtest/gtest.h>
#include <utils/common/StringUtils.h>

Go to the source code of this file.

Functions

 TEST (StringUtils, test_method_escapeXML)
 TEST (StringUtils, test_method_toTimeString)
 TEST (StringUtils, test_method_upper)
 TEST (StringUtils, test_method_replace_empty_third_argument)
 TEST (StringUtils, test_method_replace_empty_string)
 TEST (StringUtils, test_method_replace)
 TEST (StringUtils, test_method_convertUmlaute)
 TEST (StringUtils, test_method_to_lower_case)
 TEST (StringUtils, test_method_prune)


Function Documentation

TEST ( StringUtils  ,
test_method_escapeXML   
)

Definition at line 86 of file StringUtilsTest.cpp.

References StringUtils::escapeXML().

00086                                          {  
00087     string str;
00088     EXPECT_EQ("", StringUtils::escapeXML(str));
00089     EXPECT_EQ("test", StringUtils::escapeXML("test"))<< "nothing to be replaced.";
00090     EXPECT_EQ("test&apos;s", StringUtils::escapeXML("test's"))<< "' must be replaced.";
00091     EXPECT_EQ("1&lt;2", StringUtils::escapeXML("1<2"))<< "< must be replaced.";
00092     EXPECT_EQ("2&gt;1", StringUtils::escapeXML("2>1"))<< "> must be replaced.";
00093     EXPECT_EQ("M&amp;M", StringUtils::escapeXML("M&M"))<< "& must be replaced.";
00094     EXPECT_EQ("&quot;test&quot;", StringUtils::escapeXML("\"test\""))<< "\" must be replaced.";
00095 }

TEST ( StringUtils  ,
test_method_toTimeString   
)

Definition at line 76 of file StringUtilsTest.cpp.

References StringUtils::toTimeString().

00076                                             {   
00077     //EXPECT_EQ("00:00:-1", StringUtils::toTimeString(-1)) << "Something better should happen.";
00078     EXPECT_EQ("00:00:00", StringUtils::toTimeString(0));
00079     EXPECT_EQ("01:00:00", StringUtils::toTimeString(3600));
00080     EXPECT_EQ("00:00:01", StringUtils::toTimeString(1));
00081     EXPECT_EQ("49:40:00", StringUtils::toTimeString(178800));
00082     //EXPECT_EQ("49:40:00", StringUtils::toTimeString(1178800)) << "Something should happen and no error.";
00083 }

TEST ( StringUtils  ,
test_method_upper   
)

Definition at line 65 of file StringUtilsTest.cpp.

References StringUtils::upper().

00065                                      {
00066     string toUpper = "halloWelt123-?";
00067     StringUtils::upper(toUpper);
00068     EXPECT_EQ("HALLOWELT123-?", toUpper) << "It should consist only of capital letters.";
00069     string str;
00070     StringUtils::upper(str);
00071     EXPECT_EQ("",str );
00072 }

TEST ( StringUtils  ,
test_method_replace_empty_third_argument   
)

Definition at line 59 of file StringUtilsTest.cpp.

References StringUtils::replace().

00059                                                              {
00060     EXPECT_EQ("hello", StringUtils::replace("hello","a",""));
00061 }

TEST ( StringUtils  ,
test_method_replace_empty_string   
)

Definition at line 54 of file StringUtilsTest.cpp.

References StringUtils::replace().

00054                                                     {       
00055     EXPECT_EQ("", StringUtils::replace("","l","st"));
00056 }

TEST ( StringUtils  ,
test_method_replace   
)

Definition at line 47 of file StringUtilsTest.cpp.

References StringUtils::replace().

00047                                        {    
00048     EXPECT_EQ("helt", StringUtils::replace("hello","lo","t"));
00049     EXPECT_EQ("heststo", StringUtils::replace("hello","l","st"));
00050     EXPECT_EQ("", StringUtils::replace("","l","st"));
00051 }

TEST ( StringUtils  ,
test_method_convertUmlaute   
)

Definition at line 32 of file StringUtilsTest.cpp.

References StringUtils::convertUmlaute().

00032                                               {
00033     EXPECT_EQ("ae", StringUtils::convertUmlaute("ä"));
00034     EXPECT_EQ("Ae", StringUtils::convertUmlaute("Ä"));
00035     EXPECT_EQ("oe", StringUtils::convertUmlaute("ö"));
00036     EXPECT_EQ("Oe", StringUtils::convertUmlaute("Ö"));
00037     EXPECT_EQ("ue", StringUtils::convertUmlaute("ü"));
00038     EXPECT_EQ("Ue", StringUtils::convertUmlaute("Ü"));
00039     EXPECT_EQ("ss", StringUtils::convertUmlaute("ß"));
00040     EXPECT_EQ("E", StringUtils::convertUmlaute("É"));
00041     EXPECT_EQ("e", StringUtils::convertUmlaute("é"));
00042     EXPECT_EQ("E", StringUtils::convertUmlaute("È"));
00043     EXPECT_EQ("e", StringUtils::convertUmlaute("è"));
00044 }

TEST ( StringUtils  ,
test_method_to_lower_case   
)

Definition at line 24 of file StringUtilsTest.cpp.

References StringUtils::to_lower_case().

00024                                              {
00025     EXPECT_EQ("hello", StringUtils::to_lower_case("HELLO"))<< "String should be converted into small letter.";
00026     EXPECT_EQ("world", StringUtils::to_lower_case("World"))<< "String should be converted into small letter.";
00027     string str;
00028     EXPECT_EQ("", StringUtils::to_lower_case(str));
00029 }

TEST ( StringUtils  ,
test_method_prune   
)

Definition at line 19 of file StringUtilsTest.cpp.

References StringUtils::prune().

00019                                      {
00020     EXPECT_EQ("result", StringUtils::prune("  result ")) << "Blanks at the beginning and at the end of a string must be removed.";
00021 }


Generated on Wed May 5 00:06:39 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6