Skip to content

TestFunction

TestFunction

Description

Function pointer type for test functions.

Success

Function returns true if test passed, false if failed.

Failure

Function cannot fail - always returns boolean result.

Usage example (Cross-references)

Usage examples (Cross-references)
    
    // Run a specific deadend test using setjmp/longjmp to capture aborts
    bool test_deadend(TestFunction test_func, bool expect_failure) {
        if (!test_func) {
            WriteFmt("[ERROR] test_deadend: NULL test function provided\n");
    
    /// Run an array of simple tests
    int simple_test_driver(TestFunction *tests, int count) {
        if (!tests) {
            WriteFmt("[ERROR] simple_test_driver: NULL tests array provided\n");
    
    /// Run an array of deadend tests (all expecting failure)
    int deadend_test_driver(TestFunction *tests, int count) {
        if (!tests) {
            WriteFmt("[ERROR] deadend_test_driver: NULL tests array provided\n");
    /// Main test driver - handles everything: normal tests and deadend tests
    int run_test_suite(
        TestFunction *normal_tests,
        int           normal_count,
        TestFunction *deadend_tests,
        TestFunction *normal_tests,
        int           normal_count,
        TestFunction *deadend_tests,
        int           deadend_count,
        const char   *test_name
    /// TAGS: Testing, Deadend, Control
    ///
    bool test_deadend(TestFunction test_func, bool expect_failure);
    
    ///
    /// TAGS: Testing, Driver, Simple
    ///
    int simple_test_driver(TestFunction *tests, int count);
    
    ///
    /// TAGS: Testing, Driver, Deadend
    ///
    int deadend_test_driver(TestFunction *tests, int count);
    
    ///
    ///
    int run_test_suite(
        TestFunction *normal_tests,
        int           normal_count,
        TestFunction *deadend_tests,
        TestFunction *normal_tests,
        int           normal_count,
        TestFunction *deadend_tests,
        int           deadend_count,
        const char   *test_name
    
    int main(void) {
        TestFunction tests[] = {
            test_kvconfig_basic_parse,
            test_kvconfig_comments_quotes_and_duplicates,
    int main(int argc, char *argv[]) {
        // Array of test functions
        TestFunction tests[] = {
            test_two_level_nesting_writing,
            test_three_level_nesting_writing,
    int main(int argc, char *argv[]) {
        // Array of test functions
        TestFunction tests[] = {
            test_simple_string_parsing,
            test_simple_numbers,
    int main(int argc, char *argv[]) {
        // Array of test functions
        TestFunction tests[] = {
            test_basic_iterator_functionality,
            test_simple_json_object,
    int main(int argc, char *argv[]) {
        // Array of test functions
        TestFunction tests[] = {
            test_empty_object_writing,
            test_empty_array_writing,
    int main(int argc, char *argv[]) {
        // Array of test functions
        TestFunction tests[] = {
            test_simple_string_writing,
            test_simple_numbers_writing,
    int main(int argc, char *argv[]) {
        // Array of test functions
        TestFunction tests[] = {
            test_simple_roundtrip,
            test_numeric_roundtrip,
    int main(int argc, char *argv[]) {
        // Array of test functions
        TestFunction tests[] = {
            test_empty_object_reading,
            test_empty_array_reading,
    
        // Deadend tests that would cause program termination
        TestFunction deadend_tests[] = {
            test_bitvec_find_pattern_null_source,      test_bitvec_find_pattern_null_pattern,
            test_bitvec_find_last_pattern_null_source, test_bitvec_find_last_pattern_null_pattern,
    
    int main(void) {
        TestFunction tests[] = {
            test_map_type_defaults,
            test_map_type_with_value_compare,
    
        // Array of test functions
        TestFunction tests[] = {
            test_str_insert_char_at,
            test_str_insert_cstr,
        WriteFmt("[INFO] Starting Float.Math tests\n\n");
    
        TestFunction tests[] = {
            test_float_negate_abs,
            test_float_add_small_small,
        };
    
        TestFunction deadend_tests[] = {
            test_float_div_by_zero,
        };
    
        // Array of test functions
        TestFunction tests[] = {test_vec_swap_items, test_vec_reverse, test_vec_sort};
    
        int total_tests = sizeof(tests) / sizeof(tests[0]);
    
        // Array of test functions
        TestFunction tests[] = {
            test_vec_at,
            test_vec_ptr_at,
        WriteFmt("[INFO] Starting Int.Convert tests\n\n");
    
        TestFunction tests[] = {
            test_int_from_unsigned_integer,
            test_int_bytes_le_round_trip,
        };
    
        TestFunction deadend_tests[] = {
            test_int_from_binary_invalid_digit,
            test_int_from_decimal_invalid_digit,
    
    int main(void) {
        TestFunction tests[] = {
            test_map_remove_value,
            test_map_remove_pair,
        WriteFmt("[INFO] Starting Int.Compare tests\n\n");
    
        TestFunction tests[] = {
            test_int_compare,
            test_int_compare_wrappers,
    
        // Array of test functions
        TestFunction tests[] = {
            test_integer_decimal_reading,
            test_integer_hex_reading,
    
    int main(void) {
        TestFunction tests[] = {
            test_map_foreach_ptr,
            test_map_foreach_multimap_iterators,
    
        // Array of test functions
        TestFunction tests[] = {
            test_bitvec_get,
            test_bitvec_set,
    
        // Array of normal test functions
        TestFunction tests[] = {
            test_bitvec_foreach_idx,
            test_bitvec_foreach,
    
        // Array of deadend test functions
        TestFunction deadend_tests[] = {
            test_bitvec_foreach_invalid_usage,
            test_bitvec_run_lengths_null_bv,
    int main(int argc, char *argv[]) {
        // Array of normal test functions
        TestFunction normal_tests[] = {
            test_vec_pop_back,
            test_vec_pop_front,
    
    int main(void) {
        TestFunction tests[] = {
            test_map_insert_and_set,
            test_map_set_first,
        WriteFmt("[INFO] Starting Float.Compare tests\n\n");
    
        TestFunction tests[] = {
            test_float_compare_small_small,
            test_float_compare_very_large_large,
    
        // Array of normal test functions
        TestFunction tests[] = {test_str_type, test_strs_type, test_validate_str, test_validate_strs};
    
        // Array of deadend test functions (tests that should crash/abort)
    
        // Array of deadend test functions (tests that should crash/abort)
        TestFunction deadend_tests[] = {test_validate_invalid_str, test_validate_invalid_strs};
    
        int total_tests   = sizeof(tests) / sizeof(tests[0]);
    
        // Deadend tests that would cause program termination
        TestFunction deadend_tests[] = {
            test_bitvec_find_deadend_tests,
            test_bitvec_predicate_deadend_tests,
    
        // Array of test functions
        TestFunction tests[] = {
            test_basic_formatting,
            test_string_formatting,
    
        // Array of normal test functions
        TestFunction tests[] = {
            test_str_foreach_idx,
            test_str_foreach_reverse_idx,
    
        // Array of test functions
        TestFunction tests[] = {test_vec_try_reduce_space, test_vec_resize, test_vec_reserve, test_vec_clear};
    
        int total_tests = sizeof(tests) / sizeof(tests[0]);
    
        // Array of test functions
        TestFunction tests[] = {
            test_vec_init_basic,
            test_vec_init_aligned,
    
        // Array of normal test functions
        TestFunction tests[] = {
            test_str_from_u64,
            test_str_from_i64,
    
        // Array of deadend test functions
        TestFunction deadend_tests[] = {
            test_str_conversion_null_failures,
            test_str_conversion_bounds_failures,
    
        // Array of normal test functions
        TestFunction tests[] = {
            test_bitvec_foreach_idx,
            test_bitvec_foreach,
    
        // Array of normal test functions
        TestFunction tests[] = {
            test_bitvec_pop,
            test_bitvec_remove_single,
    
        // Array of deadend test functions
        TestFunction deadend_tests[] = {
            test_bitvec_remove_null_failures,
            test_bitvec_remove_range_null_failures,
    
        // Array of normal test functions
        TestFunction tests[] = {
            test_bitvec_hamming_distance_basic,
            test_bitvec_hamming_distance_edge_cases,
    
        // Array of deadend test functions
        TestFunction deadend_tests[] = {
            test_bitvec_hamming_distance_null_bv1,
            test_bitvec_hamming_distance_null_bv2,
    
        // Array of normal test functions
        TestFunction tests[] = {
            test_bitvec_equals,
            test_bitvec_compare,
    
        // Array of deadend test functions
        TestFunction deadend_tests[] = {
            test_bitvec_compare_null_failures,
            test_bitvec_subset_null_failures,
    
        // Array of normal test functions
        TestFunction tests[] = {
            test_bitvec_init,
            test_bitvec_deinit,
    
        // Array of deadend test functions (expected failure scenarios)
        TestFunction deadend_tests[] = {
            test_bitvec_null_pointer_failures,
            test_bitvec_invalid_operations,
    
        // Array of test functions
        TestFunction tests[] = {
            test_str_try_reduce_space,
            test_str_swap_char_at,
    
        // Array of deadend test functions
        TestFunction deadend_tests[] = {
            test_bitvec_bitwise_null_failures,
            test_bitvec_bitwise_ops_null_failures,
    
        // Array of normal test functions
        TestFunction tests[] = {
            test_bitvec_shift_left,
            test_bitvec_shift_right,
    
        // Array of test functions
        TestFunction tests[] = {test_vec_type_basic, test_vec_validate};
    
        int total_tests = sizeof(tests) / sizeof(tests[0]);
        WriteFmt("[INFO] Starting Int.Access tests\n\n");
    
        TestFunction tests[] = {
            test_int_bit_length,
            test_int_byte_length,
        };
    
        TestFunction deadend_tests[] = {
            test_int_log2_zero,
        };
    
    int main(void) {
        TestFunction tests[] = {
            test_map_deep_copy_zstrs,
            test_map_policy_switch_preserves_entries,
    
        // Array of test functions
        TestFunction tests[] = {test_bitvec_type_basic, test_bitvec_validate};
    
        int total_tests = sizeof(tests) / sizeof(tests[0]);
    
        // Array of deadend test functions
        TestFunction deadend_tests[] = {
            test_bitvec_foreach_invalid_usage,
            test_bitvec_run_lengths_null_bv,
    
        // Array of test functions
        TestFunction tests[] =
            {test_str_cmp, test_str_find, test_str_starts_ends_with, test_str_replace, test_str_split, test_str_strip};
    
        // Array of normal test functions
        TestFunction tests[] = {
            test_vec_foreach,
            test_vec_foreach_idx,
    
        // Array of normal test functions
        TestFunction tests[] = {
            test_bitvec_shrink_to_fit,
            test_bitvec_set_capacity,
    
        // Array of deadend test functions
        TestFunction deadend_tests[] = {
            test_bitvec_memory_null_failures,
            test_bitvec_swap_null_failures,
    
        // Array of normal test functions
        TestFunction tests[] = {
            test_bitvec_to_string,
            test_bitvec_from_string,
    
        // Array of deadend test functions
        TestFunction deadend_tests[] = {
            test_bitvec_convert_null_failures,
            test_bitvec_from_string_null_failures,
    
    int main(void) {
        TestFunction tests[] = {
            test_map_reserve_and_clear,
            test_map_rehash_policy_switch,
    
        // Array of normal test functions
        TestFunction tests[] = {
            test_bitvec_shift_left,
            test_bitvec_shift_right,
    
        // Array of deadend test functions
        TestFunction deadend_tests[] = {
            test_bitvec_bitwise_null_failures,
            test_bitvec_bitwise_ops_null_failures,
    
        // Array of test functions
        TestFunction tests[] = {
            test_complex_vec_init,
            test_complex_vec_push,
    
        // Array of normal test functions
        TestFunction tests[] = {
            test_bitvec_insert_range,
            test_bitvec_insert_multiple,
    
        // Array of deadend test functions
        TestFunction deadend_tests[] = {
            test_bitvec_insert_null_failures,
            test_bitvec_insert_invalid_range_failures,
    
        // Array of test functions
        TestFunction tests[] =
            {test_str_first, test_str_last, test_str_begin, test_str_end, test_str_char_at, test_str_char_ptr_at};
    
        // Array of test functions (adding new tests to existing ones)
        TestFunction tests[] = {
            test_bitvec_get,
            test_bitvec_set,
    
        // Deadend tests that would cause program termination
        TestFunction deadend_tests[] = {
            test_bitvec_find_deadend_tests,
            test_bitvec_predicate_deadend_tests,
        WriteFmt("[INFO] Starting Float.Convert tests\n\n");
    
        TestFunction tests[] = {
            test_float_from_unsigned_integer,
            test_float_from_signed_integer,
        };
    
        TestFunction deadend_tests[] = {
            test_float_from_str_invalid,
            test_float_from_str_null,
        WriteFmt("[INFO] Starting Int.Math tests\n\n");
    
        TestFunction tests[] = {
            test_int_shift_left_grows,
            test_int_shift_right_shrinks,
        };
    
        TestFunction deadend_tests[] = {
            test_int_add_null_result,
            test_int_shift_left_null,
        WriteFmt("[INFO] Starting Float.Access tests\n\n");
    
        TestFunction tests[] = {
            test_float_is_zero,
            test_float_is_negative,
        WriteFmt("[INFO] Starting Float.Type tests\n\n");
    
        TestFunction tests[] = {
            test_float_init,
            test_float_clear,
    
        // Array of test functions
        TestFunction tests[] = {
            test_bitvec_basic_pattern_functions,
            test_bitvec_find_pattern,
    
        // Deadend tests that would cause program termination
        TestFunction deadend_tests[] = {
            test_bitvec_find_pattern_null_source,
            test_bitvec_find_pattern_null_pattern,
        WriteFmt("[INFO] Starting Int.Type tests\n\n");
    
        TestFunction tests[] = {
            test_int_init,
            test_int_clear,
    
        // Array of test functions
        TestFunction tests[] = {
            test_bitvec_basic_pattern_functions, test_bitvec_find_pattern,           test_bitvec_find_last_pattern,
            test_bitvec_find_all_pattern,        test_bitvec_pattern_edge_cases,     test_bitvec_pattern_stress_tests,
    
        // Array of test functions
        TestFunction tests[] = {
            test_str_init,
            test_str_init_from_cstr,
    
        // Array of test functions
        TestFunction tests[] = {
            test_vec_push_back,
            test_vec_push_front,
    
    int main(void) {
        TestFunction tests[] = {
            test_map_contains_and_find,
            test_map_get_ptr,
    
        // Array of test functions
        TestFunction tests[] = {
            test_str_pop_back,
            test_str_pop_front,
Last updated on