Skip to main content
  • Home
  • login
  • Browse the archive

    swh mirror partner logo
swh logo
SoftwareHeritage
Software
Heritage
Mirror
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

Revision f6b2ab0ba4fede20d7fdc81a0b281d3470a4d6e9 authored by Jonathan M. Wilbur on 21 August 2024, 02:25:03 UTC, committed by Tomas Mraz on 10 September 2024, 17:17:34 UTC
test: authorityAttributeIdentifier X.509v3 extension
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25244)
1 parent 221e8fa
  • Files
  • Changes
  • 0b326f3
  • /
  • test
  • /
  • list_test.c
Raw File
Cook and download a directory from the Software Heritage Vault

You have requested the cooking of the directory with identifier None into a standard tar.gz archive.

Are you sure you want to continue ?

Download a directory from the Software Heritage Vault

You have requested the download of the directory with identifier None as a standard tar.gz archive.

Are you sure you want to continue ?

Cook and download a revision from the Software Heritage Vault

You have requested the cooking of the history heading to revision with identifier swh:1:rev:f6b2ab0ba4fede20d7fdc81a0b281d3470a4d6e9 into a bare git archive.

Are you sure you want to continue ?

Download a revision from the Software Heritage Vault

You have requested the download of the history heading to revision with identifier swh:1:rev:f6b2ab0ba4fede20d7fdc81a0b281d3470a4d6e9 as a bare git archive.

Are you sure you want to continue ?

Invalid Email !

The provided email is not well-formed.

Download link has expired

The requested archive is no longer available for download from the Software Heritage Vault.

Do you want to cook it again ?

Permalinks

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • revision
  • content
revision badge
swh:1:rev:f6b2ab0ba4fede20d7fdc81a0b281d3470a4d6e9
content badge Iframe embedding
swh:1:cnt:db288d1d08c025b4569756a22230721522eefe6f
list_test.c
/*
 * Copyright 2022 The OpenSSL Project Authors. All Rights Reserved.
 *
 * Licensed under the Apache License 2.0 (the "License").  You may not use
 * this file except in compliance with the License.  You can obtain a copy
 * in the file LICENSE in the source distribution or at
 * https://www.openssl.org/source/license.html
 */

#include <stdio.h>
#include <string.h>

#include <openssl/opensslconf.h>
#include <openssl/err.h>
#include <openssl/crypto.h>

#include "internal/list.h"
#include "internal/nelem.h"
#include "testutil.h"

typedef struct testl_st TESTL;
struct testl_st {
    int n;
    OSSL_LIST_MEMBER(fizz, TESTL);
    OSSL_LIST_MEMBER(buzz, TESTL);
};

DEFINE_LIST_OF(fizz, TESTL);
DEFINE_LIST_OF(buzz, TESTL);

static int test_fizzbuzz(void)
{
    OSSL_LIST(fizz) a;
    OSSL_LIST(buzz) b;
    TESTL elem[20];
    const int nelem = OSSL_NELEM(elem);
    int i, na = 0, nb = 0;

    ossl_list_fizz_init(&a);
    ossl_list_buzz_init(&b);

    if (!TEST_true(ossl_list_fizz_is_empty(&a)))
        return 0;

    for (i = 1; i < nelem; i++) {
        ossl_list_fizz_init_elem(elem + i);
        ossl_list_buzz_init_elem(elem + i);
        elem[i].n = i;
        if (i % 3 == 0) {
            ossl_list_fizz_insert_tail(&a, elem + i);
            na++;
        }
        if (i % 5 == 0) {
            ossl_list_buzz_insert_head(&b, elem + i);
            nb++;
        }
    }

    if (!TEST_false(ossl_list_fizz_is_empty(&a))
            || !TEST_size_t_eq(ossl_list_fizz_num(&a), na)
            || !TEST_size_t_eq(ossl_list_buzz_num(&b), nb)
            || !TEST_ptr(ossl_list_fizz_head(&a))
            || !TEST_ptr(ossl_list_fizz_tail(&a))
            || !TEST_ptr(ossl_list_buzz_head(&b))
            || !TEST_ptr(ossl_list_buzz_tail(&b))
            || !TEST_int_eq(ossl_list_fizz_head(&a)->n, 3)
            || !TEST_int_eq(ossl_list_fizz_tail(&a)->n, na * 3)
            || !TEST_int_eq(ossl_list_buzz_head(&b)->n, nb * 5)
            || !TEST_int_eq(ossl_list_buzz_tail(&b)->n, 5))
        return 0;
    ossl_list_fizz_remove(&a, ossl_list_fizz_head(&a));
    ossl_list_buzz_remove(&b, ossl_list_buzz_tail(&b));
    if (!TEST_size_t_eq(ossl_list_fizz_num(&a), --na)
            || !TEST_size_t_eq(ossl_list_buzz_num(&b), --nb)
            || !TEST_ptr(ossl_list_fizz_head(&a))
            || !TEST_ptr(ossl_list_buzz_tail(&b))
            || !TEST_int_eq(ossl_list_fizz_head(&a)->n, 6)
            || !TEST_int_eq(ossl_list_buzz_tail(&b)->n, 10)
            || !TEST_ptr(ossl_list_fizz_next(ossl_list_fizz_head(&a)))
            || !TEST_ptr(ossl_list_fizz_prev(ossl_list_fizz_tail(&a)))
            || !TEST_int_eq(ossl_list_fizz_next(ossl_list_fizz_head(&a))->n, 9)
            || !TEST_int_eq(ossl_list_fizz_prev(ossl_list_fizz_tail(&a))->n, 15))
        return 0;
    return 1;
}

typedef struct int_st INTL;
struct int_st {
    int n;
    OSSL_LIST_MEMBER(int, INTL);
};

DEFINE_LIST_OF(int, INTL);

static int test_insert(void)
{
    INTL *c, *d;
    OSSL_LIST(int) l;
    INTL elem[20];
    size_t i;
    int n = 1;

    ossl_list_int_init(&l);
    for (i = 0; i < OSSL_NELEM(elem); i++) {
        ossl_list_int_init_elem(elem + i);
        elem[i].n = i;
    }

    /* Check various insert options - head, tail, middle */
    ossl_list_int_insert_head(&l, elem + 3);                /* 3 */
    ossl_list_int_insert_tail(&l, elem + 6);                /* 3 6 */
    ossl_list_int_insert_before(&l, elem + 6, elem + 5);    /* 3 5 6 */
    ossl_list_int_insert_before(&l, elem + 3, elem + 1);    /* 1 3 5 6 */
    ossl_list_int_insert_after(&l, elem + 1, elem + 2);     /* 1 2 3 5 6 */
    ossl_list_int_insert_after(&l, elem + 6, elem + 7);     /* 1 2 3 5 6 7 */
    ossl_list_int_insert_after(&l, elem + 3, elem + 4);     /* 1 2 3 4 5 6 7 */
    if (!TEST_size_t_eq(ossl_list_int_num(&l), 7))
        return 0;
    c = ossl_list_int_head(&l);
    d = ossl_list_int_tail(&l);
    while (c != NULL && d != NULL) {
        if (!TEST_int_eq(c->n, n) || !TEST_int_eq(d->n, 8 - n))
            return 0;
        c = ossl_list_int_next(c);
        d = ossl_list_int_prev(d);
        n++;
    }
    if (!TEST_ptr_null(c) || !TEST_ptr_null(d))
        return 0;

    /* Check removing head, tail and middle */
    ossl_list_int_remove(&l, elem + 1);                     /* 2 3 4 5 6 7 */
    ossl_list_int_remove(&l, elem + 6);                     /* 2 3 4 5 7 */
    ossl_list_int_remove(&l, elem + 7);                     /* 2 3 4 5 */
    n = 2;
    c = ossl_list_int_head(&l);
    d = ossl_list_int_tail(&l);
    while (c != NULL && d != NULL) {
        if (!TEST_int_eq(c->n, n) || !TEST_int_eq(d->n, 7 - n))
            return 0;
        c = ossl_list_int_next(c);
        d = ossl_list_int_prev(d);
        n++;
    }
    if (!TEST_ptr_null(c) || !TEST_ptr_null(d))
        return 0;

    /* Check removing the head of a two element list works */
    ossl_list_int_remove(&l, elem + 2);                     /* 3 4 5 */
    ossl_list_int_remove(&l, elem + 4);                     /* 3 5 */
    ossl_list_int_remove(&l, elem + 3);                     /* 5 */
    if (!TEST_ptr(ossl_list_int_head(&l))
            || !TEST_ptr(ossl_list_int_tail(&l))
            || !TEST_int_eq(ossl_list_int_head(&l)->n, 5)
            || !TEST_int_eq(ossl_list_int_tail(&l)->n, 5))
        return 0;

    /* Check removing the tail of a two element list works */
    ossl_list_int_insert_head(&l, elem);                    /* 0 5 */
    ossl_list_int_remove(&l, elem + 5);                     /* 0 */
    if (!TEST_ptr(ossl_list_int_head(&l))
            || !TEST_ptr(ossl_list_int_tail(&l))
            || !TEST_int_eq(ossl_list_int_head(&l)->n, 0)
            || !TEST_int_eq(ossl_list_int_tail(&l)->n, 0))
        return 0;

    /* Check removing the only element works */
    ossl_list_int_remove(&l, elem);
    if (!TEST_ptr_null(ossl_list_int_head(&l))
            || !TEST_ptr_null(ossl_list_int_tail(&l)))
        return 0;
    return 1;
}

int setup_tests(void)
{
    ADD_TEST(test_fizzbuzz);
    ADD_TEST(test_insert);
    return 1;
}
The diff you're trying to view is too large. Only the first 1000 changed files have been loaded.
Showing with 0 additions and 0 deletions (0 / 0 diffs computed)
swh spinner

Computing file changes ...

ENEA — Copyright (C), ENEA. License: GNU AGPLv3+.
Legal notes  ::  JavaScript license information ::  Web API

back to top