Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5090)

Unified Diff: chrome/common/l10n_util_unittest.cc

Issue 20484: Adds a method to sort the elements of a vector by invoking a method on... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/common/l10n_util.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/l10n_util_unittest.cc
===================================================================
--- chrome/common/l10n_util_unittest.cc (revision 10251)
+++ chrome/common/l10n_util_unittest.cc (working copy)
@@ -10,6 +10,7 @@
#include "base/string_util.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/l10n_util.h"
+#include "chrome/common/stl_util-inl.h"
#if !defined(OS_MACOSX)
#include "chrome/test/data/resource.h"
#endif
@@ -19,9 +20,22 @@
namespace {
-class L10nUtilTest: public PlatformTest {
+class StringWrapper {
+ public:
+ explicit StringWrapper(const std::wstring& string) : string_(string) {}
+ const std::wstring& string() const { return string_; }
+
+ private:
+ std::wstring string_;
+
+ DISALLOW_COPY_AND_ASSIGN(StringWrapper);
};
+} // namespace
+
+class L10nUtilTest : public PlatformTest {
+};
+
#if defined(OS_WIN)
TEST_F(L10nUtilTest, GetString) {
std::wstring s = l10n_util::GetString(IDS_SIMPLE);
@@ -160,6 +174,20 @@
Locale::setDefault(locale, error_code);
}
+TEST_F(L10nUtilTest, SortStringsUsingFunction) {
+ std::vector<StringWrapper*> strings;
+ strings.push_back(new StringWrapper(L"C"));
+ strings.push_back(new StringWrapper(L"d"));
+ strings.push_back(new StringWrapper(L"b"));
+ strings.push_back(new StringWrapper(L"a"));
+ l10n_util::SortStringsUsingMethod(L"en-US", &strings, &StringWrapper::string);
+ ASSERT_TRUE(L"a" == strings[0]->string());
+ ASSERT_TRUE(L"b" == strings[1]->string());
+ ASSERT_TRUE(L"C" == strings[2]->string());
+ ASSERT_TRUE(L"d" == strings[3]->string());
+ STLDeleteElements(&strings);
+}
+
TEST_F(L10nUtilTest, GetFirstStrongCharacterDirection) {
// Test pure LTR string.
std::wstring string(L"foo bar");
@@ -334,5 +362,3 @@
EXPECT_EQ(wrapped_path, test_data[i].wrapped_path);
}
}
-}
-
« no previous file with comments | « chrome/common/l10n_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698