From 58b0dcbaabb36df43b4bfa4c74a963d8b24a54fe Mon Sep 17 00:00:00 2001 From: Andreas Stöckel Date: Fri, 12 Dec 2014 02:15:45 +0100 Subject: fixed bug in Utils::isIdentifier and added regression test --- src/core/common/Utils.cpp | 2 +- test/core/common/UtilsTest.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/common/Utils.cpp b/src/core/common/Utils.cpp index c460ed4..5eaafe9 100644 --- a/src/core/common/Utils.cpp +++ b/src/core/common/Utils.cpp @@ -48,7 +48,7 @@ bool Utils::isIdentifier(const std::string &name) if (first && !(isAlphabetic(c) || c == '_')) { return false; } - if (first && !(isAlphanumeric(c) || c == '_' || c == '-')) { + if (!first && !(isAlphanumeric(c) || c == '_' || c == '-')) { return false; } first = false; diff --git a/test/core/common/UtilsTest.cpp b/test/core/common/UtilsTest.cpp index 2858038..66458b2 100644 --- a/test/core/common/UtilsTest.cpp +++ b/test/core/common/UtilsTest.cpp @@ -29,6 +29,7 @@ TEST(Utils, isIdentifier) ASSERT_TRUE(Utils::isIdentifier("_t0-_EST")); ASSERT_FALSE(Utils::isIdentifier("-t0-_EST")); ASSERT_FALSE(Utils::isIdentifier("0t-_EST")); + ASSERT_FALSE(Utils::isIdentifier("invalid key")); } TEST(Utils, trim) -- cgit v1.2.3