示例#1
0
END_TEST

START_TEST (test_select_command_15)
{
    struct command command_data;

    command_data.id = 0;
    my_strcpy( command_data.name, "play", MAX_TOKEN_LENGTH );
    my_strcpy( command_data.gtp_argv[0], "black", MAX_TOKEN_LENGTH );
    my_strcpy( command_data.gtp_argv[1], "d4", MAX_TOKEN_LENGTH );
    command_data.gtp_argc = 2;

    init_board(BOARD_SIZE_DEFAULT);
    init_known_commands();
    select_command(&command_data);
    fail_unless( get_output_error() == false, "play command identified" );

    command_data.id = 0;
    my_strcpy( command_data.name, "undo", MAX_TOKEN_LENGTH );
    command_data.gtp_argc = 0;

    select_command(&command_data);
    fail_unless( get_output_error() == false, "undo command identified" );

    free_board();
}
示例#2
0
文件: gti.c 项目: rwos/gti
int main(int argc, char **argv)
{
    int i;
    char *git_path;
    char *tmp;
    unsigned int gti_speed;
    draw_fn_t draw_fn;

    tmp = getenv("GTI_SPEED");
    if (!tmp || sscanf(tmp, "%u", &gti_speed) != 1) {
        gti_speed = GTI_SPEED;
    }
    open_term();
    TERM_WIDTH = term_width();
    FRAME_TIME = 1000 * 1000 * 10 / (gti_speed + TERM_WIDTH + 1);

    draw_fn = select_command(argc, argv);
    init_space();
    for (i = -20; i < TERM_WIDTH; i++) {
        draw_fn(i);
        clear_car(i);
    }
    move_to_top();
    fflush(TERM_FH);

    git_path = getenv("GIT");
    if (git_path) {
        execv(git_path, argv);
    } else {
        execvp(GIT_NAME, argv);
    }
    /* error in exec if we land here */
    perror(GIT_NAME);
    return 1;
}
示例#3
0
END_TEST

START_TEST (test_select_command_3)
{
    struct command command_data;

    command_data.id = 0;
    my_strcpy( command_data.name, "name", MAX_TOKEN_LENGTH );

    init_known_commands();
    select_command(&command_data);
    fail_unless( get_output_error() == false, "name command identified" );
}
示例#4
0
END_TEST

START_TEST (test_select_command_24)
{
    struct command command_data;

    command_data.id = 0;
    my_strcpy( command_data.name, "level", MAX_TOKEN_LENGTH );
    command_data.gtp_argc = 0;

    init_known_commands();
    select_command(&command_data);
    fail_unless( get_output_error() == false, "level without number" );
}
示例#5
0
END_TEST

START_TEST (test_select_command_14)
{
    struct command command_data;

    command_data.id = 0;
    my_strcpy( command_data.name, "protocol_version", MAX_TOKEN_LENGTH );
    command_data.gtp_argc = 0;

    init_known_commands();
    select_command(&command_data);
    fail_unless( get_output_error() == false, "protocol_version command identified" );

}
示例#6
0
END_TEST

START_TEST (test_select_command_18)
{
    struct command command_data;

    command_data.id = 0;
    my_strcpy( command_data.name, "loadsgf", MAX_TOKEN_LENGTH );
    command_data.gtp_argc = 0;

    init_known_commands();
    select_command(&command_data);
    fail_unless( get_output_error() == true, "loadsgf without arg filename" );

}
示例#7
0
END_TEST

START_TEST (test_select_command_4)
{
    struct command command_data;

    command_data.id = 0;
    my_strcpy( command_data.name, "boardsize", MAX_TOKEN_LENGTH );
    my_strcpy( command_data.gtp_argv[0], "2", MAX_TOKEN_LENGTH );
    command_data.gtp_argc = 1;

    init_known_commands();
    select_command(&command_data);
    fail_unless( get_output_error() == false, "boardsize command identified" );
}
示例#8
0
END_TEST

START_TEST (test_select_command_5)
{
    struct command command_data;

    command_data.id = 0;
    my_strcpy( command_data.name, "boardsize", MAX_TOKEN_LENGTH );
    my_strcpy( command_data.gtp_argv[0], "0", MAX_TOKEN_LENGTH );
    command_data.gtp_argc = 1;

    init_known_commands();
    select_command(&command_data);
    fail_unless( get_output_error() == true, "boardsize with invalid size" );
}
示例#9
0
END_TEST

START_TEST (test_select_command_7)
{
    struct command command_data;

    command_data.id = 0;
    my_strcpy( command_data.name, "clear_board", MAX_TOKEN_LENGTH );
    command_data.gtp_argc = 0;

    init_board(2);
    init_known_commands();
    select_command(&command_data);
    fail_unless( get_output_error() == false, "clear_board command identified" );
}
示例#10
0
END_TEST

START_TEST (test_select_command_13)
{
    struct command command_data;

    command_data.id = 0;
    my_strcpy( command_data.name, "known_command", MAX_TOKEN_LENGTH );
    my_strcpy( command_data.gtp_argv[0], "not_implemented", MAX_TOKEN_LENGTH );
    command_data.gtp_argc = 1;

    init_known_commands();
    select_command(&command_data);
    fail_unless( get_output_error() == false, "known_command with unknown command" );

}
示例#11
0
END_TEST

START_TEST (test_select_command_23)
{
    struct command command_data;
    char filename[] = "game2.sgf";
    //FILE *sgf_file;

    command_data.id = 0;
    my_strcpy( command_data.name, "loadsgf", MAX_TOKEN_LENGTH );
    my_strcpy( command_data.gtp_argv[0], filename, MAX_TOKEN_LENGTH );
    command_data.gtp_argc = 1;

    init_known_commands();
    select_command(&command_data);
    fail_unless( get_output_error() == false, "loadsgf with valid filename, sgf_add" );
}
示例#12
0
END_TEST

START_TEST (test_select_command_16)
{
    struct command command_data;

    command_data.id = 0;
    my_strcpy( command_data.name, "showboard", MAX_TOKEN_LENGTH );
    command_data.gtp_argc = 0;

    init_board(BOARD_SIZE_DEFAULT);
    init_known_commands();
    select_command(&command_data);
    fail_unless( get_output_error() == false, "showboard command identified" );

    free_board();
}
示例#13
0
END_TEST

START_TEST (test_fixed_handicap_1)
{
    struct command command_data;

    command_data.id = 0;
    my_strcpy( command_data.name, "fixed_handicap", MAX_TOKEN_LENGTH );
    my_strcpy( command_data.gtp_argv[0], "9", MAX_TOKEN_LENGTH );
    command_data.gtp_argc = 1;

    init_board(19);
    init_known_commands();
    select_command(&command_data);
    fail_unless( get_output_error() == false, "fixed_handicap 9 set" );

    free_board();
}
示例#14
0
END_TEST

START_TEST (test_select_command_12)
{
    struct command command_data;

    command_data.id = 0;
    my_strcpy( command_data.name, "known_command", MAX_TOKEN_LENGTH );
    my_strcpy( command_data.gtp_argv[0], "name", MAX_TOKEN_LENGTH );
    my_strcpy( command_data.gtp_argv[0], "name", MAX_TOKEN_LENGTH );
    my_strcpy( command_data.gtp_argv[0], "name", MAX_TOKEN_LENGTH );
    command_data.gtp_argc = 3;

    init_known_commands();
    select_command(&command_data);
    fail_unless( get_output_error() == true, "known_command with too many args is error" );

}
示例#15
0
END_TEST

START_TEST (test_select_command_9)
{
    struct command command_data;

    init_board(BOARD_SIZE_MIN);
    init_known_commands();
    init_brains();

    command_data.id = 0;
    my_strcpy( command_data.name, "genmove", MAX_TOKEN_LENGTH );
    my_strcpy( command_data.gtp_argv[0], "BLACK", MAX_TOKEN_LENGTH );
    command_data.gtp_argc = 1;

    select_command(&command_data);
    fail_unless( get_output_error() == false, "genmove command identified" );

    free_board();
}
示例#16
0
END_TEST

START_TEST (test_select_command_20)
{
    struct command command_data;
    char filename[] = "testfile.sgf";
    FILE *sgf_file;

    sgf_file = fopen( filename, "w" );

    command_data.id = 0;
    my_strcpy( command_data.name, "loadsgf", MAX_TOKEN_LENGTH );
    my_strcpy( command_data.gtp_argv[0], filename, MAX_TOKEN_LENGTH );
    command_data.gtp_argc = 1;
    init_known_commands();
    select_command(&command_data);
    fail_unless( get_output_error() == true, "loadsgf with zero size file" );

    fclose(sgf_file);
    remove(filename);
}
示例#17
0
END_TEST

START_TEST (test_select_command_22)
{
    struct command command_data;
    //char filename[] = "testfile.sgf";
    char filename[] = "game1.sgf";
    //FILE *sgf_file;

    //sgf_file = fopen( filename, "w" );

    command_data.id = 0;
    my_strcpy( command_data.name, "loadsgf", MAX_TOKEN_LENGTH );
    my_strcpy( command_data.gtp_argv[0], filename, MAX_TOKEN_LENGTH );
    my_strcpy( command_data.gtp_argv[1], "10", MAX_TOKEN_LENGTH );
    command_data.gtp_argc = 2;

    init_known_commands();
    select_command(&command_data);
    fail_unless( get_output_error() == false, "loadsgf with valid filename, valid move_number" );

    //fclose(sgf_file);
    //remove(filename);
}