Make castv2 performance test work.
[chromium-blink-merge.git] / device / bluetooth / uribeacon / uri_encoder_unittest.cc
blob2e4fa9c1153623bd0fdf6891782b3373e670f5d3
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.
5 #include "device/bluetooth/uribeacon/uri_encoder.h"
6 #include "testing/gtest/include/gtest/gtest.h"
8 namespace device {
10 TEST(UriEncoderTest, Url1) {
11 const std::string kUri = "http://123.com";
12 const char encoded_uri[] = {2, '1', '2', '3', 7};
13 const std::vector<uint8_t> kEncodedUri(encoded_uri,
14 encoded_uri + sizeof(encoded_uri));
16 std::vector<uint8_t> encoded;
17 std::string decoded;
19 EncodeUriBeaconUri(kUri, encoded);
20 EXPECT_EQ(kEncodedUri, encoded);
22 DecodeUriBeaconUri(encoded, decoded);
23 EXPECT_EQ(kUri, decoded);
26 TEST(UriEncoderTest, Url2) {
27 const std::string kUri = "http://www.abcdefghijklmnop.org";
28 const char encoded_uri[] = {
29 0, 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
30 'o', 'p', 8};
31 const std::vector<uint8_t> kEncodedUri(encoded_uri,
32 encoded_uri + sizeof(encoded_uri));
34 std::vector<uint8_t> encoded;
35 std::string decoded;
37 EncodeUriBeaconUri(kUri, encoded);
38 EXPECT_EQ(kEncodedUri, encoded);
40 DecodeUriBeaconUri(encoded, decoded);
41 EXPECT_EQ(kUri, decoded);
44 TEST(UriEncoderTest, Url3) {
45 const std::string kUri = "https://123.com/123";
46 const char encoded_uri[] = {3, '1', '2', '3', 0, '1', '2', '3'};
47 const std::vector<uint8_t> kEncodedUri(encoded_uri,
48 encoded_uri + sizeof(encoded_uri));
50 std::vector<uint8_t> encoded;
51 std::string decoded;
53 EncodeUriBeaconUri(kUri, encoded);
54 EXPECT_EQ(kEncodedUri, encoded);
56 DecodeUriBeaconUri(encoded, decoded);
57 EXPECT_EQ(kUri, decoded);
60 TEST(UriEncoderTest, Url4) {
61 const std::string kUri = "http://www.uribeacon.org";
62 const char encoded_uri[] = {
63 0, 'u', 'r', 'i', 'b', 'e', 'a', 'c', 'o', 'n', 8};
64 const std::vector<uint8_t> kEncodedUri(encoded_uri,
65 encoded_uri + sizeof(encoded_uri));
67 std::vector<uint8_t> encoded;
68 std::string decoded;
70 EncodeUriBeaconUri(kUri, encoded);
71 EXPECT_EQ(kEncodedUri, encoded);
73 DecodeUriBeaconUri(encoded, decoded);
74 EXPECT_EQ(kUri, decoded);
77 TEST(UriEncoderTest, Url5) {
78 const std::string kUri = "http://web.mit.edu/";
79 const char encoded_uri[] = {2, 'w', 'e', 'b', '.', 'm', 'i', 't', 2};
80 const std::vector<uint8_t> kEncodedUri(encoded_uri,
81 encoded_uri + sizeof(encoded_uri));
83 std::vector<uint8_t> encoded;
84 std::string decoded;
86 EncodeUriBeaconUri(kUri, encoded);
87 EXPECT_EQ(kEncodedUri, encoded);
89 DecodeUriBeaconUri(encoded, decoded);
90 EXPECT_EQ(kUri, decoded);
93 } // namespace device