コード例 #1
0
ファイル: importer.c プロジェクト: emiddleton/sky
int sky_importer_process_actions(sky_importer *importer, bstring source,
                                 jsmntok_t *tokens, uint32_t *index)
{
    int rc;
    assert(importer != NULL);
    assert(source != NULL);
    assert(tokens != NULL);
    assert(index != NULL);

    jsmntok_t *actions_token = &tokens[*index];
    (*index)++;
    
    // Process over each action.
    int32_t i;
    for(i=0; i<actions_token->size; i++) {
        rc = sky_importer_process_action(importer, source, tokens, index);
        check(rc == 0, "Unable to process actions import");
    }
    
    // Save action file.
    rc = sky_action_file_save(importer->table->action_file);
    check(rc == 0, "Unable to save action file");
    
    return 0;

error:
    return -1;
}
コード例 #2
0
ファイル: action_file_tests.c プロジェクト: fxstein/sky
int test_sky_action_file_save() {
    int rc;
    struct tagbstring path = bsStatic("tmp/actions");
    
    // Initialize action file.
    sky_action_file *action_file = sky_action_file_create();
    sky_action_file_set_path(action_file, &path);
    
    // Action 1
    sky_action *action1 = sky_action_create();
    action1->name = bfromcstr("foo");
    rc = sky_action_file_add_action(action_file, action1);
    mu_assert_int_equals(rc, 0);
    mu_assert_int_equals(action_file->action_count, 1);

    // Action 2
    sky_action *action2 = sky_action_create();
    action2->name = bfromcstr("this_is_a_really_long_action_name_woohoo");
    rc = sky_action_file_add_action(action_file, action2);
    mu_assert_int_equals(rc, 0);
    mu_assert_int_equals(action_file->action_count, 2);

    // Save
    rc = sky_action_file_save(action_file);
    mu_assert_int_equals(rc, 0);
    mu_assert_file("tmp/actions", "tests/fixtures/action_files/0");

    sky_action_file_free(action_file);
    return 0;
}