@@ -58,6 +58,7 @@ class TestToken : public TestFixture {
5858 TEST_CASE (multiCompare5);
5959 TEST_CASE (getStrLength);
6060 TEST_CASE (getStrSize);
61+ TEST_CASE (getCharAt);
6162 TEST_CASE (strValue);
6263
6364 TEST_CASE (deleteLast);
@@ -294,6 +295,9 @@ class TestToken : public TestFixture {
294295 void getStrSize () const {
295296 Token tok;
296297
298+ tok.str (" \"\" " );
299+ ASSERT_EQUALS (sizeof (" " ), Token::getStrSize (&tok));
300+
297301 tok.str (" \" abc\" " );
298302 ASSERT_EQUALS (sizeof (" abc" ), Token::getStrSize (&tok));
299303
@@ -304,6 +308,28 @@ class TestToken : public TestFixture {
304308 ASSERT_EQUALS (sizeof (" \\ " ), Token::getStrSize (&tok));
305309 }
306310
311+ void getCharAt () const {
312+ Token tok;
313+
314+ tok.str (" \" asdf\" " );
315+ ASSERT_EQUALS (" a" , Token::getCharAt (&tok, 0 ));
316+ ASSERT_EQUALS (" s" , Token::getCharAt (&tok, 1 ));
317+
318+ tok.str (" \" a\\ ts\" " );
319+ ASSERT_EQUALS (" \\ t" , Token::getCharAt (&tok, 1 ));
320+
321+ tok.str (" \"\" " );
322+ ASSERT_EQUALS (" \\ 0" , Token::getCharAt (&tok, 0 ));
323+
324+ tok.str (" L\" a\\ ts\" " );
325+ ASSERT_EQUALS (" a" , Token::getCharAt (&tok, 0 ));
326+ ASSERT_EQUALS (" \\ t" , Token::getCharAt (&tok, 1 ));
327+
328+ tok.str (" u\" a\\ ts\" " );
329+ ASSERT_EQUALS (" \\ t" , Token::getCharAt (&tok, 1 ));
330+ ASSERT_EQUALS (" s" , Token::getCharAt (&tok, 2 ));
331+ }
332+
307333 void strValue () const {
308334 Token tok;
309335
@@ -328,6 +354,11 @@ class TestToken : public TestFixture {
328354 tok.str (" \" a\\ 0\" " );
329355 ASSERT_EQUALS (" a" , tok.strValue ());
330356
357+ tok.str (" L\" a\\ t\" " );
358+ ASSERT_EQUALS (" a\t " , tok.strValue ());
359+
360+ tok.str (" U\" a\\ 0\" " );
361+ ASSERT_EQUALS (" a" , tok.strValue ());
331362 }
332363
333364
@@ -954,6 +985,9 @@ class TestToken : public TestFixture {
954985
955986 givenACodeSampleToTokenize data3 (" return (t){1,2};" );
956987 ASSERT_EQUALS (" return(t){1,2}" , data3.tokens ()->expressionString ());
988+
989+ givenACodeSampleToTokenize data4 (" return L\" a\" ;" );
990+ ASSERT_EQUALS (" returnL\" a\" " , data4.tokens ()->expressionString ());
957991 }
958992};
959993
0 commit comments