From 1ccb57e5953d12f49dd01dfce3faea9d18dd5d66 Mon Sep 17 00:00:00 2001 From: Thomas Jarosch Date: Sun, 23 Oct 2011 21:21:42 +0200 Subject: [PATCH] Document and test Token::concatStr() --- lib/token.h | 4 ++++ test/testtoken.cpp | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/lib/token.h b/lib/token.h index 02c05a3b3..6927d7dec 100644 --- a/lib/token.h +++ b/lib/token.h @@ -48,6 +48,10 @@ public: void str(const std::string &s); + /** + * Concatenate two strings. "hello" "world" -> "hello world" + * Note: Automatically cuts of the last/first character. + */ void concatStr(std::string const& b); const std::string &str() const { diff --git a/test/testtoken.cpp b/test/testtoken.cpp index 991ab129c..7044538e5 100644 --- a/test/testtoken.cpp +++ b/test/testtoken.cpp @@ -48,6 +48,7 @@ private: TEST_CASE(matchOr); TEST_CASE(updateProperties) + TEST_CASE(updatePropertiesConcatStr) TEST_CASE(isNameGuarantees1) TEST_CASE(isNameGuarantees2) TEST_CASE(isNameGuarantees3) @@ -274,6 +275,18 @@ private: ASSERT_EQUALS(true, tok.isNumber()); } + void updatePropertiesConcatStr() { + Token tok(NULL); + tok.str("true"); + + ASSERT_EQUALS(true, tok.isBoolean()); + + tok.concatStr("123"); + + ASSERT_EQUALS(false, tok.isBoolean()); + ASSERT_EQUALS("tru23", tok.str()); + } + void isNameGuarantees1() { Token tok(NULL); tok.str("Name");