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

Side by Side Diff: net/quic/crypto/null_encrypter_test.cc

Issue 935333002: Update from https://crrev.com/316786 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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 | « net/quic/crypto/null_encrypter.cc ('k') | net/quic/crypto/quic_crypto_client_config.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "net/quic/crypto/null_encrypter.h" 5 #include "net/quic/crypto/null_encrypter.h"
6 #include "net/quic/test_tools/quic_test_utils.h" 6 #include "net/quic/test_tools/quic_test_utils.h"
7 7
8 using base::StringPiece; 8 using base::StringPiece;
9 9
10 namespace net { 10 namespace net {
11 namespace test { 11 namespace test {
12 12
13 class NullEncrypterTest : public ::testing::TestWithParam<bool> { 13 class NullEncrypterTest : public ::testing::TestWithParam<bool> {
14 }; 14 };
15 15
16 TEST_F(NullEncrypterTest, Encrypt) { 16 TEST_F(NullEncrypterTest, Encrypt) {
17 unsigned char expected[] = { 17 unsigned char expected[] = {
18 // fnv hash 18 // fnv hash
19 0xa0, 0x6f, 0x44, 0x8a, 19 0xa0, 0x6f, 0x44, 0x8a,
20 0x44, 0xf8, 0x18, 0x3b, 20 0x44, 0xf8, 0x18, 0x3b,
21 0x47, 0x91, 0xb2, 0x13, 21 0x47, 0x91, 0xb2, 0x13,
22 // payload 22 // payload
23 'g', 'o', 'o', 'd', 23 'g', 'o', 'o', 'd',
24 'b', 'y', 'e', '!', 24 'b', 'y', 'e', '!',
25 }; 25 };
26 NullEncrypter encrypter; 26 NullEncrypter encrypter;
27 scoped_ptr<QuicData> encrypted( 27 char encrypted[256];
28 encrypter.EncryptPacket(0, "hello world!", "goodbye!")); 28 size_t encrypted_len = 0;
29 ASSERT_TRUE(encrypted.get()); 29 ASSERT_TRUE(encrypter.EncryptPacket(0, "hello world!", "goodbye!", encrypted,
30 &encrypted_len, 256));
30 test::CompareCharArraysWithHexError( 31 test::CompareCharArraysWithHexError(
31 "encrypted data", encrypted->data(), encrypted->length(), 32 "encrypted data", encrypted, encrypted_len,
32 reinterpret_cast<const char*>(expected), 33 reinterpret_cast<const char*>(expected), arraysize(expected));
33 arraysize(expected));
34 } 34 }
35 35
36 TEST_F(NullEncrypterTest, GetMaxPlaintextSize) { 36 TEST_F(NullEncrypterTest, GetMaxPlaintextSize) {
37 NullEncrypter encrypter; 37 NullEncrypter encrypter;
38 EXPECT_EQ(1000u, encrypter.GetMaxPlaintextSize(1012)); 38 EXPECT_EQ(1000u, encrypter.GetMaxPlaintextSize(1012));
39 EXPECT_EQ(100u, encrypter.GetMaxPlaintextSize(112)); 39 EXPECT_EQ(100u, encrypter.GetMaxPlaintextSize(112));
40 EXPECT_EQ(10u, encrypter.GetMaxPlaintextSize(22)); 40 EXPECT_EQ(10u, encrypter.GetMaxPlaintextSize(22));
41 } 41 }
42 42
43 TEST_F(NullEncrypterTest, GetCiphertextSize) { 43 TEST_F(NullEncrypterTest, GetCiphertextSize) {
44 NullEncrypter encrypter; 44 NullEncrypter encrypter;
45 EXPECT_EQ(1012u, encrypter.GetCiphertextSize(1000)); 45 EXPECT_EQ(1012u, encrypter.GetCiphertextSize(1000));
46 EXPECT_EQ(112u, encrypter.GetCiphertextSize(100)); 46 EXPECT_EQ(112u, encrypter.GetCiphertextSize(100));
47 EXPECT_EQ(22u, encrypter.GetCiphertextSize(10)); 47 EXPECT_EQ(22u, encrypter.GetCiphertextSize(10));
48 } 48 }
49 49
50 } // namespace test 50 } // namespace test
51 } // namespace net 51 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/crypto/null_encrypter.cc ('k') | net/quic/crypto/quic_crypto_client_config.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698