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

Side by Side Diff: crypto/openssl_bio_string_unittest.cc

Issue 2391393005: Remove openssl_bio_string. (Closed)
Patch Set: Created 4 years, 2 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 | « crypto/openssl_bio_string.cc ('k') | testing/libfuzzer/fuzzers/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 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.
4
5 #include "crypto/openssl_bio_string.h"
6
7 #include <openssl/bio.h>
8
9 #include "testing/gtest/include/gtest/gtest.h"
10
11 namespace crypto {
12
13 TEST(OpenSSLBIOString, TestWrite) {
14 std::string s;
15 const std::string expected1("a one\nb 2\n");
16 const std::string expected2("c d e f");
17 const std::string expected3("g h i");
18 {
19 bssl::UniquePtr<BIO> bio(BIO_new_string(&s));
20 ASSERT_TRUE(bio.get());
21
22 EXPECT_EQ(static_cast<int>(expected1.size()),
23 BIO_printf(bio.get(), "a %s\nb %i\n", "one", 2));
24 EXPECT_EQ(expected1, s);
25
26 EXPECT_EQ(1, BIO_flush(bio.get()));
27 EXPECT_EQ(expected1, s);
28
29 EXPECT_EQ(static_cast<int>(expected2.size()),
30 BIO_write(bio.get(), expected2.data(), expected2.size()));
31 EXPECT_EQ(expected1 + expected2, s);
32
33 EXPECT_EQ(static_cast<int>(expected3.size()),
34 BIO_puts(bio.get(), expected3.c_str()));
35 EXPECT_EQ(expected1 + expected2 + expected3, s);
36 }
37 EXPECT_EQ(expected1 + expected2 + expected3, s);
38 }
39
40 TEST(OpenSSLBIOString, TestReset) {
41 std::string s;
42 const std::string expected1("a b c\n");
43 const std::string expected2("d e f g\n");
44 {
45 bssl::UniquePtr<BIO> bio(BIO_new_string(&s));
46 ASSERT_TRUE(bio.get());
47
48 EXPECT_EQ(static_cast<int>(expected1.size()),
49 BIO_write(bio.get(), expected1.data(), expected1.size()));
50 EXPECT_EQ(expected1, s);
51
52 EXPECT_EQ(1, BIO_reset(bio.get()));
53 EXPECT_EQ(std::string(), s);
54
55 EXPECT_EQ(static_cast<int>(expected2.size()),
56 BIO_write(bio.get(), expected2.data(), expected2.size()));
57 EXPECT_EQ(expected2, s);
58 }
59 EXPECT_EQ(expected2, s);
60 }
61
62 } // namespace crypto
OLDNEW
« no previous file with comments | « crypto/openssl_bio_string.cc ('k') | testing/libfuzzer/fuzzers/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698