예제 #1
0
} END_TEST

START_TEST (test_2) {
    object *obj = object_list();
    
    fail_unless(object_list_length(obj) == 0, NULL);
    
    object *val;
    val = object_int(1);
    object_list_insert_at(obj, 0, val);
    object_free(val);
    
    fail_unless(object_list_length(obj) == 1, NULL);
    
    val = object_int(3);
    object_list_insert_at(obj, 1, val);
    object_free(val);
    
    fail_unless(object_list_length(obj) == 2, NULL);
    
    val = object_int(2);
    object_list_insert_at(obj, 1, val);
    object_free(val);
    
    fail_unless(object_list_length(obj) == 3, NULL);
    
    object *next = object_copy(obj);
    
    fail_unless(object_list_length(next) == 3, NULL);
    
    object_list_remove(obj, 0);
    fail_unless(object_list_length(obj) == 2, NULL);
    
    object_list_remove(obj, 0);
    fail_unless(object_list_length(obj) == 1, NULL);
    
    object_list_remove(obj, 0);
    fail_unless(object_list_length(obj) == 0, NULL);
    object_free(obj);
    
    obj = next;
    next = object_copy(next);
    
    object_list_remove(obj, 1);
    fail_unless(object_list_length(obj) == 2, NULL);
    object_free(obj);
    
    obj = next;
    
    object_list_remove(obj, 2);
    fail_unless(object_list_length(obj) == 2, NULL);
    object_free(obj);
    
    object_free(obj);
} END_TEST
예제 #2
0
static void
create_command_undo(Command_t *parent)
{
   CreateCommand_t *command = (CreateCommand_t*) parent;
   object_list_remove(command->list, command->obj);
   object_list_set_changed(command->list, command->changed);
}
예제 #3
0
static CmdExecuteValue_t
delete_command_execute(Command_t *parent)
{
   DeleteCommand_t *command = (DeleteCommand_t*) parent;
   command->changed = object_list_get_changed(command->list);
   command->position = object_get_position_in_list(command->obj);
   object_list_remove(command->list, command->obj);
   return CMD_APPEND;
}