chromium/third_party/boringssl/src/crypto/stack/stack_test.cc

/* Copyright (c) 2018, Google Inc.
 *
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */

#include <openssl/stack.h>

#include <limits.h>

#include <algorithm>
#include <memory>
#include <utility>
#include <vector>

#include <gtest/gtest.h>

#include <openssl/mem.h>
#include <openssl/rand.h>


// Define a custom stack type for testing.
TEST_INT;

static void TEST_INT_free(TEST_INT *x) {}

BSSL_NAMESPACE_BEGIN
BORINGSSL_MAKE_DELETER()
BSSL_NAMESPACE_END

static bssl::UniquePtr<TEST_INT> TEST_INT_new(int x) {}

DEFINE_STACK_OF(TEST_INT)

struct ShallowStackDeleter {};

ShallowStack;

// kNull is treated as a nullptr expectation for purposes of ExpectStackEquals.
// The tests in this file will never use it as a test value.
static const int kNull =;

static void ExpectStackEquals(const STACK_OF(TEST_INT) *sk,
                              const std::vector<int> &vec) {}

TEST(StackTest, Basic) {}

TEST(StackTest, BigStack) {}

static uint64_t g_compare_count =;

static int compare(const TEST_INT *const *a, const TEST_INT *const *b) {}

static int compare_reverse(const TEST_INT *const *a, const TEST_INT *const *b) {}

TEST(StackTest, Sorted) {}

// sk_*_find should return the first matching element in all cases.
TEST(StackTest, FindFirst) {}

// Exhaustively test the binary search.
TEST(StackTest, BinarySearch) {}

TEST(StackTest, DeleteIf) {}

TEST(StackTest, IsSorted) {}

TEST(StackTest, Sort) {}

TEST(StackTest, NullIsEmpty) {}