Sha256: 32a6e25444161bd9f03e46761deffab13d1b893e993462e4f15302482c616402

Contents?: true

Size: 1 KB

Versions: 3

Compression:

Stored size: 1 KB

Contents

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

void test_shuffle_strings_in_place()
{
    char *test_strings[] = {"apple", "banana", "cherry", "date", "elderberry"};
    size_t num_strings = sizeof(test_strings) / sizeof(test_strings[0]);

    // Test for shuffling a valid array of strings
    char **original_strings = malloc(sizeof(char *) * num_strings);
    memcpy(original_strings, test_strings, sizeof(test_strings));
    int result = shuffle_strings_in_place(test_strings, num_strings);
    assert(result == 1);

    // Test for strings being shuffled in place
    int any_strings_moved = 0;
    for (size_t i = 0; i < num_strings; i++)
    {
        if (strcmp(original_strings[i], test_strings[i]) != 0)
        {
            any_strings_moved = 1;
            break;
        }
    }
    assert(any_strings_moved == 1);

    free(original_strings);

    printf("All tests pass!\n");
}

int main()
{
    test_shuffle_strings_in_place();
    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_shuffle_strings_in_place.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_shuffle_strings_in_place.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_shuffle_strings_in_place.c