OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
armansito
2015/02/24 23:55:08
nit: s/(c) 2012/2015/
dvh
2015/02/25 23:52:13
Done.
| |
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 "device/bluetooth/uribeacon/uri_encoder.h" | |
6 #include "testing/gtest/include/gtest/gtest.h" | |
7 | |
8 namespace device { | |
9 | |
10 TEST(UriEncoderTest, Url1) { | |
11 const std::string kUri = "http://123.com"; | |
12 const char encodedUri[] = {2, '1', '2', '3', 7}; | |
13 const std::string kEncodedUri(encodedUri, sizeof(encodedUri)); | |
14 | |
15 std::string encoded; | |
16 std::string decoded; | |
17 | |
18 EncodeUriBeaconUri(kUri, &encoded); | |
19 EXPECT_EQ(kEncodedUri, encoded); | |
20 | |
21 DecodeUriBeaconUri(encoded, &decoded); | |
22 EXPECT_EQ(kUri, decoded); | |
23 } | |
24 | |
25 TEST(UriEncoderTest, Url2) { | |
26 const std::string kUri = "http://www.abcdefghijklmnop.org"; | |
27 const char encodedUri[] = {0, | |
armansito
2015/02/26 00:39:16
nit: This should be |encoded_uri|, according Googl
dvh
2015/03/03 20:26:04
Done.
| |
28 'a', | |
29 'b', | |
30 'c', | |
31 'd', | |
32 'e', | |
33 'f', | |
34 'g', | |
35 'h', | |
36 'i', | |
37 'j', | |
38 'k', | |
39 'l', | |
40 'm', | |
41 'n', | |
42 'o', | |
43 'p', | |
44 8}; | |
armansito
2015/02/24 23:55:08
Probably run 'git cl format' at least once :)
dvh
2015/02/25 23:52:13
It already went through clang-format with setting
armansito
2015/02/26 00:39:15
Oh well, this is one of those cases when git cl fo
dvh
2015/03/03 20:26:04
Done.
| |
45 const std::string kEncodedUri(encodedUri, sizeof(encodedUri)); | |
46 | |
47 std::string encoded; | |
48 std::string decoded; | |
49 | |
50 EncodeUriBeaconUri(kUri, &encoded); | |
51 EXPECT_EQ(kEncodedUri, encoded); | |
52 | |
53 DecodeUriBeaconUri(encoded, &decoded); | |
54 EXPECT_EQ(kUri, decoded); | |
55 } | |
56 | |
57 TEST(UriEncoderTest, Url3) { | |
58 const std::string kUri = "https://123.com/123"; | |
59 const char encodedUri[] = {3, '1', '2', '3', 0, '1', '2', '3'}; | |
armansito
2015/02/26 00:39:16
nit: |encoded_uri|
dvh
2015/03/03 20:26:04
Done.
| |
60 const std::string kEncodedUri(encodedUri, sizeof(encodedUri)); | |
61 | |
62 std::string encoded; | |
63 std::string decoded; | |
64 | |
65 EncodeUriBeaconUri(kUri, &encoded); | |
66 EXPECT_EQ(kEncodedUri, encoded); | |
67 | |
68 DecodeUriBeaconUri(encoded, &decoded); | |
69 EXPECT_EQ(kUri, decoded); | |
70 } | |
71 | |
72 TEST(UriEncoderTest, Url4) { | |
73 const std::string kUri = "http://www.uribeacon.org"; | |
74 const char encodedUri[] = {0, 'u', 'r', 'i', 'b', 'e', 'a', 'c', 'o', 'n', 8}; | |
armansito
2015/02/26 00:39:16
nit: |encoded_uri|
dvh
2015/03/03 20:26:04
Done.
| |
75 const std::string kEncodedUri(encodedUri, sizeof(encodedUri)); | |
76 | |
77 std::string encoded; | |
78 std::string decoded; | |
79 | |
80 EncodeUriBeaconUri(kUri, &encoded); | |
81 EXPECT_EQ(kEncodedUri, encoded); | |
82 | |
83 DecodeUriBeaconUri(encoded, &decoded); | |
84 EXPECT_EQ(kUri, decoded); | |
85 } | |
86 | |
87 TEST(UriEncoderTest, Url5) { | |
88 const std::string kUri = "http://web.mit.edu/"; | |
89 const char encodedUri[] = {2, 'w', 'e', 'b', '.', 'm', 'i', 't', 2}; | |
armansito
2015/02/26 00:39:15
nit: |encoded_uri|
dvh
2015/03/03 20:26:04
Done.
| |
90 const std::string kEncodedUri(encodedUri, sizeof(encodedUri)); | |
91 | |
92 std::string encoded; | |
93 std::string decoded; | |
94 | |
95 EncodeUriBeaconUri(kUri, &encoded); | |
96 EXPECT_EQ(kEncodedUri, encoded); | |
97 | |
98 DecodeUriBeaconUri(encoded, &decoded); | |
99 EXPECT_EQ(kUri, decoded); | |
100 } | |
101 | |
102 } // namespace device | |
OLD | NEW |