Index: device/bluetooth/uribeacon/uri_encoder_unittest.cc |
diff --git a/device/bluetooth/uribeacon/uri_encoder_unittest.cc b/device/bluetooth/uribeacon/uri_encoder_unittest.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..68fec342c92803c26707e2cf4dbaeab2097fa626 |
--- /dev/null |
+++ b/device/bluetooth/uribeacon/uri_encoder_unittest.cc |
@@ -0,0 +1,102 @@ |
+// 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.
|
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "device/bluetooth/uribeacon/uri_encoder.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
+ |
+namespace device { |
+ |
+TEST(UriEncoderTest, Url1) { |
+ const std::string kUri = "http://123.com"; |
+ const char encodedUri[] = {2, '1', '2', '3', 7}; |
+ const std::string kEncodedUri(encodedUri, sizeof(encodedUri)); |
+ |
+ std::string encoded; |
+ std::string decoded; |
+ |
+ EncodeUriBeaconUri(kUri, &encoded); |
+ EXPECT_EQ(kEncodedUri, encoded); |
+ |
+ DecodeUriBeaconUri(encoded, &decoded); |
+ EXPECT_EQ(kUri, decoded); |
+} |
+ |
+TEST(UriEncoderTest, Url2) { |
+ const std::string kUri = "http://www.abcdefghijklmnop.org"; |
+ 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.
|
+ 'a', |
+ 'b', |
+ 'c', |
+ 'd', |
+ 'e', |
+ 'f', |
+ 'g', |
+ 'h', |
+ 'i', |
+ 'j', |
+ 'k', |
+ 'l', |
+ 'm', |
+ 'n', |
+ 'o', |
+ 'p', |
+ 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.
|
+ const std::string kEncodedUri(encodedUri, sizeof(encodedUri)); |
+ |
+ std::string encoded; |
+ std::string decoded; |
+ |
+ EncodeUriBeaconUri(kUri, &encoded); |
+ EXPECT_EQ(kEncodedUri, encoded); |
+ |
+ DecodeUriBeaconUri(encoded, &decoded); |
+ EXPECT_EQ(kUri, decoded); |
+} |
+ |
+TEST(UriEncoderTest, Url3) { |
+ const std::string kUri = "https://123.com/123"; |
+ 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.
|
+ const std::string kEncodedUri(encodedUri, sizeof(encodedUri)); |
+ |
+ std::string encoded; |
+ std::string decoded; |
+ |
+ EncodeUriBeaconUri(kUri, &encoded); |
+ EXPECT_EQ(kEncodedUri, encoded); |
+ |
+ DecodeUriBeaconUri(encoded, &decoded); |
+ EXPECT_EQ(kUri, decoded); |
+} |
+ |
+TEST(UriEncoderTest, Url4) { |
+ const std::string kUri = "http://www.uribeacon.org"; |
+ 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.
|
+ const std::string kEncodedUri(encodedUri, sizeof(encodedUri)); |
+ |
+ std::string encoded; |
+ std::string decoded; |
+ |
+ EncodeUriBeaconUri(kUri, &encoded); |
+ EXPECT_EQ(kEncodedUri, encoded); |
+ |
+ DecodeUriBeaconUri(encoded, &decoded); |
+ EXPECT_EQ(kUri, decoded); |
+} |
+ |
+TEST(UriEncoderTest, Url5) { |
+ const std::string kUri = "http://web.mit.edu/"; |
+ 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.
|
+ const std::string kEncodedUri(encodedUri, sizeof(encodedUri)); |
+ |
+ std::string encoded; |
+ std::string decoded; |
+ |
+ EncodeUriBeaconUri(kUri, &encoded); |
+ EXPECT_EQ(kEncodedUri, encoded); |
+ |
+ DecodeUriBeaconUri(encoded, &decoded); |
+ EXPECT_EQ(kUri, decoded); |
+} |
+ |
+} // namespace device |