OLD | NEW |
1 // Copyright (c) 2011 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 "crypto/secure_hash.h" | 5 #include "crypto/secure_hash.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/pickle.h" | 9 #include "base/pickle.h" |
10 #include "crypto/sha2.h" | 10 #include "crypto/sha2.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 ctx1->Update(input1.data(), input1.size()); | 55 ctx1->Update(input1.data(), input1.size()); |
56 ctx1->Update(input2.data(), input2.size()); | 56 ctx1->Update(input2.data(), input2.size()); |
57 ctx1->Update(input3.data(), input3.size()); | 57 ctx1->Update(input3.data(), input3.size()); |
58 | 58 |
59 EXPECT_TRUE(ctx1->Serialize(&pickle)); | 59 EXPECT_TRUE(ctx1->Serialize(&pickle)); |
60 ctx1->Update(input4.data(), input4.size()); | 60 ctx1->Update(input4.data(), input4.size()); |
61 ctx1->Update(input5.data(), input5.size()); | 61 ctx1->Update(input5.data(), input5.size()); |
62 | 62 |
63 ctx1->Finish(output1, sizeof(output1)); | 63 ctx1->Finish(output1, sizeof(output1)); |
64 | 64 |
65 void* data_iterator = NULL; | 65 PickleIterator data_iterator(pickle); |
66 EXPECT_TRUE(ctx2->Deserialize(&data_iterator, &pickle)); | 66 EXPECT_TRUE(ctx2->Deserialize(&data_iterator)); |
67 ctx2->Update(input4.data(), input4.size()); | 67 ctx2->Update(input4.data(), input4.size()); |
68 ctx2->Update(input5.data(), input5.size()); | 68 ctx2->Update(input5.data(), input5.size()); |
69 | 69 |
70 ctx2->Finish(output2, sizeof(output2)); | 70 ctx2->Finish(output2, sizeof(output2)); |
71 | 71 |
72 EXPECT_EQ(0, memcmp(output1, output2, crypto::kSHA256Length)); | 72 EXPECT_EQ(0, memcmp(output1, output2, crypto::kSHA256Length)); |
73 } | 73 } |
OLD | NEW |