From 66ac08ab9a3e323e5257fffebe13aa1ee83f147e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Remko=20Tron=C3=A7on?= Date: Sat, 12 Mar 2011 19:47:06 +0100 Subject: Allow empty hashes in cache. diff --git a/Swiften/Avatars/AvatarFileStorage.cpp b/Swiften/Avatars/AvatarFileStorage.cpp index 3ff78e4..62dfdf6 100644 --- a/Swiften/Avatars/AvatarFileStorage.cpp +++ b/Swiften/Avatars/AvatarFileStorage.cpp @@ -26,7 +26,7 @@ AvatarFileStorage::AvatarFileStorage(const boost::filesystem::path& avatarsDir, getline(file, line); std::pair r = String::getSplittedAtFirst(line, ' '); JID jid(r.second); - if (jid.isValid() && !r.first.empty()) { + if (jid.isValid()) { jidAvatars.insert(std::make_pair(jid, r.first)); } else { diff --git a/Swiften/Base/UnitTest/StringTest.cpp b/Swiften/Base/UnitTest/StringTest.cpp index 884bbee..b29f331 100644 --- a/Swiften/Base/UnitTest/StringTest.cpp +++ b/Swiften/Base/UnitTest/StringTest.cpp @@ -16,6 +16,7 @@ class StringTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(StringTest); CPPUNIT_TEST(testGetUnicodeCodePoints); CPPUNIT_TEST(testGetSplittedAtFirst); + CPPUNIT_TEST(testGetSplittedAtFirst_CharacterAtBegin); CPPUNIT_TEST(testGetSplittedAtFirst_CharacterAtEnd); CPPUNIT_TEST(testGetSplittedAtFirst_NoSuchCharacter); CPPUNIT_TEST(testReplaceAll); @@ -44,6 +45,14 @@ class StringTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(std::string("cd@ef"), result.second); } + void testGetSplittedAtFirst_CharacterAtBegin() { + std::string testling(" ab"); + + std::pair result = String::getSplittedAtFirst(testling, ' '); + CPPUNIT_ASSERT(result.first.empty()); + CPPUNIT_ASSERT_EQUAL(std::string("ab"), result.second); + } + void testGetSplittedAtFirst_CharacterAtEnd() { std::string testling("ab@"); diff --git a/Swiften/VCards/VCardFileStorage.cpp b/Swiften/VCards/VCardFileStorage.cpp index 444ce3f..db189ff 100644 --- a/Swiften/VCards/VCardFileStorage.cpp +++ b/Swiften/VCards/VCardFileStorage.cpp @@ -32,7 +32,7 @@ VCardFileStorage::VCardFileStorage(boost::filesystem::path dir) : vcardsPath(dir getline(file, line); std::pair r = String::getSplittedAtFirst(line, ' '); JID jid(r.second); - if (jid.isValid() && !r.first.empty()) { + if (jid.isValid()) { photoHashes.insert(std::make_pair(jid, r.first)); } else { -- cgit v0.10.2-6-g49f6