diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/common/extract.hpp | 2 | ||||
-rw-r--r-- | src/common/extract_test.cpp | 13 |
2 files changed, 15 insertions, 0 deletions
diff --git a/src/common/extract.hpp b/src/common/extract.hpp index 3c24693..c7bdbcb 100644 --- a/src/common/extract.hpp +++ b/src/common/extract.hpp @@ -198,6 +198,8 @@ bool extract(XString str, struct item *it); inline bool extract(XString str, MapName *m) { + XString::iterator it = std::find(str.begin(), str.end(), '.'); + str = str.xislice_h(it); VString<15> tmp; bool rv = extract(str, &tmp); *m = tmp; diff --git a/src/common/extract_test.cpp b/src/common/extract_test.cpp index d8e9ebe..78478c2 100644 --- a/src/common/extract_test.cpp +++ b/src/common/extract_test.cpp @@ -317,3 +317,16 @@ TEST(extract, record_str) EXPECT_EQ("", z); x = y = z = ""; } + +TEST(extract, mapname) +{ + MapName map; + EXPECT_TRUE(extract("abc", &map)); + EXPECT_EQ(map, "abc"); + EXPECT_TRUE(extract("abc.gat", &map)); + EXPECT_EQ(map, "abc"); + EXPECT_TRUE(extract("abcdefghijklmno", &map)); + EXPECT_EQ(map, "abcdefghijklmno"); + EXPECT_TRUE(extract("abcdefghijklmno.gat", &map)); + EXPECT_EQ(map, "abcdefghijklmno"); +} |