blob: 4d07fef3ec2927d7a4e90bccb61123e602fcfcb0 [file] [log] [blame]
// Copyright 2021 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "cryptohome/crypto/error_util.h"
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <openssl/bnerr.h>
#include <openssl/err.h>
namespace cryptohome {
TEST(ErrorUtilTest, ErrorQueue) {
EXPECT_TRUE(GetOpenSSLErrors().empty());
// Trigger 2 different errors to get more interesting OpenSSL error queue.
ERR_PUT_error(ERR_LIB_BN, 0, BN_R_INPUT_NOT_REDUCED, "", 0);
ERR_PUT_error(ERR_LIB_BN, 0, BN_R_DIV_BY_ZERO, "", 0);
EXPECT_THAT(GetOpenSSLErrors(), testing::ContainsRegex(".*;.*;"));
EXPECT_TRUE(GetOpenSSLErrors().empty());
}
} // namespace cryptohome