/** * tests rt() */ static char * test_rt() { Logo good, b_varnum, b_inst; int ret; printf("Testing %s\n", __FUNCTION__); /* good input */ good = setup(2, "RT 20"); insert_line(good, "RT A"); /* bad varnum */ b_varnum = setup(1, "RT 2P"); /* bad instruction */ b_inst = setup(1, "LT 20"); ret = rt(good); mu_assert("error, ret != 0", ret == 0); good->counter = good->counter + 1; ret = rt(good); mu_assert("error, ret != 0", ret == 0); ret = rt(b_varnum); mu_assert("error, ret != PARSE_ERR", ret == PARSE_ERR); ret = rt(b_inst); mu_assert("error, ret != PARSE_ERR", ret == PARSE_ERR); tear_down(good); tear_down(b_varnum); tear_down(b_inst); return 0; }
/** * tests instrctlst() */ static char * test_instrctlst() { Logo good, bad1, bad2; int ret; printf("Testing %s\n", __FUNCTION__); /* a good input structure. no need for opening { as thats dealt with by mainlogo() */ good = setup(3, "FD 30"); insert_line(good, "RT 30"); insert_line(good, "}"); ret = instrctlst(good); mu_assert("error, ret != 0", ret == 0); /* a bad input structure that fails because of bad <INSTRUCTION> */ bad1 = setup(3, "BAD"); insert_line(bad1, "FDA 123"); insert_line(bad1, "}"); ret = instrctlst(bad1); mu_assert("error, ret != PARSE_ERR", ret == PARSE_ERR); /* a bad input structure that fails because of missing '}' */ bad2 = setup(3, "LT 30"); insert_line(bad2, "FD 30"); insert_line(bad2, "RT 20"); ret = instrctlst(bad2); mu_assert("error, ret != PARSE_ERR", ret == PARSE_ERR); tear_down(good); tear_down(bad1); tear_down(bad2); return 0; }
/** * tests polish() */ static char * test_polish() { Logo good, b_polish1, b_polish2, b_missing; int ret; printf("Testing %s\n", __FUNCTION__); /* good input */ good = setup(1, "A B 2 3 4 + - 8 * / * ;"); /* bad input with bad varnum */ b_polish1 = setup(1, "ABC 23 + ;"); /* bad input with bad operator */ b_polish2 = setup(1, "A B C = & ;"); /* missing semicolon */ b_missing = setup(1, "A B 3 + -"); /* test them */ ret = polish(good->lines[0], good); mu_assert("error, ret != 0", ret == 0); ret = polish(b_polish1->lines[0], b_polish1); mu_assert("error, ret != PARSE_ERR", ret == PARSE_ERR); ret = polish(b_polish2->lines[0], b_polish2); mu_assert("error, ret != PARSE_ERR", ret == PARSE_ERR); ret = polish(b_missing->lines[0], b_missing); mu_assert("error, ret != PARSE_ERR", ret == PARSE_ERR); tear_down(good); tear_down(b_polish1); tear_down(b_polish2); tear_down(b_missing); return 0; }
bool test_intersect() { bool result = true; //the first one (set_up_1()) is with new_piece_rh (int x, int y, bool small, bool horizontal) set_up_1(); for (int i = 0; i < NB_PIECES; i++) for (int j = 0; j < NB_PIECES; j++) { result = result && test_equality_bool(i == j, intersect(pieces[i], pieces[j]), "intersect"); } piece pb_piece1 = new_piece_rh(3, 3, false, false); piece pb_piece2 = new_piece_rh(3, 1, false, false); result = result && test_equality_bool(true, intersect(pieces[0], pb_piece1), "set up 1 intersect pb1"); result = result && test_equality_bool(true, intersect(pb_piece2, pb_piece1), "set up 1 intersect pb2"); tear_down(); delete_piece(pb_piece1); delete_piece(pb_piece2); //the second one (set_up_2()) is with new_piece(int x, int y, int width, int height, bool move_x, bool move_y) set_up_2(); for (int i = 0; i < NB_PIECES; i++) for (int j = 0; j < NB_PIECES; j++) { result = result && test_equality_bool(i == j, intersect(pieces[i], pieces[j]), "intersect"); } piece pb_piece3 = new_piece(3, 3, 1, 3, false, true); piece pb_piece4 = new_piece(3, 1, 1, 3, false, true); result = result && test_equality_bool(true, intersect(pieces[0], pb_piece3), "set up 2 intersect pb1"); result = result && test_equality_bool(true, intersect(pb_piece4, pb_piece3), "set up 2 intersect pb2"); tear_down(); delete_piece(pb_piece3); delete_piece(pb_piece4); return result; }
bool test_copy() { piece p = new_piece_rh(0, 0, true, true); bool result = true; //the first one (set_up_1()) is with new_piece_rh (int x, int y, bool small, bool horizontal) set_up_1(); for (int i = 0; i < NB_PIECES; i++) { copy_piece(pieces[i], p); result = result && test_equality_int(get_height(pieces[i]), get_height(p), "copy get_height"); result = result && test_equality_int(get_width(pieces[i]), get_width(p), "copy get_width"); result = result && test_equality_int(get_x(pieces[i]), get_x(p), "copy get_x"); result = result && test_equality_int(get_y(pieces[i]), get_y(p), "copy get_y"); result = result && test_equality_bool(is_horizontal(pieces[i]), is_horizontal(p), "copy is_horizontal"); result = result && test_equality_bool(can_move_x(pieces[i]), can_move_x(p), "copy can_move_x"); result = result && test_equality_bool(can_move_y(pieces[i]), can_move_y(p), "copy can_move_y"); } tear_down(); //the second one (set_up_2()) is with new_piece(int x, int y, int width, int height, bool move_x, bool move_y) set_up_2(); for (int i = 0; i < NB_PIECES; i++) { copy_piece(pieces[i], p); result = result && test_equality_int(get_height(pieces[i]), get_height(p), "copy get_height"); result = result && test_equality_int(get_width(pieces[i]), get_width(p), "copy get_width"); result = result && test_equality_int(get_x(pieces[i]), get_x(p), "copy get_x"); result = result && test_equality_int(get_y(pieces[i]), get_y(p), "copy get_y"); result = result && test_equality_bool(is_horizontal(pieces[i]), is_horizontal(p), "copy is_horizontal"); result = result && test_equality_bool(can_move_x(pieces[i]), can_move_x(p), "copy can_move_x"); result = result && test_equality_bool(can_move_y(pieces[i]), can_move_y(p), "copy can_move_y"); } tear_down(); delete_piece(p); return result; }
/** * tests parse() */ static char * test_parse() { Logo good, bad; int ret, i; printf("Testing %s\n", __FUNCTION__); /* a good input structure */ good = setup(3, "{"); insert_line(good, "FD 30"); insert_line(good, "}"); /* free good->vars as parse() makes a new one */ free(good->vars); ret = parse(good); mu_assert("error, ret != 0", ret == 0); /* the input->vars should be initialised */ for (i=0; i<VARARY_SIZE; i++) { mu_assert("good->vars[i].used != 0", good->vars[i].used == 0); mu_assert("good->vars[i].used != 0", good->vars[i].data == 0); } tear_down(good); /* a bad input structure */ bad = setup(3, "}"); insert_line(bad, "FD 30"); insert_line(bad, "}"); /* free bad->vars as parse() makes a new one */ free(bad->vars); ret = parse(bad); mu_assert("error, ret != PARSE_ERR", ret == PARSE_ERR); tear_down(bad); return 0; }
/** * tests varnum() */ static char * test_varnum() { Logo good, b_var, b_number; int ret; printf("Testing %s\n", __FUNCTION__); /* good input */ good = setup(4, "20"); insert_line(good, "H"); /* decimals and negative numbers */ insert_line(good, "2.5"); insert_line(good, "-2.5"); /* bad input */ b_var = setup(1, "AB"); b_number = setup(1, "209x"); /* test them */ ret = varnum(good->lines[0], good); mu_assert("error, ret != 0", ret == 0); ret = varnum(good->lines[1], good); mu_assert("error, ret != 0", ret == 0); ret = varnum(good->lines[2], good); mu_assert("error, ret != 0", ret == 0); ret = varnum(good->lines[3], good); mu_assert("error, ret != 0", ret == 0); ret = varnum(b_var->lines[0], b_var); mu_assert("error, ret != PARSE_ERR", ret == PARSE_ERR); ret = varnum(b_number->lines[0], b_number); mu_assert("error, ret != PARSE_ERR", ret == PARSE_ERR); tear_down(good); tear_down(b_var); tear_down(b_number); return 0; }
/** * tests fd() as well as chk_inst() */ static char * test_fd() { Logo good, b_varnum, b_inst, b_chk_inst; char *buffer; int ret; printf("Testing %s\n", __FUNCTION__); /* good input */ good = setup(2, "FD 20"); insert_line(good, "FD A"); /* bad varnum */ b_varnum = setup(1, "FD AB"); /* bad instruction */ b_inst = setup(1, "RT 20"); /* test chk_inst error checking */ b_chk_inst = setup(1, "FD"); ret = fd(good); mu_assert("error, ret != 0", ret == 0); good->counter = good->counter + 1; /* set the variable */ set_var("A", good->vars, 30.0); ret = fd(good); mu_assert("error, ret != 0", ret == 0); tear_down(good); /* expect postscript and test the output file */ char str[STR_LENGTH] = ""; char tmp[LINE_LENGTH]; sprintf(tmp, "%.2f 0 rlineto\n", 20 * LOGO2PS_FACTOR); strcat(str, tmp); sprintf(tmp, "%.2f 0 rlineto\n", 30 * LOGO2PS_FACTOR); strcat(str, tmp); buffer = get_content(TEST_OUT); mu_assert("error, TEST_OUT is not as expected", strcmp(buffer, str) == 0); free(buffer); ret = fd(b_varnum); mu_assert("error, ret != PARSE_ERR", ret == PARSE_ERR); tear_down(b_varnum); ret = fd(b_inst); mu_assert("error, ret != PARSE_ERR", ret == PARSE_ERR); tear_down(b_inst); ret = fd(b_chk_inst); mu_assert("error, ret != PARSE_ERR", ret == PARSE_ERR); tear_down(b_chk_inst); return 0; }
/** * tests varnum() */ static char * test_varnum() { Logo good, b_var, b_number; int ret; float op; printf("Testing %s\n", __FUNCTION__); /* good input */ good = setup(4, "20"); /* decimals and negative numbers */ insert_line(good, "2.5"); insert_line(good, "-2.5"); insert_line(good, "A"); /* bad input */ b_var = setup(3, "AB"); /* non existant var */ insert_line(b_var, "C"); insert_line(b_var, "3-"); b_number = setup(1, "209x"); /* test them */ ret = varnum(good->lines[0], good, &op); mu_assert("error, ret != 0", ret == 0); mu_assert("error, op not set correctly", op == 20); ret = varnum(good->lines[1], good, &op); mu_assert("error, ret != 0", ret == 0); mu_assert("error, op not set correctly", op == 2.5); ret = varnum(good->lines[2], good, &op); mu_assert("error, ret != 0", ret == 0); mu_assert("error, op not set correctly", op == -2.5); /* set the var A */ set_var("A", good->vars, 20); ret = varnum(good->lines[3], good, &op); mu_assert("error, ret != 0", ret == 0); mu_assert("error, op not set correctly", op == 20); ret = varnum(b_var->lines[0], b_var, &op); mu_assert("error, ret != PARSE_ERR", ret == PARSE_ERR); ret = varnum(b_var->lines[1], b_var, &op); mu_assert("error, ret != VAR_ERR", ret == VAR_ERR); ret = varnum(b_var->lines[2], b_var, &op); mu_assert("error, ret != VAR_ERR", ret == PARSE_ERR); ret = varnum(b_number->lines[0], b_number, &op); mu_assert("error, ret != PARSE_ERR", ret == PARSE_ERR); tear_down(good); tear_down(b_var); tear_down(b_number); return 0; }
/** *test put long keys into Btree */ TEST(KeyBtree_Put_Char_Test, put_07_longkey) { set_up(); int32_t iRet = 0; int32_t iValue = 0; int32_t iSuccess = 0; int32_t iFail = 0; charBtree btree(sizeof(char*)); for (int32_t iLoop = 0; iLoop < TEST_COUNT; iLoop ++) { /* malloc */ pstrKey[ iLoop ] = (char *)malloc( TEST_SIZE ); /* Set the flag for free */ iFlag = 1; /* Create the key */ get_next_random_value( iValue ); sprintf( pstrKey[ iLoop ], "%08x", iValue ); /* Put the key-value pair */ iRet = btree.put( pstrKey[ iLoop ], iLoop + 1 ); if (iRet == ERROR_CODE_OK) { iSuccess ++; } else { iFail ++; } } EXPECT_EQ( iFail, 0 ); EXPECT_EQ( iSuccess, btree.get_object_count() ); tear_down(); btree.clear(); }
static void run_test(int expected_ret, void setup_asfds_callback(struct asfd *sfd, struct asfd *in, struct asfd *out)) { struct async *as; struct asfd *sfd; struct asfd *in; struct asfd *out; as=setup(); sfd=asfd_mock_setup(&areads, &awrites); in=asfd_mock_setup(&ireads, &iwrites); out=asfd_mock_setup(&oreads, &owrites); fail_unless((sfd->desc=strdup_w("main_socket", __func__))!=NULL); fail_unless((in->desc=strdup_w("stdin", __func__))!=NULL); fail_unless((out->desc=strdup_w("stdout", __func__))!=NULL); as->asfd_add(as, sfd); as->asfd_add(as, in); as->asfd_add(as, out); as->read_write=async_rw_both; setup_asfds_callback(sfd, in, out); fail_unless(monitor_client_main_loop(as)==expected_ret); asfd_free(&in); asfd_free(&out); asfd_free(&sfd); asfd_mock_teardown(&areads, &awrites); asfd_mock_teardown(&ireads, &iwrites); asfd_mock_teardown(&oreads, &owrites); tear_down(&as); }
bool test_move() { bool result = true; piece p = new_piece_rh(0, 0, true, true); set_up(); for (int dist = 1; dist < NB_PIECES; dist++) for (int i=0; i < NB_PIECES; i++) { copy_piece(pieces[i],p); move_piece(p, LEFT, dist); if (is_horizontal(pieces[i])) result = result && test_equality_int(get_x(pieces[i])-dist,get_x(p),"move LEFT"); else result = result && test_equality_int(get_x(pieces[i]),get_x(p),"move LEFT"); copy_piece(pieces[i],p); move_piece(p, RIGHT, dist); if (is_horizontal(pieces[i])) result = result && test_equality_int(get_x(pieces[i])+dist,get_x(p),"move RIGHT"); else result = result && test_equality_int(get_x(pieces[i]),get_x(p),"move RIGHT"); copy_piece(pieces[i],p); move_piece(p, UP, dist); if (!is_horizontal(pieces[i])) result = result && test_equality_int(get_y(pieces[i])+dist,get_y(p),"move UP"); else result = result && test_equality_int(get_y(pieces[i]),get_y(p),"move UP"); copy_piece(pieces[i],p); move_piece(p, DOWN, dist); if (!is_horizontal(pieces[i])) result = result && test_equality_int(get_y(pieces[i])-dist,get_y(p),"move DOWN"); else result = result && test_equality_int(get_y(pieces[i]),get_y(p),"move DOWN"); } tear_down(); delete_piece(p); return result; }
static void do_test_cstat_set_backup_list(enum protocol protocol) { struct cstat *cstat; cstat=setup_cstat(CNAME, protocol); ck_assert_str_eq(CLIENTCONFDIR "/" CNAME, cstat->conffile); cstat->permitted=1; fail_unless(recursive_delete(BASE)==0); build_storage_dirs((struct sdirs *)cstat->sdirs, sd123, ARR_LEN(sd123)); fail_unless(!cstat_set_backup_list(cstat)); fail_unless(cstat->bu!=NULL); fail_unless(recursive_delete(BASE)==0); build_storage_dirs((struct sdirs *)cstat->sdirs, sd13, ARR_LEN(sd13)); fail_unless(!cstat_set_backup_list(cstat)); fail_unless(cstat->bu!=NULL); fail_unless(recursive_delete(BASE)==0); build_storage_dirs((struct sdirs *)cstat->sdirs, sd12345, ARR_LEN(sd12345)); fail_unless(!cstat_set_backup_list(cstat)); fail_unless(cstat->bu!=NULL); cstat->permitted=0; fail_unless(!cstat_set_backup_list(cstat)); fail_unless(cstat->bu==NULL); tear_down(&cstat); }
END_TEST START_TEST(test_protocol1_restore_file_not_found) { struct asfd *asfd; struct sbuf *sb; struct conf **confs; struct cntr *cntr; clean(); confs=setup_confs(); sb=setup_sbuf("/path", "/datapth", NULL, 0); asfd=asfd_mock_setup(&areads, &awrites); setup_not_found_message(asfd, sb); // Passing in NULL bu means that the file will not be found, as there // are no backups to traverse. // The function should return 0, so that the calling function // can continue. fail_unless(!restore_file( asfd, NULL /*bu*/, sb, ACTION_RESTORE, NULL /*sdirs*/, confs )); cntr=get_cntr(confs); fail_unless(cntr->ent[CMD_WARNING]->count==1); tear_down(&sb, NULL, &confs, &asfd); }
/* * Run through one frame drawing cycle */ void SdlApp::step() { if (!running) return; draw_scene(); SDL_Event event; while ( SDL_PollEvent( &event ) ) { switch( event.type ) { case SDL_ACTIVEEVENT: //TODO: handle focus change break; case SDL_KEYDOWN: /* handle key presses */ handle_key_press( &event.key.keysym ); break; case SDL_QUIT: /* handle quit requests */ tear_down(); break; default: break; } } }
END_TEST static void do_md5sum_test(const char *endfile, int warnings, void setup_callback(struct asfd *asfd, struct sbuf *sb)) { struct asfd *asfd; struct cntr *cntr; struct sbuf *sb; const char *path="somepath"; const char *datapth="/datapth"; const char *best=BASE "/existent"; clean(); cntr=setup_cntr(); sb=setup_sbuf(path, datapth, endfile, 0/*compression*/); build_file(best, "blah"); asfd=asfd_mock_setup(&areads, &awrites); setup_callback(asfd, sb); // Returns 0 so that the parent process continues. fail_unless(!verify_file(asfd, sb, 0 /*patches*/, best, cntr)); fail_unless(cntr->ent[CMD_WARNING]->count==warnings); tear_down(&sb, &cntr, NULL, &asfd); }
END_TEST static void test_manifest_tell_seek(enum protocol protocol, int phase) { struct slist *slist; struct manio *manio; struct sbuf *sb=NULL; man_off_t *offset=NULL; int entries=1000; prng_init(0); base64_init(); hexmap_init(); recursive_delete(path); slist=build_manifest(path, protocol, entries, phase); fail_unless(slist!=NULL); sb=slist->head; fail_unless((manio=do_manio_open(path, "rb", protocol, phase))!=NULL); read_manifest(&sb, manio, 0, entries/2, protocol, phase); fail_unless((offset=manio_tell(manio))!=NULL); fail_unless(sb!=NULL); fail_unless(!manio_close(&manio)); fail_unless((manio=do_manio_open(path, "rb", protocol, phase))!=NULL); fail_unless(!manio_seek(manio, offset)); read_manifest(&sb, manio, entries/2, entries, protocol, phase); fail_unless(sb==NULL); fail_unless(!manio_close(&manio)); fail_unless(!manio); slist_free(&slist); man_off_t_free(&offset); tear_down(); }
static void do_init_test(int data_len) { rs_filebuf_t *fb; fb=setup(NULL, data_len); fail_unless(fb->do_known_byte_count==data_len); tear_down(&fb); }
/** * tests set() */ static char * test_set() { Logo good, b_num_args, b_var, b_syntax1, b_syntax2, b_polish1, b_polish2, b_polish3; int ret; float a, num; printf("Testing %s\n", __FUNCTION__); /* good input */ good = setup(1, "SET A := 3 2 9 8 + - * ;"); /* bad number of args */ b_num_args = setup(1, "SET A :="); /* bad var input */ b_var = setup(1, "SET AB := 8 ;"); /* bad syntax (bad equal sign) */ b_syntax1 = setup(1, "SET A = 8 ;"); /* bad syntax (bad instruction) */ b_syntax2 = setup(1, "DO A := 10 ;"); /* bad polish (will be tested more thoroughly later) */ b_polish1 = setup(1, "SET A := 9 8 & ;"); /* unbalanced polish. parser allows this but the interpreter should flag it as an error */ b_polish2 = setup(1, "SET A := 9 8 8 7 + - ;"); /* a polish only has a ; */ b_polish3 = setup(1, "SET A := ;"); /* test them all */ ret = set(good); mu_assert("error, ret != 0", ret == 0); /* this should have set A, calculate the above polish expression */ num = 3 * (2 - (9 + 8)); /* get the value in A */ get_var("A", good->vars, &a); mu_assert("error, A != polish expression", a == num); ret = set(b_num_args); mu_assert("error, ret != PARSE_ERR", ret == PARSE_ERR); ret = set(b_var); mu_assert("error, ret != PARSE_ERR", ret == PARSE_ERR); ret = set(b_syntax1); mu_assert("error, ret != PARSE_ERR", ret == PARSE_ERR); ret = set(b_syntax2); mu_assert("error, ret != PARSE_ERR", ret == PARSE_ERR); ret = set(b_polish1); mu_assert("error, ret != PARSE_ERR", ret == PARSE_ERR); ret = set(b_polish2); mu_assert("error, ret != POL_ERR", ret == POL_ERR); ret = set(b_polish3); mu_assert("error, ret != POL_ERR", ret == POL_ERR); tear_down(good); tear_down(b_num_args); tear_down(b_var); tear_down(b_syntax1); tear_down(b_syntax2); tear_down(b_polish1); tear_down(b_polish2); tear_down(b_polish3); return 0; }
static void test_cstat_set_run_status_idle(enum protocol protocol) { struct cstat *cstat; cstat=set_run_status_setup(protocol, 1 /*permitted*/); cstat_set_run_status(cstat); fail_unless(cstat->run_status==RUN_STATUS_IDLE); tear_down(&cstat); }
static void test_cstat_set_run_status_not_permitted(enum protocol protocol) { struct cstat *cstat; cstat=set_run_status_setup(protocol, 0 /*not permitted*/); cstat_set_run_status(cstat); fail_unless(cstat->run_status==RUN_STATUS_UNSET); tear_down(&cstat); }
int main(int argc, char *argv[]) { initialize(argc, argv); handle_events(); tear_down(); return 0; }
END_TEST START_TEST(test_json_send_empty) { struct asfd *asfd; asfd=asfd_setup(BASE "/empty"); fail_unless(!json_send(asfd, NULL, NULL, NULL, NULL, NULL, 0/*cache*/)); tear_down(&asfd); }
END_TEST START_TEST(test_protocol1_rs_infilebuf_fill) { rs_buffers_t rsbuf; rs_filebuf_t *fb; fb=setup(&rsbuf, 0 /*data_len*/); fail_unless(rs_infilebuf_fill(NULL /*job*/, &rsbuf, fb)==RS_DONE); tear_down(&fb); }
static void test_cstat_set_run_status_client_crashed(enum protocol protocol) { struct cstat *cstat; cstat=set_run_status_setup(protocol, 1 /*permitted*/); fail_unless(recursive_delete(BASE)==0); build_storage_dirs((struct sdirs *)cstat->sdirs, sd1w, ARR_LEN(sd1w)); cstat_set_run_status(cstat); fail_unless(cstat->run_status==RUN_STATUS_CLIENT_CRASHED); tear_down(&cstat); }
static int test_default_cipherlist_explicit(void) { SETUP_CIPHERLIST_TEST_FIXTURE(); if (fixture == NULL) return 0; if (!TEST_true(SSL_CTX_set_cipher_list(fixture->server, "DEFAULT")) || !TEST_true(SSL_CTX_set_cipher_list(fixture->client, "DEFAULT"))) tear_down(fixture); EXECUTE_CIPHERLIST_TEST(); return result; }
/** * tests instruction() */ static char * test_instruction() { Logo fd, lt, rt, set, dologo, bad1, bad2, bad3; int ret; printf("Testing %s\n", __FUNCTION__); /* create Logo handles for all 5 instructions */ fd = setup(1, "FD 30"); lt = setup(1, "LT 30"); rt = setup(1, "RT 30"); set = setup(1, "SET A := 30 ;"); dologo = setup(3, "DO A FROM 1 TO 5 {"); insert_line(dologo, "FD 20"); insert_line(dologo, "}"); /* test them all */ ret = instruction(fd); mu_assert("error, ret != 0", ret == 0); ret = instruction(rt); mu_assert("error, ret != 0", ret == 0); ret = instruction(lt); mu_assert("error, ret != 0", ret == 0); ret = instruction(set); mu_assert("error, ret != 0", ret == 0); ret = instruction(dologo); mu_assert("error, ret != 0", ret == 0); bad1 = setup(1, "DOESNOTEXIST 123"); ret = instruction(bad1); mu_assert("error, ret != PARSE_ERR", ret == PARSE_ERR); /* test that if any of the <INSTRUCTION> such as fd are malformed, ret == PARSE_ERR */ bad2 = setup(1, "FD abc990"); ret = instruction(bad2); mu_assert("error, ret != PARSE_ERR", ret == PARSE_ERR); /* tests empty string */ bad3 = setup(1, ""); ret = instruction(bad3); mu_assert("error, ret != PARSE_ERR", ret == PARSE_ERR); tear_down(fd); tear_down(lt); tear_down(rt); tear_down(set); tear_down(dologo); tear_down(bad1); tear_down(bad2); tear_down(bad3); return 0; }
END_TEST START_TEST(test_win_alloc_error) { struct rconf rconf; struct win *win; alloc_check_init(); rconf_init(&rconf); alloc_errors=1; fail_unless((win=win_alloc(&rconf))==NULL); tear_down(); }
END_TEST START_TEST(test_protocol1_rs_infilebuf_fill_error3) { rs_buffers_t rsbuf; rs_filebuf_t *fb; fb=setup(&rsbuf, 0 /*data_len*/); // buf->next_in > fb->buf + fb->buf_len rsbuf.next_in=fb->buf+fb->buf_len+1; fail_unless(rs_infilebuf_fill(NULL /*job*/, &rsbuf, fb)==RS_IO_ERROR); tear_down(&fb); }
END_TEST START_TEST(test_protocol1_rs_outfilebuf_drain_error2) { rs_buffers_t rsbuf; rs_filebuf_t *fb; fb=setup(&rsbuf, 0 /*data_len*/); rsbuf.next_out=fb->buf-1; // buf->next_out < fb->buf rsbuf.avail_out=1; fail_unless(rs_outfilebuf_drain(NULL /*job*/, &rsbuf, fb)==RS_IO_ERROR); tear_down(&fb); }