summaryrefslogtreecommitdiffstats
path: root/app/l10n_util_mac_unittest.mm
diff options
context:
space:
mode:
authorthomasvl@chromium.org <thomasvl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-07 19:26:36 +0000
committerthomasvl@chromium.org <thomasvl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-07 19:26:36 +0000
commitaff5eec98954766821f46a7e9fab07b7007f0319 (patch)
treef1f93210978317adc3ca097e49486cf79035c389 /app/l10n_util_mac_unittest.mm
parent086eaec4d8ed6b6207925253f17fdabef82a0ed7 (diff)
downloadchromium_src-aff5eec98954766821f46a7e9fab07b7007f0319.zip
chromium_src-aff5eec98954766821f46a7e9fab07b7007f0319.tar.gz
chromium_src-aff5eec98954766821f46a7e9fab07b7007f0319.tar.bz2
Move some Mac l10n helpers out into app/l10n so they are closer to the generic ones.
Complete the apis points so the ones folks might need are all there already. Switch the code using the old calls over to the new helpers. TEST=no l10n stuff broke BUG=none Review URL: http://codereview.chromium.org/165132 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22753 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'app/l10n_util_mac_unittest.mm')
-rw-r--r--app/l10n_util_mac_unittest.mm46
1 files changed, 46 insertions, 0 deletions
diff --git a/app/l10n_util_mac_unittest.mm b/app/l10n_util_mac_unittest.mm
new file mode 100644
index 0000000..e6c4485
--- /dev/null
+++ b/app/l10n_util_mac_unittest.mm
@@ -0,0 +1,46 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import <Foundation/Foundation.h>
+
+#include "base/sys_string_conversions.h"
+#include "app/l10n_util_mac.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "testing/platform_test.h"
+
+typedef PlatformTest L10nUtilMacTest;
+
+TEST_F(L10nUtilMacTest, FixUpWindowsStyleLabel) {
+ struct TestData {
+ NSString* input;
+ NSString* output;
+ };
+
+ TestData data[] = {
+ { @"", @"" },
+ { @"nothing", @"nothing" },
+ { @"foo &bar", @"foo bar" },
+ { @"foo &&bar", @"foo &bar" },
+ { @"foo &&&bar", @"foo &bar" },
+ { @"&foo &&bar", @"foo &bar" },
+ { @"&foo &bar", @"foo bar" },
+ { @"foo bar.", @"foo bar." },
+ { @"foo bar..", @"foo bar.." },
+ { @"foo bar...", @"foo bar\u2026" },
+ { @"foo.bar", @"foo.bar" },
+ { @"foo..bar", @"foo..bar" },
+ { @"foo...bar", @"foo\u2026bar" },
+ { @"foo...bar...", @"foo\u2026bar\u2026" },
+ };
+ for (size_t idx = 0; idx < ARRAYSIZE_UNSAFE(data); ++idx) {
+ string16 input16(base::SysNSStringToUTF16(data[idx].input));
+
+ NSString* result = l10n_util::FixUpWindowsStyleLabel(input16);
+ EXPECT_TRUE(result != nil) << "Fixup Failed, idx = " << idx;
+
+ EXPECT_TRUE([data[idx].output isEqualTo:result])
+ << "For idx " << idx << ", expected '" << [data[idx].output UTF8String]
+ << "', got '" << [result UTF8String] << "'";
+ }
+}