StringTokenizerTest.cpp File Reference

#include <gtest/gtest.h>
#include <utils/common/StringTokenizer.h>
#include <utils/common/UtilExceptions.h>

Go to the source code of this file.

Functions

 TEST (StringTokenizer, test_method_getVector)
 TEST (StringTokenizer, test_method_get_with_empty_data)
 TEST (StringTokenizer, test_method_get)
 TEST (StringTokenizer, test_method_front)
 TEST (StringTokenizer, test_method_size)
 TEST (StringTokenizer, test_method_reinit)
 TEST (StringTokenizer, test_split_any_char)
 TEST (StringTokenizer, test_split_with_x)
 TEST (StringTokenizer, test_split_with_newline)
 TEST (StringTokenizer, test_split_with_whitechar)


Function Documentation

TEST ( StringTokenizer  ,
test_method_getVector   
)

Definition at line 89 of file StringTokenizerTest.cpp.

References StringTokenizer::getVector().

00089                                              {
00090     StringTokenizer *strTok = new StringTokenizer("Hello World");
00091     vector<string> strVek = strTok->getVector();
00092     EXPECT_EQ("World",strVek.back());
00093     EXPECT_EQ("Hello",strVek.front());
00094 }

TEST ( StringTokenizer  ,
test_method_get_with_empty_data   
)

Definition at line 83 of file StringTokenizerTest.cpp.

References StringTokenizer::get().

00083                                                        {
00084     StringTokenizer *strTok = new StringTokenizer();
00085     ASSERT_THROW(strTok->get(0),OutOfBoundsException) << "Expect an OutOfBoundsException exception.";
00086 }

TEST ( StringTokenizer  ,
test_method_get   
)

Definition at line 75 of file StringTokenizerTest.cpp.

References StringTokenizer::get().

00075                                        {
00076     StringTokenizer *strTok = new StringTokenizer("Hello World");
00077     EXPECT_EQ("Hello",strTok->get(0)) << "The first token is not right.";
00078     EXPECT_EQ("World",strTok->get(1)) << "The second token is not right.";
00079     ASSERT_THROW(strTok->get(2),OutOfBoundsException) << "Expect an OutOfBoundsException exception.";
00080 }

TEST ( StringTokenizer  ,
test_method_front   
)

Definition at line 67 of file StringTokenizerTest.cpp.

References StringTokenizer::front(), and StringTokenizer::next().

00067                                          {
00068     StringTokenizer *strTok = new StringTokenizer("Hello World");
00069     EXPECT_EQ("Hello",strTok->front()) << "The first token is not right.";
00070     strTok->next();
00071     EXPECT_EQ("Hello",strTok->front()) << "The first token is not right.";
00072 }

TEST ( StringTokenizer  ,
test_method_size   
)

Definition at line 59 of file StringTokenizerTest.cpp.

References StringTokenizer::size().

00059                                         {
00060     StringTokenizer *strTok = new StringTokenizer("Hello little World");
00061     EXPECT_EQ(3,strTok->size()) << "The number of the token is not right.";
00062     StringTokenizer *strTok2 = new StringTokenizer("");
00063     EXPECT_EQ(0,strTok2->size()) << "The number of the token is not right.";
00064 }

TEST ( StringTokenizer  ,
test_method_reinit   
)

Definition at line 50 of file StringTokenizerTest.cpp.

References StringTokenizer::hasNext(), StringTokenizer::next(), and StringTokenizer::reinit().

00050                                           {
00051     StringTokenizer *strTok = new StringTokenizer("Hello");
00052     strTok->next();
00053     EXPECT_FALSE(strTok->hasNext()) << "No tokens should be available.";
00054     strTok->reinit();
00055     EXPECT_TRUE(strTok->hasNext()) << "There must be more tokens available.";
00056 }

TEST ( StringTokenizer  ,
test_split_any_char   
)

Definition at line 40 of file StringTokenizerTest.cpp.

References StringTokenizer::hasNext(), and StringTokenizer::next().

00040                                            {
00041     StringTokenizer *strTok = new StringTokenizer("HelloxWyorld", "xy", true);
00042     EXPECT_TRUE(strTok->hasNext()) << "There must be more tokens available.";
00043     EXPECT_EQ("Hello",strTok->next());
00044     EXPECT_EQ("W",strTok->next());
00045     EXPECT_EQ("orld",strTok->next());
00046     EXPECT_FALSE(strTok->hasNext()) << "No tokens should be available.";
00047 }

TEST ( StringTokenizer  ,
test_split_with_x   
)

Definition at line 30 of file StringTokenizerTest.cpp.

References StringTokenizer::hasNext(), and StringTokenizer::next().

00030                                          {
00031     StringTokenizer *strTok = new StringTokenizer("HelloxxWorld", "x");
00032     EXPECT_TRUE(strTok->hasNext()) << "There must be more tokens available.";
00033     EXPECT_EQ("Hello",strTok->next());
00034     EXPECT_EQ("",strTok->next());
00035     EXPECT_EQ("World",strTok->next());
00036     EXPECT_FALSE(strTok->hasNext()) << "No tokens should be available.";
00037 }

TEST ( StringTokenizer  ,
test_split_with_newline   
)

Definition at line 21 of file StringTokenizerTest.cpp.

References StringTokenizer::hasNext(), StringTokenizer::NEWLINE, and StringTokenizer::next().

00021                                                {
00022     StringTokenizer *strTok = new StringTokenizer("Hello\nWorld", StringTokenizer::NEWLINE);
00023     EXPECT_TRUE(strTok->hasNext()) << "There must be more tokens available.";
00024     EXPECT_EQ("Hello",strTok->next());
00025     EXPECT_EQ("World",strTok->next());
00026     EXPECT_FALSE(strTok->hasNext()) << "No tokens should be available.";
00027 }

TEST ( StringTokenizer  ,
test_split_with_whitechar   
)

Definition at line 12 of file StringTokenizerTest.cpp.

References StringTokenizer::hasNext(), StringTokenizer::next(), and StringTokenizer::WHITECHARS.

00012                                                  {
00013     StringTokenizer *strTok = new StringTokenizer("Hello  World", StringTokenizer::WHITECHARS);
00014     EXPECT_TRUE(strTok->hasNext()) << "There must be more tokens available.";
00015     EXPECT_EQ("Hello",strTok->next());
00016     EXPECT_EQ("World",strTok->next());
00017     EXPECT_FALSE(strTok->hasNext()) << "No tokens should be available.";
00018 }


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