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

Side by Side Diff: device/bluetooth/uribeacon/uri_encoder_unittest.cc

Issue 2015703002: bluetooth: Remove UriBeacon code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@my-origin
Patch Set: Delete target Created 4 years, 6 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
« no previous file with comments | « device/bluetooth/uribeacon/uri_encoder.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 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 #include <stdint.h>
6
7 #include "device/bluetooth/uribeacon/uri_encoder.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9
10 namespace device {
11
12 TEST(UriEncoderTest, Url1) {
13 const std::string kUri = "http://123.com";
14 const char encoded_uri[] = {2, '1', '2', '3', 7};
15 const std::vector<uint8_t> kEncodedUri(encoded_uri,
16 encoded_uri + sizeof(encoded_uri));
17
18 std::vector<uint8_t> encoded;
19 std::string decoded;
20
21 EncodeUriBeaconUri(kUri, encoded);
22 EXPECT_EQ(kEncodedUri, encoded);
23
24 DecodeUriBeaconUri(encoded, decoded);
25 EXPECT_EQ(kUri, decoded);
26 }
27
28 TEST(UriEncoderTest, Url2) {
29 const std::string kUri = "http://www.abcdefghijklmnop.org";
30 const char encoded_uri[] = {
31 0, 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
32 'o', 'p', 8};
33 const std::vector<uint8_t> kEncodedUri(encoded_uri,
34 encoded_uri + sizeof(encoded_uri));
35
36 std::vector<uint8_t> encoded;
37 std::string decoded;
38
39 EncodeUriBeaconUri(kUri, encoded);
40 EXPECT_EQ(kEncodedUri, encoded);
41
42 DecodeUriBeaconUri(encoded, decoded);
43 EXPECT_EQ(kUri, decoded);
44 }
45
46 TEST(UriEncoderTest, Url3) {
47 const std::string kUri = "https://123.com/123";
48 const char encoded_uri[] = {3, '1', '2', '3', 0, '1', '2', '3'};
49 const std::vector<uint8_t> kEncodedUri(encoded_uri,
50 encoded_uri + sizeof(encoded_uri));
51
52 std::vector<uint8_t> encoded;
53 std::string decoded;
54
55 EncodeUriBeaconUri(kUri, encoded);
56 EXPECT_EQ(kEncodedUri, encoded);
57
58 DecodeUriBeaconUri(encoded, decoded);
59 EXPECT_EQ(kUri, decoded);
60 }
61
62 TEST(UriEncoderTest, Url4) {
63 const std::string kUri = "http://www.uribeacon.org";
64 const char encoded_uri[] = {
65 0, 'u', 'r', 'i', 'b', 'e', 'a', 'c', 'o', 'n', 8};
66 const std::vector<uint8_t> kEncodedUri(encoded_uri,
67 encoded_uri + sizeof(encoded_uri));
68
69 std::vector<uint8_t> encoded;
70 std::string decoded;
71
72 EncodeUriBeaconUri(kUri, encoded);
73 EXPECT_EQ(kEncodedUri, encoded);
74
75 DecodeUriBeaconUri(encoded, decoded);
76 EXPECT_EQ(kUri, decoded);
77 }
78
79 TEST(UriEncoderTest, Url5) {
80 const std::string kUri = "http://web.mit.edu/";
81 const char encoded_uri[] = {2, 'w', 'e', 'b', '.', 'm', 'i', 't', 2};
82 const std::vector<uint8_t> kEncodedUri(encoded_uri,
83 encoded_uri + sizeof(encoded_uri));
84
85 std::vector<uint8_t> encoded;
86 std::string decoded;
87
88 EncodeUriBeaconUri(kUri, encoded);
89 EXPECT_EQ(kEncodedUri, encoded);
90
91 DecodeUriBeaconUri(encoded, decoded);
92 EXPECT_EQ(kUri, decoded);
93 }
94
95 } // namespace device
OLDNEW
« no previous file with comments | « device/bluetooth/uribeacon/uri_encoder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698