Пример #1
0
END_TEST


static Suite* Streader_suite(void)
{
    Suite* s = suite_create("Streader");

    const int timeout = DEFAULT_TIMEOUT;

#define BUILD_TCASE(name)                   \
    TCase* tc_##name = tcase_create(#name); \
    suite_add_tcase(s, tc_##name);          \
    tcase_set_timeout(tc_##name, timeout)

    BUILD_TCASE(init);
    BUILD_TCASE(match);

    BUILD_TCASE(read_null);
    BUILD_TCASE(read_bool);
    BUILD_TCASE(read_int);
    BUILD_TCASE(read_float);
    BUILD_TCASE(read_string);
    BUILD_TCASE(read_tstamp);
    BUILD_TCASE(read_piref);
    BUILD_TCASE(read_list);
    BUILD_TCASE(read_dict);
    BUILD_TCASE(read_format);

#undef BUILD_TCASE

    tcase_add_test(tc_init, Initial_streader_has_no_error_set);

    tcase_add_test(tc_match, Matching_visible_characters_succeed);
    tcase_add_test(tc_match, Matching_wrong_characters_fails);
    tcase_add_test(tc_match, Characters_past_specified_length_are_ignored);
    tcase_add_test(tc_match, Matching_strings_requires_quotes_in_data);
    tcase_add_test(tc_match, Matching_strings_succeeds);
    tcase_add_test(tc_match, Matching_wrong_strings_fails);

    tcase_add_test(tc_read_null, Reading_null_consumes_data);
    tcase_add_test(tc_read_null, Null_token_with_trailing_garbage_is_rejected);

    tcase_add_test(tc_read_bool, Reading_bool_stores_correct_value);
    tcase_add_test(tc_read_bool, Bool_with_trailing_garbage_is_rejected);

    tcase_add_test(tc_read_int, Read_zero_int);
    tcase_add_test(tc_read_int, Read_nonzero_int);
    tcase_add_test(tc_read_int, Reading_too_large_int_in_magnitude_fails);

    tcase_add_test(tc_read_float, Read_zero_float);
    tcase_add_test(tc_read_float, Read_nonzero_float);
    tcase_add_test(tc_read_float, Whitespace_terminates_decimal_number);

    tcase_add_test(tc_read_string, Read_valid_string);
    tcase_add_test(tc_read_string, Reading_invalid_string_fails);

    tcase_add_test(tc_read_tstamp, Read_valid_tstamp);
    tcase_add_test(tc_read_tstamp, Reading_invalid_tstamp_fails);

    tcase_add_test(tc_read_piref, Read_valid_piref);
    tcase_add_test(tc_read_piref, Reading_invalid_piref_fails);

    tcase_add_test(tc_read_list, Read_empty_list);
    tcase_add_test(tc_read_list, Read_list_of_numbers);
    tcase_add_test(tc_read_list, Read_list_of_tstamps);
    tcase_add_test(tc_read_list, Callback_must_be_specified_for_nonempty_lists);
    tcase_add_test(tc_read_list, Callback_failure_interrupts_list_reading);

    tcase_add_test(tc_read_dict, Read_empty_dict);
    tcase_add_test(tc_read_dict, Read_dict_of_numbers);
    tcase_add_test(tc_read_dict, Callback_must_be_specified_for_nonempty_dicts);
    tcase_add_test(tc_read_dict, Callback_failure_interrupts_dict_reading);

    tcase_add_test(tc_read_format, Read_formatted_input);

    return s;
}
Пример #2
0
END_TEST


static Suite* Player_suite(void)
{
    Suite* s = suite_create("Player");

    const int timeout = DEFAULT_TIMEOUT;

#define BUILD_TCASE(name)                                                \
    TCase* tc_##name = tcase_create(#name);                              \
    suite_add_tcase(s, tc_##name);                                       \
    tcase_set_timeout(tc_##name, timeout);                               \
    tcase_add_checked_fixture(tc_##name, setup_empty, handle_teardown)

    BUILD_TCASE(general);
    BUILD_TCASE(notes);
    BUILD_TCASE(patterns);
    BUILD_TCASE(songs);
    BUILD_TCASE(events);

#undef BUILD_TCASE

    // Note mixing
    tcase_add_test(tc_notes, Complete_debug_note_renders_correctly);
    tcase_add_test(tc_notes, Note_off_stops_the_note_correctly);
    tcase_add_test(tc_notes, Note_end_is_reached_correctly_during_note_off);
    tcase_add_test(tc_notes, Implicit_note_off_is_triggered_correctly);
    tcase_add_test(tc_notes, Independent_notes_mix_correctly);
    tcase_add_test(tc_notes, Debug_single_shot_renders_one_pulse);

    // Patterns
    tcase_add_loop_test(
            tc_patterns, Empty_pattern_contains_silence,
            0, MIXING_RATE_COUNT);
    tcase_add_loop_test(tc_patterns, Note_on_at_pattern_end_is_handled, 0, 4);
    tcase_add_loop_test(tc_patterns, Note_on_after_pattern_end_is_ignored, 0, 4);
    tcase_add_test(tc_patterns, Note_on_at_pattern_start_is_handled);
    tcase_add_test(tc_patterns, Pattern_playback_repeats_pattern);
    tcase_add_test(tc_patterns, Pattern_playback_pauses_zero_length_pattern);

    // Songs
    tcase_add_test(tc_songs, Empty_composition_renders_zero_frames);
    tcase_add_test(tc_songs, Paused_empty_composition_contains_silence);
    tcase_add_loop_test(tc_songs, Initial_tempo_is_set_correctly, 0, 4);
    tcase_add_test(tc_songs, Infinite_mode_loops_composition);
    tcase_add_loop_test(tc_songs, Skipping_moves_position_forwards, 0, 4);

    // Events
    tcase_add_loop_test(
            tc_events, Pattern_delay_extends_gap_between_trigger_rows,
            0, 4);
    tcase_add_loop_test(
            tc_events, Pattern_delay_inserts_gap_between_adjacent_triggers,
            0, 4);
    tcase_add_loop_test(
            tc_events, Tempo_change_affects_playback_cursor,
            0, 4);
    tcase_add_loop_test(
            tc_events, Tempo_slide_affects_playback_cursor,
            0, 4);
    tcase_add_loop_test(
            tc_events, Jump_backwards_creates_a_loop,
            0, 4);
    tcase_add_test(tc_events, Events_appear_in_event_buffer);
    tcase_add_test(
            tc_events,
            Events_from_many_triggers_can_be_retrieved_with_multiple_receives);
    tcase_add_test(
            tc_events,
            Events_from_many_triggers_are_skipped_by_fire);
    tcase_add_test(
            tc_events,
            Events_from_complex_bind_can_be_retrieved_with_multiple_receives);
    tcase_add_test(
            tc_events,
            Fire_with_complex_bind_can_be_processed_with_multiple_receives);
    tcase_add_test(tc_events, Query_initial_location);
    tcase_add_test(tc_events, Query_final_location);
    tcase_add_test(tc_events, Query_voice_count_with_silence);
    tcase_add_test(tc_events, Query_voice_count_with_note);
    tcase_add_test(tc_events, Query_note_force);

    return s;
}