OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/indexed_db/indexed_db_leveldb_coding.h" | 5 #include "content/browser/indexed_db/indexed_db_leveldb_coding.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 std::string encoded_b = WrappedEncodeStringWithLength(b); | 469 std::string encoded_b = WrappedEncodeStringWithLength(b); |
470 EXPECT_TRUE(encoded_a.size()); | 470 EXPECT_TRUE(encoded_a.size()); |
471 | 471 |
472 EXPECT_LT(CompareStrings(encoded_a, encoded_b), 0); | 472 EXPECT_LT(CompareStrings(encoded_a, encoded_b), 0); |
473 EXPECT_GT(CompareStrings(encoded_b, encoded_a), 0); | 473 EXPECT_GT(CompareStrings(encoded_b, encoded_a), 0); |
474 EXPECT_EQ(CompareStrings(encoded_a, encoded_a), 0); | 474 EXPECT_EQ(CompareStrings(encoded_a, encoded_a), 0); |
475 EXPECT_EQ(CompareStrings(encoded_b, encoded_b), 0); | 475 EXPECT_EQ(CompareStrings(encoded_b, encoded_b), 0); |
476 } | 476 } |
477 } | 477 } |
478 | 478 |
479 static std::string WrappedEncodeBinary(std::string value) { | 479 static std::string WrappedEncodeBinary(const std::string& value) { |
480 std::string buffer; | 480 std::string buffer; |
481 EncodeBinary(value, &buffer); | 481 EncodeBinary(value, &buffer); |
482 return buffer; | 482 return buffer; |
483 } | 483 } |
484 | 484 |
485 TEST(IndexedDBLevelDBCodingTest, EncodeBinary) { | 485 TEST(IndexedDBLevelDBCodingTest, EncodeBinary) { |
486 const unsigned char binary_data[] = {0x00, 0x01, 0xfe, 0xff}; | 486 const unsigned char binary_data[] = {0x00, 0x01, 0xfe, 0xff}; |
487 EXPECT_EQ( | 487 EXPECT_EQ( |
488 1u, | 488 1u, |
489 WrappedEncodeBinary(std::string(binary_data, binary_data + 0)).size()); | 489 WrappedEncodeBinary(std::string(binary_data, binary_data + 0)).size()); |
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
975 std::string b = WrappedEncodeVarInt(static_cast<int64>(n)); | 975 std::string b = WrappedEncodeVarInt(static_cast<int64>(n)); |
976 | 976 |
977 EXPECT_EQ(a.size(), b.size()); | 977 EXPECT_EQ(a.size(), b.size()); |
978 EXPECT_EQ(*a.begin(), *b.begin()); | 978 EXPECT_EQ(*a.begin(), *b.begin()); |
979 } | 979 } |
980 } | 980 } |
981 | 981 |
982 } // namespace | 982 } // namespace |
983 | 983 |
984 } // namespace content | 984 } // namespace content |
OLD | NEW |