Sha256: 95db4d33f3e3515e90d3de8a4fe7a23dcabe1b1fae858a5fea5b2d7e243ec78b

Contents?: true

Size: 965 Bytes

Versions: 3

Compression:

Stored size: 965 Bytes

Contents

#include "../foundationallib.h"
#include <assert.h>
#include <stdio.h>

// Define the Set and SetKey structures
struct SetKey
{
    const char *key;
    struct SetKey *next;
};

struct Set
{
    struct SetKey **table;
    size_t capacity;
};

// Define the FOUNDATIONAL_LIB_FUNC macro

// Include the set_in function
#include "set_in.c"

// Test the set_in function
void test_set_in()
{
    // Create a Set
    struct Set set;
    set.capacity = 10;
    set.table = calloc(set.capacity, sizeof(struct SetKey *));

    // Add some keys to the Set
    struct SetKey key1 = {"key1", NULL};
    set.table[0] = &key1;

    struct SetKey key2 = {"key2", NULL};
    set.table[1] = &key2;

    // Test for present key
    assert(set_in(&set, "key1") == 1);

    // Test for absent key
    assert(set_in(&set, "key3") == 0);

    // Free the memory used by the Set
    free(set.table);
}

int main()
{
    test_set_in();

    printf("All tests passed.\n");

    return 0;
}

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
foundational_lib-1.0.1 ./tests/more/experimental/third_test_suite/non_production_ready_test_suite/test_every_relevant_function_in_a_separate_thorough_program/work_in_progress_code/src/test_frozen_set_destructor.c
foundational_lib2-1.0 ./tests/more/experimental/third_test_suite/non_production_ready_test_suite/test_every_relevant_function_in_a_separate_thorough_program/work_in_progress_code/src/test_frozen_set_destructor.c
foundational_lib-1.0 ./tests/more/experimental/third_test_suite/non_production_ready_test_suite/test_every_relevant_function_in_a_separate_thorough_program/work_in_progress_code/src/test_frozen_set_destructor.c