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

Side by Side Diff: ios/web/navigation/nscoder_util_unittest.mm

Issue 988383002: Upstream various ios/web utilities and helpers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@web-public-upstreaming
Patch Set: Created 5 years, 9 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #import <Foundation/Foundation.h>
6
7 #include "base/basictypes.h"
8 #include "base/mac/scoped_nsobject.h"
9 #include "ios/web/navigation/nscoder_util.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "testing/platform_test.h"
12
13 namespace web {
14 namespace {
15
16 typedef PlatformTest NSCoderStdStringTest;
17
18 const char* testStrings[] = {
19 "Arf",
20 "",
21 "This is working™",
22 "古池や蛙飛込む水の音\nふるいけやかわずとびこむみずのおと",
23 "ἀγεωμέτρητος μηδεὶς εἰσίτω",
24 "Bang!\t\n"
25 };
26
27 TEST_F(NSCoderStdStringTest, encodeDecode) {
28 for (size_t i = 0; i < arraysize(testStrings); ++i) {
29 NSMutableData* data = [NSMutableData data];
30
31 base::scoped_nsobject<NSKeyedArchiver> archiver(
32 [[NSKeyedArchiver alloc] initForWritingWithMutableData:data]);
33 nscoder_util::EncodeString(archiver, @"test", testStrings[i]);
34 [archiver finishEncoding];
35
36 base::scoped_nsobject<NSKeyedUnarchiver> unarchiver(
37 [[NSKeyedUnarchiver alloc] initForReadingWithData:data]);
38 const std::string decoded = nscoder_util::DecodeString(unarchiver, @"test");
39
40 EXPECT_EQ(decoded, testStrings[i]);
41 }
42 }
43
44 TEST_F(NSCoderStdStringTest, decodeEmpty) {
45 NSMutableData* data = [NSMutableData data];
46
47 base::scoped_nsobject<NSKeyedArchiver> archiver(
48 [[NSKeyedArchiver alloc] initForWritingWithMutableData:data]);
49 [archiver finishEncoding];
50
51 base::scoped_nsobject<NSKeyedUnarchiver> unarchiver(
52 [[NSKeyedUnarchiver alloc] initForReadingWithData:data]);
53 const std::string decoded = nscoder_util::DecodeString(unarchiver, @"test");
54
55 EXPECT_EQ(decoded, "");
56 }
57
58 } // namespace
59 } // namespace web
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698