proxygen
UtilsTest.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-present, Facebook, Inc.
3  * All rights reserved.
4  *
5  * This source code is licensed under the BSD-style license found in the
6  * LICENSE file in the root directory of this source tree.
7  */
8 
9 #include <gtest/gtest.h>
10 
11 #include <fizz/crypto/Utils.h>
12 
13 using namespace folly;
14 using namespace testing;
15 
16 namespace fizz {
17 namespace test {
18 
19 TEST(UtilsTest, TestEqualWrongSize) {
20  StringPiece a{"hi"};
21  StringPiece b{"hello"};
22  EXPECT_FALSE(CryptoUtils::equal(a, b));
23  EXPECT_FALSE(CryptoUtils::equal(b, a));
24 }
25 
26 TEST(UtilsTest, TestEqual) {
27  StringPiece a{"hello!!"};
28  StringPiece b{"hello!!"};
29  StringPiece c{"goodbye"};
30  EXPECT_TRUE(CryptoUtils::equal(a, b));
31  EXPECT_FALSE(CryptoUtils::equal(a, c));
32 }
33 
34 TEST(UtilsTest, TestClean) {
35  std::array<uint8_t, 8> a{'p', 'a', 's', 's', 'w', 'o', 'r', 'd'};
36  CryptoUtils::clean(range(a));
37  for (auto byte : a) {
38  EXPECT_EQ(byte, 0);
39  }
40 }
41 } // namespace test
42 } // namespace fizz
char b
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
—— Concurrent Priority Queue Implementation ——
Definition: AtomicBitSet.h:29
constexpr Range< Iter > range(Iter first, Iter last)
Definition: Range.h:1114
Definition: Actions.h:16
char a
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
char c
TEST(SequencedExecutor, CPUThreadPoolExecutor)