Exemplo n.º 1
0
void init_robot(struct robot *bot){

	rs_init(&bot->rs);
   
    cs_init(&bot->cs_a);
    cs_init(&bot->cs_d);

    quadramp_init(&bot->qr_a);
    quadramp_init(&bot->qr_d);

    pid_init(&bot->pid_a);
    pid_init(&bot->pid_d);

   position_init(&bot->posr); //nous
   
//	bot->EVENT_DO_CS =1;
	bot->events = EVENT_DO_CS | EVENT_DO_POS;
	
    quadramp_init(&bot->qr_a);
    quadramp_init(&bot->qr_d);
	
	#ifdef UART_VERBOSE
	UART_CPutString("\r\n init robot structures : [OK]");
	#endif
}
Exemplo n.º 2
0
// Check every op manipulates the stack correctly
TEST op_stack_size() {
    for (size_t i = 0; i < E_OP__LENGTH; i++) {
        const tele_op_t *op = tele_ops[i];

        if (op->get != NULL) {
            scene_state_t ss = {};  // initalise to empty
                                    // (needs dedicated initaliser)
            exec_state_t es;
            es_init(&es);
            es_push(&es);
            es_variables(&es)->script_number = 1;
            command_state_t cs;
            cs_init(&cs);

            // add params to stack (plus an extra 2, to check that too many
            // values aren't removed, warning: note the maximum stack size in
            // state.h)
            const int16_t stack_extra = 2;
            for (int j = 0; j < op->params + stack_extra; j++) cs_push(&cs, 0);

            // execute get
            op->get(op->data, &ss, &es, &cs);

            // check that the stack has the correct number of items in it
            if (op->returns) {
                ASSERT_EQm(op->name, cs_stack_size(&cs), stack_extra + 1);
            }
            else {
                ASSERT_EQm(op->name, cs_stack_size(&cs), stack_extra);
            }
        }

        if (op->set != NULL) {
            scene_state_t ss = {};  // initalise to empty
                                    // (needs dedicated initaliser)
            exec_state_t es;
            es_init(&es);
            command_state_t cs;
            cs_init(&cs);

            // add params to stack (plus an extra 2, to check that too many
            // values aren't removed, warning: note the maximum stack size in
            // state.h)
            // set functions require an extra value on the stack
            const int16_t stack_extra = 2;
            for (int j = 0; j < op->params + stack_extra + 1; j++)
                cs_push(&cs, 0);

            // execute get
            op->set(op->data, &ss, &es, &cs);

            // check that the stack has the correct number of items in it
            ASSERT_EQm(op->name, cs_stack_size(&cs), stack_extra);
        }
    }
    PASS();
}
Exemplo n.º 3
0
void test_create_message(void)

{

 cs_init();



 char * dummy = "sample_text";

 cs * new_message;



 new_message = create_message(dummy);



 UnityAssertEqualNumber((_U_SINT)((0)), (_U_SINT)((strcmp(new_message->message,dummy))), (((void *)0)), (_U_UINT)35, UNITY_DISPLAY_STYLE_INT);

 UnityAssertEqualNumber((_U_SINT)((1)), (_U_SINT)((new_message->id)), (((void *)0)), (_U_UINT)36, UNITY_DISPLAY_STYLE_INT);

 UnityAssertEqualNumber((_U_SINT)((((void *)0))), (_U_SINT)((new_message->next)), (((void *)0)), (_U_UINT)37, UNITY_DISPLAY_STYLE_INT);

}
Exemplo n.º 4
0
CUT_EXPORT void test_csint(void)
{
    cs_init();
    CSint *vint = CSINT(0);
    cut_assert_not_null(vint);

    vint = CSINT(-1);
    cut_assert_not_null(vint);

    vint = CSINT(1);
    cut_assert_not_null(vint);

    vint = CSINT(INT_MIN);
    cut_assert_not_null(vint);

    vint = CSINT(INT_MAX);
    cut_assert_not_null(vint);

    /* overflow */
    vint = CSINT(INT_MAX+1);
    cut_assert_not_null(vint);

    vint = CSINT(INT_MIN-1);
    cut_assert_not_null(vint);
}
Exemplo n.º 5
0
Arquivo: main.c Projeto: ahma88/magro
void savesrc(char* templatedir, char* csfname, char* outfname, HDF* hdf)
{
	CSPARSE* parse;
	NEOERR* err;
	FILE* fp;

	nerr_init();

	chdir(templatedir);
	printf("reading %s ... ", csfname);
    err = cs_init(&parse, hdf);
    if( nerr_match(err, NERR_PASS) ) { printf("NG\n"); nerr_log_error(err); exit(41); } 
	err = cs_parse_file(parse, csfname);
    if( nerr_match(err, NERR_PASS) ) { printf("NG\n"); nerr_log_error(err); exit(42); } 
	printf("OK\n");

	chdir(boot_path);
	chdir(CODEGEN_DIRNAME);
	printf("writing %s ... ", outfname);
	fp = fopen(outfname, "w");
    if( fp != NULL )
	{
		err = cs_render(parse, (void*)fp, render);
		fclose(fp);
    	if( nerr_match(err, NERR_PASS) ) { printf("NG\n"); exit(43); } 
		printf("OK\n");
	}else{
		printf("can't open file");
	}
    cs_destroy(&parse);
}
Exemplo n.º 6
0
CUT_EXPORT void test_cs_getMax(void)
{
    cs_init();
    CSint *vint = NULL;

    vint = CSINT(0);
    cut_assert_equal_int(0, cs_getMax(vint));

    vint = CSINT(INT_MIN);
    cut_assert_equal_int(INT_MIN, cs_getMax(vint));

    vint = CSINT(INT_MAX);
    cut_assert_equal_int(INT_MAX, cs_getMax(vint));

    /* overflow */
    vint = CSINT(INT_MIN-1);
    cut_assert_equal_int(INT_MAX, cs_getMax(vint));

    /* overflow */
    vint = CSINT(INT_MAX+1);
    cut_assert_equal_int(INT_MIN, cs_getMax(vint));

    /**/
    vint = cs_createCSint(0, 10);
    
}
/* ************************************************** */
void tx(call_t *c, packet_t *packet) {
    struct nodedata *nodedata = get_node_private_data(c);
    array_t *down = get_entity_bindings_down(c);
    int i = down->size;
    
    /* radio sleep */
    if (nodedata->sleep) {
        packet_dealloc(packet);
        return;
    }

    /* radio activity */
    cs_init(c);
    nodedata->tx_busy = packet->id;

    /* log tx */
    PRINT_REPLAY("radio-tx0 %"PRId64" %d 50\n", get_time(), c->node);

    /* transmit to antenna */
    while (i--) {
        packet_t *packet_down;
        
        if (i > 0) {
            packet_down = packet_clone(packet);         
        } else {
            packet_down = packet;
        }
        c->from = down->elts[i];
        MEDIA_TX(c, packet_down);
    }

    return;
}
Exemplo n.º 8
0
// Check every mod manipulates the stack correctly
TEST mod_stack_size() {
    for (size_t i = 0; i < E_MOD__LENGTH; i++) {
        const tele_mod_t *mod = tele_mods[i];

        scene_state_t ss = {};  // initalise to empty
                                // (needs dedicated initaliser)
        exec_state_t es;
        es_init(&es);
        command_state_t cs;
        cs_init(&cs);

        // add params to stack (plus an extra 2, to check that too many
        // values aren't removed, warning: note the maximum stack size in
        // state.h)
        const int16_t stack_extra = 2;
        for (int j = 0; j < mod->params + stack_extra; j++) cs_push(&cs, 0);

        // execute func
        const tele_command_t sub_command = { .length = 1,
                                             .separator = 0,
                                             .data = { { .tag = OP,
                                                         .value = E_OP_A } } };
        mod->func(&ss, &es, &cs, &sub_command);

        // check that the stack has the correct number of items in it
        ASSERT_EQm(mod->name, cs_stack_size(&cs), stack_extra);
    }
Exemplo n.º 9
0
void test_add_message(void){



 cs*aux;



 cs_init();



 char * dummy1 = "sample_text_one";

 char * dummy2 = "sample_text_two";

 char * dummy3 = "CRK2X13xXDJl88bgt25l8UUIOTY5gWZVopxuE5FY4ifmK88vWlk3ri8eSenii5B7hP0qOfPa3eONPA65f8kpakXn9r56kN40s8lzQYiKvQZXF8g3ADRGpjPD7QYlxJQKOi4M1iokBGj1wAlBsBbiueX1L3vvTpNpEtJT1WWCtLjOQhWsrPzuS4ir0u7JpHEjFNyGJ9j4NpYRBNavpWbATMCiucJ4AIPOe7x3hwBEAWcMO2uxRkmh041vmYgNbPmcS8CFf1hJc3JJsgLqAjSgaRABytG8c1714JkumAXyO79fwxMquHC8tEe5eTje0ulnezpY6xuzJQgkpzGJIxwt5pX7sJ5gRomLR0WbRC9osgCHtxVn6ZCeppjr6MpUFXxZe6Cm84kDALqrRkogIDxjrEUt6u13TOzqX57z60ancHyGGVHxNV3vujuJPrhENzWm8P3Pr4MxqRUMffR7PW3y3t2vNawXWAERwNRfgjpI9xYvJU7FViEzZ9gHEePXR5bC177vth1bgAGH2z2vxrwzTB65goZ02wOcwV5IivbgOTt0OiW2b5DqMJUzhiHQ9Z1yMYpj01YED0zYRhrnI24WYWpWGbUFxhhBLw8j2mnqb7HnJMh5AYggk7aISWICSGVm7k5NfxKRx8KEvnxnyTcowRmkKo9ucAB0W8hLlBKRLaZSXiXjxpmaO0Av9PwC7PwrJcFXMahqtbjIScwwGCgpTq4UFPH3gDnXEafePkJlBRPKE9iWQYS54W84mh12YDcc69hWILJowQL07ICZ7BVbGJPvbE4EmcHpq7OPe9Krh6qPHtoONIspHEP5hzYIr5ENNrpRyOc5iBBSEHJXokOlI9DOGBS2F5GpHOgCbAPnZe8sKlN76jMP1f1zkfwPBijUgjjDnT6P2XM358WksyXC5FIk6hmmSh1Y1LWgrg9Lygabca292sn9ayfAwhDPwJXBZlADMOKKGLkqpt5uOGoMe48X6rVIgiuRSqPRJgBrrc0DkZ59n6T24sq7AxM3oxhX";



 add_message(dummy1);

 aux = cs_list->next;



 UnityAssertEqualNumber((_U_SINT)((0)), (_U_SINT)((strcmp(aux->message,dummy1))), (((void *)0)), (_U_UINT)53, UNITY_DISPLAY_STYLE_INT);

 UnityAssertEqualNumber((_U_SINT)((1)), (_U_SINT)((aux->id)), (((void *)0)), (_U_UINT)54, UNITY_DISPLAY_STYLE_INT);

 UnityAssertEqualNumber((_U_SINT)((((void *)0))), (_U_SINT)((aux->next)), (((void *)0)), (_U_UINT)55, UNITY_DISPLAY_STYLE_INT);

 UnityAssertEqualNumber((_U_SINT)((1)), (_U_SINT)((number_of_messages)), (((void *)0)), (_U_UINT)56, UNITY_DISPLAY_STYLE_INT);



 add_message(dummy2);

 aux = aux->next;



 UnityAssertEqualNumber((_U_SINT)((0)), (_U_SINT)((strcmp(aux->message,dummy2))), (((void *)0)), (_U_UINT)61, UNITY_DISPLAY_STYLE_INT);

 UnityAssertEqualNumber((_U_SINT)((2)), (_U_SINT)((aux->id)), (((void *)0)), (_U_UINT)62, UNITY_DISPLAY_STYLE_INT);

 UnityAssertEqualNumber((_U_SINT)((((void *)0))), (_U_SINT)((aux->next)), (((void *)0)), (_U_UINT)63, UNITY_DISPLAY_STYLE_INT);

 UnityAssertEqualNumber((_U_SINT)((2)), (_U_SINT)((number_of_messages)), (((void *)0)), (_U_UINT)64, UNITY_DISPLAY_STYLE_INT);



 add_message(dummy3);

 UnityAssertEqualNumber((_U_SINT)((((void *)0))), (_U_SINT)((aux->next)), (((void *)0)), (_U_UINT)67, UNITY_DISPLAY_STYLE_INT);



}
Exemplo n.º 10
0
CUT_EXPORT void cut_setup(void)
{
#if DEBUG
    g_print("cut_setup\n");
#endif
    cut_message("cut_setup");
    cs_init();
}
Exemplo n.º 11
0
CUT_EXPORT void test_cs_createNamedCSint_INT_MAX_TO_INT_MIN(void)
{
    /* this will cause cutter SEGV */
#if 0
    cs_init();
    CSint *vint = cs_createNamedCSint(INT_MAX, INT_MIN, "dummy");
    cut_assert_null(vint);
#endif
}
Exemplo n.º 12
0
CUT_EXPORT void test_cs_createNamedCSint_0_TO_INT_MAX_PLUS1(void)
{
    /* this will cause cutter SEGV */
#if 0
    cs_init();
    CSint *vint = cs_createNamedCSint(0, INT_MAX+1, "dummy");
    cut_assert_null(vint);
    cs_end();
#endif
}
Exemplo n.º 13
0
CUT_EXPORT void test_cs_createCSint_SWAP(void)
{
    cs_init();
    CSint *vint = cs_createCSint(0, -1);
    cut_assert_null(vint);

    vint = cs_createCSint(1, 0);
    cut_assert_null(vint);

    vint = cs_createCSint(1, -1);
    cut_assert_null(vint);
}
Exemplo n.º 14
0
static int diary_handle_feed_rss(request_rec *r, diary_conf *conf)
{
    HDF *hdf;
    CSPARSE *cs;
    NEOERR *cs_err;
    STRING cs_err_str;

    ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "diary_handle_feed_rss()");

    hdf_init(&hdf);
    hdf_set_value(hdf, "hdf.loadpaths.1", conf->path);
    hdf_set_value(hdf, "diary.title", conf->title);
    hdf_set_value(hdf, "diary.uri", conf->uri);

    cs_err = hdf_read_file(hdf, INDEX_HDF);
    if(cs_err){
        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "cannot read index.hdf.");
        hdf_destroy(&hdf);
        return HTTP_INTERNAL_SERVER_ERROR;
    }
    //hdf_dump(hdf, NULL);

    cs_err = cs_init(&cs, hdf);
    if(cs_err){
        string_init(&cs_err_str);
        nerr_error_string(cs_err, &cs_err_str);
        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
                      "error at cs_init(): %s", cs_err_str.buf);
        cs_destroy(&cs);
        hdf_destroy(&hdf);
        return HTTP_INTERNAL_SERVER_ERROR;
    }

    cgi_register_strfuncs(cs);

    cs_err = cs_parse_string(cs, strdup(RSS_TMPL), RSS_TMPL_LEN);
    if(cs_err){
        string_init(&cs_err_str);
        nerr_error_string(cs_err, &cs_err_str);
        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
                      "error in cs_parse_string(): %s", cs_err_str.buf);
        cs_destroy(&cs);
        hdf_destroy(&hdf);
        return HTTP_INTERNAL_SERVER_ERROR;
    }

    r->content_type = "application/rss+xml";
    cs_render(cs, r, diary_cs_render_cb);

    cs_destroy(&cs);
    hdf_destroy(&hdf);
    return OK;
}
Exemplo n.º 15
0
int main() {
	std::cout << THREADS << " threads / std::mutex locking\n";
	cs_init();
	std::array<std::thread, THREADS> ts;
	for(auto& t : ts) {
		t = std::thread(&call_cs);
	}
	for(auto& t : ts) {
		t.join();
	}
	cs_finish();
}
void mtranApi_ussrSetup(int portRC, int portEvent, char* host, void (*msgHandler)(char*, char, char)) {
  /*Initialize Message Handler*/
  mtranApi_msgHandler = msgHandler;

  /*Initialize command sender*/
  cs_init(portRC, host);
  cs_sendCommand_void("setup"); //initializes simulator

  /*Initialize event listener*/
  el_init(portEvent, host);
  el_installEvent("handleMessage", mtranApi_handleMessage);
  el_startEventListen();
}
Exemplo n.º 17
0
int process_template(HDF *hdf, char *infile, char *outfile)
{
  int ret = 0;
  FILE *outfh = NULL;
  NEOERR *err;
  CSPARSE *parse = NULL;

  if (!make_dirs(outfile))
  {
    ret = -1;
  }
  else
  {
    if ((outfh = fopen(outfile, "w")) == NULL)
    {
      perror("fopen");
      ret = -2;
    }
    else
    {
      err = cs_init(&parse, hdf);
      if (err != STATUS_OK)
      {
        nerr_log_error(err);
        ret = -5;
      }
      else
      { 
        err = cs_parse_file(parse, infile);
        if (err != STATUS_OK)
        {
          nerr_log_error(err);
          ret = -6;
        }
        
        err = cs_render(parse, outfh, csoutfunc);  
        if (err != STATUS_OK)
        {
          nerr_log_error(err);
          ret = -7;
        }

        cs_destroy(&parse);
      }
      fclose(outfh);
    }
  }
  return ret;
}
Exemplo n.º 18
0
CUT_EXPORT void test_cs_createNamedCSint_SWAP(void)
{
    /* this will cause cutter SEGV */
#if 0
    cs_init();
    CSint *vint = cs_createNamedCSint(0, -1, "dummy");
    cut_assert_null(vint);

    vint = cs_createNamedCSint(1, 0, "dummy");
    cut_assert_null(vint);

    vint = cs_createNamedCSint(1, -1, "dummy");
    cut_assert_null(vint);
#endif
}
Exemplo n.º 19
0
void test_cs_init(void)

{

 cs_init();



 UnityAssertEqualNumber((_U_SINT)((((void *)0))), (_U_SINT)((cs_list->message)), (((void *)0)), (_U_UINT)20, UNITY_DISPLAY_STYLE_INT);

 UnityAssertEqualNumber((_U_SINT)((0)), (_U_SINT)((cs_list->id)), (((void *)0)), (_U_UINT)21, UNITY_DISPLAY_STYLE_INT);

 UnityAssertEqualNumber((_U_SINT)((((void *)0))), (_U_SINT)((cs_list->next)), (((void *)0)), (_U_UINT)22, UNITY_DISPLAY_STYLE_INT);

 UnityAssertEqualNumber((_U_SINT)((0)), (_U_SINT)((number_of_messages)), (((void *)0)), (_U_UINT)23, UNITY_DISPLAY_STYLE_INT);

}
Exemplo n.º 20
0
void formatter_kml_split_output(formatter_split_t *obj, char *filename) {
    FILE *fp = fopen(filename, "w");

    CSPARSE *csparse;
    HDF *hdf;
    NEOERR *err;
    int stage = 0;
    if ((err = hdf_init(&hdf)) != STATUS_OK) {
        goto error;
    }

    coordinate_subset_t *subset = obj->set->first_subset;
    int16_t i = 0;
    while (subset) {
        _cs_set_valuef(hdf, "tracks.%d.colour=%s", i, kml_colours[i % 9]);
        coordinate_t *coordinate = subset->first;
        int16_t j = 0;
        while (coordinate && coordinate != subset->last) {
            _cs_set_valuef(hdf, "tracks.%d.points.%d.lng=%f", i, j, coordinate->lng);
            _cs_set_valuef(hdf, "tracks.%d.points.%d.lat=%f", i, j, coordinate->lat);
            _cs_set_valuef(hdf, "tracks.%d.points.%d.ele=%d", i, j, coordinate->ele);
            _cs_set_valuef(hdf, "tracks.%d.points.%d.time=%f", i, j, coordinate->timestamp);
            coordinate = coordinate->next;
            j++;
        }
        subset = subset->next;
        i++;
    }

    if ((err = cs_init(&csparse, hdf)) != STATUS_OK ||
        (err = cs_parse_file(csparse, "formatter/templates/flight.split.kml.cs.xml")) != STATUS_OK ||
        (err = cs_render(csparse, fp, cs_fwrite)) != STATUS_OK) {
        goto error;
    }

    goto end;

    error:
    nerr_log_error(err);
    goto end;

    end:
    hdf_destroy(&hdf);
    cs_destroy(&csparse);
    fclose(fp);
}
Exemplo n.º 21
0
int main(void)
{
  GC_INIT();
  TF_Buffer *buffer = TF_GetAllOpList();
  Tensorflow__OpList *op_list = tensorflow__op_list__unpack(NULL, buffer->length, buffer->data);

  HDF *hdf;
  hdf_init(&hdf);

  for (int i=0; i<op_list->n_op; i++) {
    struct _Tensorflow__OpDef *op = op_list->op[i];
    char variable[256];
    char value[256];
    snprintf(variable, 256, "Op.%s.name", op->name);
    snprintf(value, 256, "tf-%s", kebab_case(op->name));
    hdf_set_value(hdf, variable, value);
    for (int j=0; j<op->n_input_arg; j++) {
      Tensorflow__OpDef__ArgDef *arg = op->input_arg[j];
      snprintf(variable, 256, "Op.%s.input_arg.%s", op->name, arg->name);
      const char *multiple = arg->number_attr && *arg->number_attr ? "list" : "single";
      hdf_set_value(hdf, variable, multiple);
    };
    for (int j=0; j<op->n_attr; j++) {
      Tensorflow__OpDef__AttrDef *attr = op->attr[j];
      snprintf(variable, 256, "Op.%s.attr.%s", op->name, attr->name);
      snprintf(value, 256, "%s", attr->type);
      hdf_set_value(hdf, variable, value);
    };
    snprintf(variable, 256, "Op.%s.n_output", op->name);
    snprintf(value, 256, "%d", op->n_output_arg);
    hdf_set_value(hdf, variable, value);
  };

  CSPARSE *parse;
  cs_init(&parse, hdf);
  cs_parse_file(parse, "tensorflow.scm.in");
  cs_render(parse, stdout, output);

  cs_destroy(&parse);
  hdf_destroy(&hdf);

  tensorflow__op_list__free_unpacked(op_list, NULL);
  TF_DeleteBuffer(buffer);
}
Exemplo n.º 22
0
static void wiki_output(MMIOT *doc, request_rec *r)
{
    char *title;
    int ret;
    int size;
    char *p;
    wiki_conf *conf;
    list_t *css;
    HDF *hdf;
    CSPARSE *cs;
    int i;

    conf =
        (wiki_conf *) ap_get_module_config(r->per_dir_config,
                                           &wiki_module);
    ret = mkd_compile(doc, MKD_TOC | MKD_AUTOLINK);

    hdf_init(&hdf);

    if(conf->name){
        hdf_set_value(hdf, "wikiname", conf->name);
    }

    title = mkd_doc_title(doc);
    if(title == NULL){
        title = "notitle";
    }
    hdf_set_value(hdf, "title", title);

    for(i=0, css = conf->css; css; i++, css = (list_t *) css->next){
        hdf_set_valuef(hdf, "css.%d=%s", i, (char *)css->data);
    }

    if ((size = mkd_document(doc, &p)) != EOF) {
        hdf_set_value(hdf, "document", p);
    }

    cs_init(&cs, hdf);
    cs_parse_string(cs, strdup(DEFAULT_TEMPLATE), strlen(DEFAULT_TEMPLATE));
    cs_render(cs, r, cs_output);
    hdf_destroy(&hdf);
    cs_destroy(&cs);
}
Exemplo n.º 23
0
CUT_EXPORT void test_cs_getPreviousValue(void)
{
    cs_init();
    CSint *vint = NULL;

    vint = cs_createCSint(-10, 10);
    cut_assert_equal_int(-10, cs_getMin(vint));
    cut_assert_equal_int(10, cs_getMax(vint));
    for (int i=-10; i < 10; i++){
        if (i == -10) {
            cut_assert_equal_int(INT_MIN, cs_getPreviousValue(vint, i));
        } else {
            cut_assert_equal_int(i-1, cs_getPreviousValue(vint, i));
        }
    }
    cut_assert_equal_int(INT_MIN, cs_getPreviousValue(vint, -10));
    cut_assert_equal_int(INT_MIN, cs_getPreviousValue(vint, INT_MIN));
    cut_assert_equal_int(10, cs_getPreviousValue(vint, INT_MAX));
}
Exemplo n.º 24
0
CUT_EXPORT void test_cs_createCSintArray(void)
{
    cs_init();
    CSint **avint = NULL;

    avint = cs_createCSintArray(INT_MAX+1, 0, INT_MAX);
    cut_assert_not_null(avint);

    avint = cs_createCSintArray(-1, 0, 0);
    cut_assert_null(avint);

    avint = cs_createCSintArray(0, 0, 0);
    cut_assert_not_null(avint);

    avint = cs_createCSintArray(0, 0, INT_MAX+1);
    cut_assert_not_null(avint);

    avint = cs_createCSintArray(0, INT_MIN-1, 0);
    cut_assert_not_null(avint);
}
Exemplo n.º 25
0
/** Entry point. */
int
main (int argc, char **argv)
{
    avr_init (argc, argv);
    /* Pull-ups. */
    PORTB = 0xe0;
    PORTC = 0xfc;
    PORTD = 0x80;
    timer_init ();
    uart0_init ();
    twi_proto_init ();
    cs_init ();
    aux_init ();
    eeprom_read_params ();
    proto_send0 ('z');
    sei ();
    while (1)
	main_loop ();
    return 0;
}
Exemplo n.º 26
0
CUT_EXPORT void test_cs_getNextValue(void)
{
    cs_init();
    CSint *vint = NULL;

    /* -10,-9,-8,...,8,9,10 */
    vint = cs_createCSint(-10, 10);
    cut_assert_equal_int(-10, cs_getMin(vint));
    cut_assert_equal_int(10, cs_getMax(vint));
    for (int i=-10; i <= 10; i++){
        if (i == 10) {
            cut_assert_equal_int(INT_MAX, cs_getNextValue(vint, i));
        } else {
            cut_assert_equal_int(i+1, cs_getNextValue(vint, i));
        }
        
    }
    cut_assert_equal_int(INT_MAX, cs_getNextValue(vint, 10));
    cut_assert_equal_int(-10, cs_getNextValue(vint, INT_MIN));
    cut_assert_equal_int(INT_MAX, cs_getNextValue(vint, INT_MAX));
}
Exemplo n.º 27
0
CUT_EXPORT void test_cs_createCSintFromDomain(void)
{
    cs_init();
    CSint *vint = NULL;

    int array[] = {1};
    vint = cs_createCSintFromDomain(array, 1);
    cut_assert_not_null(vint);

#if 0
    /* this will cause cutter SEGV */
    vint = cs_createCSintFromDomain(NULL, 0);
    cut_assert_null(vint);

    vint = cs_createCSintFromDomain(array, -1);
    cut_assert_null(vint);

    vint = cs_createCSintFromDomain(array, 0);
    cut_assert_null(vint);
#endif
}
Exemplo n.º 28
0
CUT_EXPORT void test_cs_createNamedCSint(void)
{
    cs_init();
    CSint *vint = cs_createNamedCSint(0, 1, "dummy");
    cut_assert_not_null(vint);

    vint = cs_createNamedCSint(-1, 0, "dummy");
    cut_assert_not_null(vint);

    vint = cs_createNamedCSint(-1, 1, "dummy");
    cut_assert_not_null(vint);

    vint = cs_createNamedCSint(INT_MIN, INT_MAX, "dummy");
    cut_assert_not_null(vint);

    vint = cs_createNamedCSint(0, 0, "dummy");
    cut_assert_not_null(vint);

    vint = cs_createNamedCSint(INT_MIN, INT_MIN, "dummy");
    cut_assert_not_null(vint);

    vint = cs_createNamedCSint(INT_MAX, INT_MAX, "dummy");
    cut_assert_not_null(vint);
}
Exemplo n.º 29
0
CUT_EXPORT void test_cs_createCSint(void)
{
    cs_init();
    CSint *vint = cs_createCSint(0, 1);
    cut_assert_not_null(vint);

    vint = cs_createCSint(-1, 0);
    cut_assert_not_null(vint);

    vint = cs_createCSint(-1, 1);
    cut_assert_not_null(vint);

    vint = cs_createCSint(INT_MIN, INT_MAX);
    cut_assert_not_null(vint);

    vint = cs_createCSint(0, 0);
    cut_assert_not_null(vint);

    vint = cs_createCSint(INT_MIN, INT_MIN);
    cut_assert_not_null(vint);

    vint = cs_createCSint(INT_MAX, INT_MAX);
    cut_assert_not_null(vint);
}
Exemplo n.º 30
0
/*
 * bword --
 *	Move backward by words.
 */
static int
bword(SCR *sp, VICMD *vp, enum which type)
{
	enum { INWORD, NOTWORD } state;
	VCS cs;
	u_long cnt;
	int nmw, omw;

	cnt = F_ISSET(vp, VC_C1SET) ? vp->count : 1;
	cs.cs_lno = vp->m_start.lno;
	cs.cs_cno = vp->m_start.cno;
	if (cs_init(sp, &cs))
		return (1);

	/*
	 * !!!
	 * If in whitespace, or the previous character is whitespace, move
	 * past it.  (This doesn't count as a word move.)  Stay at the
	 * character before the current one, it sets word "state" for the
	 * 'b' command.
	 */
	if (cs.cs_flags == 0 && !ISBLANK2(cs.cs_ch)) {
		if (cs_prev(sp, &cs))
			return (1);
		if (cs.cs_flags == 0 && !ISBLANK2(cs.cs_ch))
			goto start;
	}
	if (cs_bblank(sp, &cs))
		return (1);

	/*
	 * Cyclically move to the beginning of the previous word -- this
	 * involves skipping over word characters and then any trailing
	 * non-word characters.  Note, for the 'b' command, the definition
	 * of a word keeps switching.
	 */
start:	if (type == BIGWORD)
		while (cnt--) {
			nmw = ISMULTIWIDTH(sp, cs.cs_ch);
			for (;;) {
				omw = nmw;
				if (cs_prev(sp, &cs))
					return (1);
				if (cs.cs_flags == CS_SOF)
					goto ret;
				if (cs.cs_flags != 0 || ISBLANK2(cs.cs_ch) ||
				    (nmw = ISMULTIWIDTH(sp, cs.cs_ch)) != omw)
					break;
			}
			/*
			 * When we reach the end of the word before the last
			 * word, we're done.  If we changed state, move forward
			 * one to the end of the next word.
			 */
			if (cnt == 0) {
				if (cs.cs_flags == 0 && cs_next(sp, &cs))
					return (1);
				break;
			}

			/* Eat whitespace characters. */
			if (nmw == omw && cs_bblank(sp, &cs))
				return (1);
			if (cs.cs_flags == CS_SOF)
				goto ret;
		}
	else
		while (cnt--) {
			state = cs.cs_flags == 0 &&
			    inword(cs.cs_ch) ? INWORD : NOTWORD;
			nmw = ISMULTIWIDTH(sp, cs.cs_ch);
			for (;;) {
				omw = nmw;
				if (cs_prev(sp, &cs))
					return (1);
				if (cs.cs_flags == CS_SOF)
					goto ret;
				if (cs.cs_flags != 0 || ISBLANK2(cs.cs_ch) ||
				    (nmw = ISMULTIWIDTH(sp, cs.cs_ch)) != omw)
					break;
				if (state == INWORD) {
					if (!inword(cs.cs_ch))
						break;
				} else
					if (inword(cs.cs_ch))
						break;
			}
			/* See comment above. */
			if (cnt == 0) {
				if (cs.cs_flags == 0 && cs_next(sp, &cs))
					return (1);
				break;
			}

			/* Eat whitespace characters. */
			if (cs.cs_flags != 0 || ISBLANK2(cs.cs_ch))
				if (cs_bblank(sp, &cs))
					return (1);
			if (cs.cs_flags == CS_SOF)
				goto ret;
		}

	/* If we didn't move, we must be at SOF. */
ret:	if (cs.cs_lno == vp->m_start.lno && cs.cs_cno == vp->m_start.cno) {
		v_sof(sp, &vp->m_start);
		return (1);
	}

	/* Set the end of the range for motion commands. */
	vp->m_stop.lno = cs.cs_lno;
	vp->m_stop.cno = cs.cs_cno;

	/*
	 * All commands move to the end of the range.  Motion commands
	 * adjust the starting point to the character before the current
	 * one.
	 *
	 * !!!
	 * The historic vi didn't get this right -- the `yb' command yanked
	 * the right stuff and even updated the cursor value, but the cursor
	 * was not actually updated on the screen.
	 */
	vp->m_final = vp->m_stop;
	if (ISMOTION(vp))
		--vp->m_start.cno;
	return (0);
}