Пример #1
0
void SkGridView::onSizeChange()
{
	fScrollBar->setHeight(this->height());
	fScrollBar->setLoc(this->locX() + this->width() - fScrollBar->width(), 0);

	if (fCellSize.equals(0, 0))
	{
		fVisibleCount.set(0, 0);
		return;
	}

	SkScalar rows = SkScalarDiv(this->height(), fCellSize.fY);
	SkScalar cols = SkScalarDiv(this->width(), fCellSize.fX);
	int		 y = SkScalarFloor(rows);
	int		 x = SkScalarFloor(cols);

	y = check_count(y, rows);
	x = check_count(x, cols);

	if (!fVisibleCount.equals(x, y))
	{
		fVisibleCount.set(x, y);
		this->ensureSelectionIsVisible();
	//	this->dirtyStrCache();
	}
}
Пример #2
0
static int
post_lb(POST_ARGS)
{
	const char	*p;
	char		*buf;
	size_t		 sz;

	check_count(mdoc, MDOC_ELEM, CHECK_WARN, CHECK_EQ, 1);

	assert(mdoc->last->child);
	assert(MDOC_TEXT == mdoc->last->child->type);

	p = mdoc_a2lib(mdoc->last->child->string);

	/* If lookup ok, replace with table value. */

	if (p) {
		free(mdoc->last->child->string);
		mdoc->last->child->string = mandoc_strdup(p);
		return(1);
	}

	/* If not, use "library ``xxxx''. */

	sz = strlen(mdoc->last->child->string) +
		2 + strlen("\\(lqlibrary\\(rq");
	buf = mandoc_malloc(sz);
	snprintf(buf, sz, "library \\(lq%s\\(rq", 
			mdoc->last->child->string);
	free(mdoc->last->child->string);
	mdoc->last->child->string = buf;
	return(1);
}
Пример #3
0
    inline void operator()(internal_node const& n)
    {
        typedef typename rtree::elements_type<internal_node>::type elements_type;
        elements_type const& elements = rtree::elements(n);

        // root internal node shouldn't contain 0 elements
        if ( elements.empty()
          || !check_count(elements) )
        {
            result = false;
            return;
        }

        size_t current_level_backup = m_current_level;
        ++m_current_level;

        for ( typename elements_type::const_iterator it = elements.begin();
              it != elements.end() && result == true ;
              ++it)
        {
            rtree::apply_visitor(*this, *it->second);
        }

        m_current_level = current_level_backup;
    }
Пример #4
0
void init()
{
	object me;
	me = this_player();
	
	me->add_temp("taohua/count", 13);
	check_count(me, 13);
	return;
}
Пример #5
0
void operators()
{
	bit_field BF_0(2);
	bit_field BF_1(2);
	check_count(BF_0);

	//==
	if(!(BF_0 == BF_1)){
		LOG; ++fail;
	}

	//!=
	if(BF_0 != BF_1){
		LOG; ++fail;
	}

	//&=
	BF_0 &= BF_1;
	if(BF_0[0] != 0){
		LOG; ++fail;
	}
	check_count(BF_0);

	//^=
	BF_0 ^= BF_1;
	if(BF_0[0] != 0){
		LOG; ++fail;
	}
	check_count(BF_0);

	//|=
	BF_0 |= BF_1;
	if(BF_0[0] != 0){
		LOG; ++fail;
	}
	check_count(BF_0);

	//~
	~BF_0;
	if(BF_0[0] != 1){
		LOG; ++fail;
	}
	check_count(BF_0);

	//=
	BF_0 = BF_1;
	if(BF_0[0] != 0){
		LOG; ++fail;
	}
	check_count(BF_0);

	//bitgroup_vector::proxy assignment test
	BF_0[0] = BF_0[1] = 1;
	if(BF_0[0] != 1 || BF_0[1] != 1){
		LOG; ++fail;
	}
	check_count(BF_0);
}
Пример #6
0
void assignment()
{
	//starting with every bit off, turn every even bit on
	boost::uint64_t test_size = 16;
	bit_field BF(test_size);
	for(boost::uint64_t x=0; x<test_size; ++x){
		if(x % 2 == 0){
			BF[x] = true;
		}
	}
	check_count(BF);

	//make sure every even bit on
	for(boost::uint64_t x=0; x<test_size; ++x){
		if(x % 2 == 0){
			if(BF[x] != true){
				LOG; ++fail;
			}
		}
	}
	check_count(BF);

	//starting with every bit on, turn every even bit off
	BF.set();
	for(boost::uint64_t x=0; x<test_size; ++x){
		if(x % 2 == 0){
			BF[x] = false;
		}
	}
	check_count(BF);

	//make sure every even bit off
	for(boost::uint64_t x=0; x<test_size; ++x){
		if(x % 2 == 0){
			if(BF[x] != false){
				LOG; ++fail;
			}
		}
	}
	check_count(BF);
}
Пример #7
0
    inline void operator()(leaf const& n)
    {
        typedef typename rtree::elements_type<leaf>::type elements_type;
        elements_type const& elements = rtree::elements(n);

        // empty leaf in non-root node
        if ( ( m_current_level > 0 && elements.empty() )
          || !check_count(elements) )
        {
            result = false;
        }
    }
Пример #8
0
void named_functions()
{
	bit_field BF(1);

	//size function
	if(BF.size() != 1){
		LOG; ++fail;
	}

	//reset function
	BF[0] = 1;
	if(BF[0] != 1){
		LOG; ++fail;
	}
	check_count(BF);
	BF.reset();
	if(BF[0] == 1){
		LOG; ++fail;
	}
	check_count(BF);
}
Пример #9
0
void counting()
{
	if(r==1&&c==(n+1))
	{	// all combinations exhausted
		printf("THE NUMBER OF SOLUTIONS ARE:   %ld\n",count);
		exit(1);
	}
	if(r==n+1)
	{	//a possible solution reached
		r=n;
		c=pos[r];
		mat[r][c]=' ';
		c=c+1;
		counting();

	}
	if((c<=n)&&(check_fnc(r,c)) )
	{
		mat[r][c]='q'; //to check the postion in current row
		if(check_count())
			{
				count++;
				if(count==1||count==2)
					disp();
			}
		pos[r]=c;
		r=r+1;
		c=1;
		counting();

	}
	else
	{
	    if(c<n)
	    {
		c++;
		counting();
	    }
	    else
	    {  // to move from curent row to the previous one and rearranging the previous one 
		c=pos[r];
		mat[r][c]=' ';
		r=r-1;
		c=pos[r];
		mat[r][c]=' ';
		c=c+1;
		counting();
	    }
	}

}
Пример #10
0
void solve(int a, int b) {
    // 长除法
    int i; 
    int mod; 
    if(a % b == 0) {
        fprintf(fout, "%d.", dec[0]); 
        count = len(dec[0]) + 1; 
        for( i = 1 ; i < p ; i++ ) {
            fprintf(fout, "%hi", dec[i]); 
            check_count(); 
        } 
        fprintf(fout, "%d\n", a/b); 
        return; 
    }else{
        dec[p] = a / b; 
        res[p] = a % b; 
        mod = a % b;
        if(hash[mod]) {
            // 进入循环处理阶段
            fprintf(fout, "%d.", dec[0]); 
            count = len(dec[0]) + 1; 
            i = 0; 
            while(1) {
                if(res[i] == mod) {
                    fprintf(fout, "(%d", dec[i+1]); 
                    check_count(); 
                    check_count(); 
                    break; 
                }
                fprintf(fout, "%d", dec[i+1]); 
                check_count(); 
                i = i + 1; 
            }
            i = i + 1; 
            while(1) {
                if(res[i] == mod) {
                    fprintf(fout, ")\n"); 
                    check_count(); 
                    break; 
                }
                fprintf(fout, "%d", dec[i+1]);
                check_count(); 
                i = i + 1; 
            }
            return; 
        }
        hash[mod] = 1; 
        solve(res[p++]*10, b); 
    }
}
Пример #11
0
static int
post_an(POST_ARGS)
{
	struct mdoc_node *np;

	np = mdoc->last;
	if (AUTH__NONE != np->norm->An.auth && np->child) {
		check_count(mdoc, MDOC_ELEM, CHECK_WARN, CHECK_EQ, 0);
		return(1);
	}

	/* 
	 * FIXME: make this ewarn and make sure that the front-ends
	 * don't print the arguments.
	 */
	if (AUTH__NONE != np->norm->An.auth || np->child)
		return(1);

	mdoc_nmsg(mdoc, np, MANDOCERR_NOARGS);
	return(1);
}
Пример #12
0
static int
ebool(struct mdoc *mdoc)
{

	if (NULL == mdoc->last->child) {
		mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_MACROEMPTY);
		mdoc_node_delete(mdoc, mdoc->last);
		return(1);
	}
	check_count(mdoc, MDOC_ELEM, CHECK_WARN, CHECK_EQ, 1);

	assert(MDOC_TEXT == mdoc->last->child->type);

	if (0 == strcmp(mdoc->last->child->string, "on"))
		return(1);
	if (0 == strcmp(mdoc->last->child->string, "off"))
		return(1);

	mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_BADBOOL);
	return(1);
}
Пример #13
0
static int
ewarn_ge1(POST_ARGS)
{
	return(check_count(mdoc, MDOC_ELEM, CHECK_WARN, CHECK_GT, 0));
}
int main(int argc, char *argv[]) {
    boost::scoped_ptr<pg::tempdb> db;

    try {
        db.reset(new pg::tempdb);
    } catch (const std::exception &e) {
        std::cerr << "Unable to setup database: " << e.what() << "\n";
        return 77; // <-- code to skip this test.
    }

    try {
        boost::shared_ptr<middle_pgsql_t> mid_pgsql(new middle_pgsql_t());
        options_t options;
        options.conninfo = db->conninfo().c_str();
        options.num_procs = 1;
        options.prefix = "osm2pgsql_test";
        options.tblsslim_index = "tablespacetest";
        options.tblsslim_data = "tablespacetest";
        options.slim = 1;

        boost::shared_ptr<geometry_processor> processor =
            geometry_processor::create("point", &options);

        export_list columns;
        { taginfo info; info.name = "amenity"; info.type = "text"; columns.add(OSMTYPE_NODE, info); }

        boost::shared_ptr<output_multi_t> out_test(new output_multi_t("foobar_amenities", processor, columns, mid_pgsql.get(), options));

        osmdata_t osmdata(mid_pgsql, out_test);

        boost::scoped_ptr<parse_delegate_t> parser(new parse_delegate_t(options.extra_attributes, options.bbox, options.projection));

        osmdata.start();

        if (parser->streamFile("pbf", "tests/liechtenstein-2013-08-03.osm.pbf", options.sanitize, &osmdata) != 0) {
            throw std::runtime_error("Unable to read input file `tests/liechtenstein-2013-08-03.osm.pbf'.");
        }

        parser.reset(NULL);

        osmdata.stop();

        // start a new connection to run tests on
        pg::conn_ptr test_conn = pg::conn::connect(db->conninfo());

        check_count(test_conn, 1,
                    "select count(*) from pg_catalog.pg_class "
                    "where relname = 'osm2pgsql_test_foobar_amenities'");

        check_count(test_conn, 244,
                    "select count(*) from osm2pgsql_test_foobar_amenities");

        check_count(test_conn, 36,
                    "select count(*) from osm2pgsql_test_foobar_amenities where amenity='parking'");

        check_count(test_conn, 34,
                    "select count(*) from osm2pgsql_test_foobar_amenities where amenity='bench'");

        check_count(test_conn, 1,
                    "select count(*) from osm2pgsql_test_foobar_amenities where amenity='vending_machine'");

        return 0;

    } catch (const std::exception &e) {
        std::cerr << "ERROR: " << e.what() << std::endl;

    } catch (...) {
        std::cerr << "UNKNOWN ERROR" << std::endl;
    }

    return 1;
}
int main(int argc, char *argv[]) {
    boost::scoped_ptr<pg::tempdb> db;

    try {
        db.reset(new pg::tempdb);
    } catch (const std::exception &e) {
        std::cerr << "Unable to setup database: " << e.what() << "\n";
        return 77; // <-- code to skip this test.
    }

    try {
        boost::shared_ptr<middle_pgsql_t> mid_pgsql(new middle_pgsql_t());
        options_t options;
        options.conninfo = db->conninfo().c_str();
        options.num_procs = 1;
        options.prefix = "osm2pgsql_test";
        options.tblsslim_index = "tablespacetest";
        options.tblsslim_data = "tablespacetest";
        options.slim = 1;

        boost::shared_ptr<geometry_processor> processor =
            geometry_processor::create("line", &options);

        export_list columns;
        { taginfo info; info.name = "highway"; info.type = "text"; columns.add(OSMTYPE_WAY, info); }

        boost::shared_ptr<output_multi_t> out_test(new output_multi_t("foobar_highways", processor, columns, mid_pgsql.get(), options));

        osmdata_t osmdata(mid_pgsql, out_test);

        boost::scoped_ptr<parse_delegate_t> parser(new parse_delegate_t(options.extra_attributes, options.bbox, options.projection));

        osmdata.start();

        if (parser->streamFile("pbf", "tests/liechtenstein-2013-08-03.osm.pbf", options.sanitize, &osmdata) != 0) {
            throw std::runtime_error("Unable to read input file `tests/liechtenstein-2013-08-03.osm.pbf'.");
        }

        parser.reset(NULL);

        osmdata.stop();

        // start a new connection to run tests on
        pg::conn_ptr test_conn = pg::conn::connect(db->conninfo());

        check_count(test_conn, 1, "select count(*) from pg_catalog.pg_class where relname = 'osm2pgsql_test_foobar_highways'");
        check_count(test_conn, 2753, "select count(*) from osm2pgsql_test_foobar_highways");

        //check that we have the right spread
        check_count(test_conn, 13, "select count(*) from osm2pgsql_test_foobar_highways where highway='bridleway'");
        check_count(test_conn, 3, "select count(*) from osm2pgsql_test_foobar_highways where highway='construction'");
        check_count(test_conn, 96, "select count(*) from osm2pgsql_test_foobar_highways where highway='cycleway'");
        check_count(test_conn, 249, "select count(*) from osm2pgsql_test_foobar_highways where highway='footway'");
        check_count(test_conn, 18, "select count(*) from osm2pgsql_test_foobar_highways where highway='living_street'");
        check_count(test_conn, 171, "select count(*) from osm2pgsql_test_foobar_highways where highway='path'");
        check_count(test_conn, 6, "select count(*) from osm2pgsql_test_foobar_highways where highway='pedestrian'");
        check_count(test_conn, 81, "select count(*) from osm2pgsql_test_foobar_highways where highway='primary'");
        check_count(test_conn, 842, "select count(*) from osm2pgsql_test_foobar_highways where highway='residential'");
        check_count(test_conn, 3, "select count(*) from osm2pgsql_test_foobar_highways where highway='road'");
        check_count(test_conn, 90, "select count(*) from osm2pgsql_test_foobar_highways where highway='secondary'");
        check_count(test_conn, 1, "select count(*) from osm2pgsql_test_foobar_highways where highway='secondary_link'");
        check_count(test_conn, 352, "select count(*) from osm2pgsql_test_foobar_highways where highway='service'");
        check_count(test_conn, 34, "select count(*) from osm2pgsql_test_foobar_highways where highway='steps'");
        check_count(test_conn, 33, "select count(*) from osm2pgsql_test_foobar_highways where highway='tertiary'");
        check_count(test_conn, 597, "select count(*) from osm2pgsql_test_foobar_highways where highway='track'");
        check_count(test_conn, 164, "select count(*) from osm2pgsql_test_foobar_highways where highway='unclassified'");
        return 0;

    } catch (const std::exception &e) {
        std::cerr << "ERROR: " << e.what() << std::endl;

    } catch (...) {
        std::cerr << "UNKNOWN ERROR" << std::endl;
    }

    return 1;
}
static void
test_filter(CamelMimeFilter *f, const char *inname, const char *outname)
{
	CamelStreamMem *in, *out;
	CamelStream *indisk, *outdisk, *filter;
	int id;

	camel_test_push("Data file `%s'", inname);

	camel_test_push("setup");

	indisk = camel_stream_fs_new_with_name(inname, O_RDONLY, 0);
	check(indisk);
	outdisk = camel_stream_fs_new_with_name(outname, O_RDONLY, 0);
	check(outdisk);

	out = (CamelStreamMem *)camel_stream_mem_new();
	check(camel_stream_write_to_stream(outdisk, (CamelStream *)out) > 0);

	camel_test_pull();

	camel_test_push("reading through filter stream");

	in = (CamelStreamMem *)camel_stream_mem_new();

	filter = (CamelStream *)camel_stream_filter_new_with_stream(indisk);
	check_count(indisk, 2);
	id = camel_stream_filter_add((CamelStreamFilter *)filter, f);
	check_count(f, 2);

	check(camel_stream_write_to_stream(filter, (CamelStream *)in) > 0);
	check_msg(in->buffer->len == out->buffer->len
		  && memcmp(in->buffer->data, out->buffer->data, in->buffer->len) == 0,
		  "Buffer content mismatch, %d != %d, in = '%.*s' != out = '%.*s'", in->buffer->len, out->buffer->len,
		  in->buffer->len, in->buffer->data, out->buffer->len, out->buffer->data);

	camel_test_pull();

	camel_stream_filter_remove((CamelStreamFilter *)filter, id);
	check_count(f, 1);
	camel_mime_filter_reset(f);

	check_unref(filter, 1);
	check_count(indisk, 1);
	check_count(f, 1);
	check_unref(in, 1);

	check(camel_stream_reset(indisk) == 0);

	camel_test_push("writing through filter stream");

	in = (CamelStreamMem *)camel_stream_mem_new();
	filter = (CamelStream *)camel_stream_filter_new_with_stream((CamelStream *)in);
	check_count(in, 2);
	id = camel_stream_filter_add((CamelStreamFilter *)filter, f);
	check_count(f, 2);

	check(camel_stream_write_to_stream(indisk, filter) > 0);
	check(camel_stream_flush(filter) == 0);
	check_msg(in->buffer->len == out->buffer->len
		  && memcmp(in->buffer->data, out->buffer->data, in->buffer->len) == 0,
		  "Buffer content mismatch, %d != %d, in = '%.*s' != out = '%.*s'", in->buffer->len, out->buffer->len,
		  in->buffer->len, in->buffer->data, out->buffer->len, out->buffer->data);

	camel_stream_filter_remove((CamelStreamFilter *)filter, id);
	check_unref(filter, 1);
	check_unref(in, 1);
	check_unref(indisk, 1);
	check_unref(outdisk, 1);
	check_unref(out, 1);

	camel_test_pull();

	camel_test_pull();
}
Пример #17
0
int mouse_doing(void)
{
    int fd = 0;
    int mx = 512;
    int my = 384;
    char victory = -1;
    mouse_info_t mouse_info;
    fd = open("/dev/input/mice",O_RDWR|O_NONBLOCK);
    if(fd < 0 )
    {
        perror("open");
        exit(1);
    }
    draw_cursor(mx,my);
    print_choice();

    while(1)
    {
        if(get_mouse_info(fd,&mouse_info) > 0)
        {
            repair_shape(mx,my);
            mx += mouse_info.dx;
            my += mouse_info.dy;

            mx = (mx >= 0) ? mx:0;
            my = (my >= 0) ? my:0;
            
            if(mx >= (fb_info.w - C_WIDTH))
            {
                mx = fb_info.w - C_WIDTH;
            }

            if(my >= (fb_info.h - C_HEIGHT))
            {
                my = fb_info.h - C_HEIGHT;
            }
             draw_cursor(mx,my);

            switch(mouse_info.button)
            {
                case 1:
//printf("%d\n", event.button);                
                    repair_shape(mx, my);
                    if((draw_one_chess(mx,my)) == 0)
                    {
                        check_count(mx,my);
                        victory = check_all();
                    }
                    draw_cursor(mx, my);
                    break;
                case 2:
                    break;
                case 4:
                    break;
                default :
                    break;
            }
            if(victory == 1)
            {
                printf("Player %d won!\n",who);
                printf("Continue ? y/n \n");
                if(getchar() == '\n')
                {
                    break;
                }
                else
                {
					memset((u8_t *)fb_info.fb_mem, 0, fb_info.w*fb_info.h*fb_info.bpp/8);
					memset(board, 0, H_NUM*V_NUM);
					draw_board();
					print_choice();
					color_choice = 0x000000ff;
					who = 1;
					victory = -1;
					mx = 512;
					my = 384;
					draw_cursor(mx, my);
                }
                getchar();
            }
         }
        usleep(100);
    }
    return 0;
}
Пример #18
0
static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
    const cairo_test_context_t *ctx = cairo_test_get_context (cr);
    cairo_surface_t        *surface;
    cairo_t                *cr2;
    cairo_rectangle_list_t *rectangle_list;
    const char             *phase;
    cairo_bool_t            uses_clip_rects;
    
    surface = cairo_surface_create_similar (cairo_get_group_target (cr),
                                            CAIRO_CONTENT_COLOR, 100, 100);
    /* don't use cr accidentally */
    cr = NULL;
    cr2 = cairo_create (surface);
    cairo_surface_destroy (surface);

    /* Check the surface type so we ignore cairo_copy_clip_rectangle_list failures
     * on surface types that don't use rectangle lists for clipping.
     * Default to FALSE for the internal surface types, (meta, test-fallback, etc.)
     */
    switch (cairo_surface_get_type (surface)) {
    case CAIRO_SURFACE_TYPE_IMAGE:
    case CAIRO_SURFACE_TYPE_XLIB:
    case CAIRO_SURFACE_TYPE_XCB:
    case CAIRO_SURFACE_TYPE_GLITZ:
    case CAIRO_SURFACE_TYPE_WIN32:
    case CAIRO_SURFACE_TYPE_BEOS:
    case CAIRO_SURFACE_TYPE_DIRECTFB:
        uses_clip_rects = TRUE;
	break;
    case CAIRO_SURFACE_TYPE_QUARTZ:
    case CAIRO_SURFACE_TYPE_PDF:
    case CAIRO_SURFACE_TYPE_PS:
    case CAIRO_SURFACE_TYPE_SVG:
    case CAIRO_SURFACE_TYPE_OS2:
    default:
        uses_clip_rects = FALSE;
        break;
    }

    /* first, test basic stuff. This should not be clipped, it should
       return the surface rectangle. */
    phase = "No clip set";
    rectangle_list = cairo_copy_clip_rectangle_list (cr2);
    if (!check_count (ctx, phase, uses_clip_rects, rectangle_list, 1) ||
        !check_clip_extents (ctx, phase, cr2, 0, 0, 100, 100) ||
        !check_rectangles_contain (ctx, phase, uses_clip_rects, rectangle_list, 0, 0, 100, 100)) {
        cairo_rectangle_list_destroy (rectangle_list);
	return CAIRO_TEST_FAILURE;
    }
    cairo_rectangle_list_destroy (rectangle_list);

    /* Test simple clip rect. */
    phase = "Simple clip rect";
    cairo_save (cr2);
    cairo_rectangle (cr2, 10, 10, 80, 80);
    cairo_clip (cr2);
    rectangle_list = cairo_copy_clip_rectangle_list (cr2);
    if (!check_count (ctx, phase, uses_clip_rects, rectangle_list, 1) ||
        !check_clip_extents (ctx, phase, cr2, 10, 10, 80, 80) ||
        !check_rectangles_contain (ctx, phase, uses_clip_rects, rectangle_list, 10, 10, 80, 80)) {
        cairo_rectangle_list_destroy (rectangle_list);
	return CAIRO_TEST_FAILURE;
    }
    cairo_rectangle_list_destroy (rectangle_list);
    cairo_restore (cr2);

    /* Test everything clipped out. */
    phase = "All clipped out";
    cairo_save (cr2);
    cairo_clip (cr2);
    rectangle_list = cairo_copy_clip_rectangle_list (cr2);
    if (!check_count (ctx, phase, uses_clip_rects, rectangle_list, 0)) {
        cairo_rectangle_list_destroy (rectangle_list);
	return CAIRO_TEST_FAILURE;
    }
    cairo_rectangle_list_destroy (rectangle_list);
    cairo_restore (cr2);
    
    /* test two clip rects */
    phase = "Two clip rects";
    cairo_save (cr2);
    cairo_rectangle (cr2, 10, 10, 10, 10);
    cairo_rectangle (cr2, 20, 20, 10, 10);
    cairo_clip (cr2);
    cairo_rectangle (cr2, 15, 15, 10, 10);
    cairo_clip (cr2);
    rectangle_list = cairo_copy_clip_rectangle_list (cr2);
    if (!check_count (ctx, phase, uses_clip_rects, rectangle_list, 2) ||
        !check_clip_extents (ctx, phase, cr2, 15, 15, 10, 10) ||
        !check_rectangles_contain (ctx, phase, uses_clip_rects, rectangle_list, 15, 15, 5, 5) ||
        !check_rectangles_contain (ctx, phase, uses_clip_rects, rectangle_list, 20, 20, 5, 5)) {
        cairo_rectangle_list_destroy (rectangle_list);
	return CAIRO_TEST_FAILURE;
    }
    cairo_rectangle_list_destroy (rectangle_list);
    cairo_restore (cr2);

    /* test non-rectangular clip */
    phase = "Nonrectangular clip";
    cairo_save (cr2);
    cairo_move_to (cr2, 0, 0);
    cairo_line_to (cr2, 100, 100);
    cairo_line_to (cr2, 100, 0);
    cairo_close_path (cr2);
    cairo_clip (cr2);
    rectangle_list = cairo_copy_clip_rectangle_list (cr2);
     /* can't get this in one tight user-space rectangle */
    if (!check_unrepresentable (ctx, phase, rectangle_list) ||
        !check_clip_extents (ctx, phase, cr2, 0, 0, 100, 100)) {
        cairo_rectangle_list_destroy (rectangle_list);
	return CAIRO_TEST_FAILURE;
    }
    cairo_rectangle_list_destroy (rectangle_list);
    cairo_restore (cr2);
    
    phase = "User space, simple scale, getting clip with same transform";
    cairo_save (cr2);
    cairo_scale (cr2, 2, 2);
    cairo_rectangle (cr2, 5, 5, 40, 40);
    cairo_clip (cr2);
    rectangle_list = cairo_copy_clip_rectangle_list (cr2);
    if (!check_count (ctx, phase, uses_clip_rects, rectangle_list, 1) ||
        !check_clip_extents (ctx, phase, cr2, 5, 5, 40, 40) ||
        !check_rectangles_contain (ctx, phase, uses_clip_rects, rectangle_list, 5, 5, 40, 40)) {
        cairo_rectangle_list_destroy (rectangle_list);
	return CAIRO_TEST_FAILURE;
    }
    cairo_rectangle_list_destroy (rectangle_list);
    cairo_restore (cr2);

    phase = "User space, simple scale, getting clip with no transform";
    cairo_save (cr2);
    cairo_save (cr2);
    cairo_scale (cr2, 2, 2);
    cairo_rectangle (cr2, 5, 5, 40, 40);
    cairo_restore (cr2);
    cairo_clip (cr2);
    rectangle_list = cairo_copy_clip_rectangle_list (cr2);
    if (!check_count (ctx, phase, uses_clip_rects, rectangle_list, 1) ||
        !check_clip_extents (ctx, phase, cr2, 10, 10, 80, 80) ||
        !check_rectangles_contain (ctx, phase, uses_clip_rects, rectangle_list, 10, 10, 80, 80)) {
        cairo_rectangle_list_destroy (rectangle_list);
	return CAIRO_TEST_FAILURE;
    }
    cairo_rectangle_list_destroy (rectangle_list);
    cairo_restore (cr2);

    phase = "User space, rotation, getting clip with no transform";
    cairo_save (cr2);
    cairo_save (cr2);
    cairo_rotate (cr2, 12);
    cairo_rectangle (cr2, 5, 5, 40, 40);
    cairo_restore (cr2);
    cairo_clip (cr2);
    rectangle_list = cairo_copy_clip_rectangle_list (cr2);
    if (!check_unrepresentable (ctx, phase, rectangle_list)) {
        cairo_rectangle_list_destroy (rectangle_list);
	return CAIRO_TEST_FAILURE;
    }
    cairo_rectangle_list_destroy (rectangle_list);
    cairo_restore (cr2);

    cairo_destroy (cr2);
    return CAIRO_TEST_SUCCESS;
}
Пример #19
0
static void driver_tests(void)
{
    MMRESULT rc;
    DWORD dwACMVersion = acmGetVersion();

    if (winetest_interactive) {
        trace("ACM version = %u.%02u build %u%s\n",
              HIWORD(dwACMVersion) >> 8,
              HIWORD(dwACMVersion) & 0xff,
              LOWORD(dwACMVersion),
              LOWORD(dwACMVersion)  ==  0 ? " (Retail)" : "");
    }

    check_count(ACM_METRIC_COUNT_CODECS);
    check_count(ACM_METRIC_COUNT_CONVERTERS);
    check_count(ACM_METRIC_COUNT_DISABLED);
    check_count(ACM_METRIC_COUNT_DRIVERS);
    check_count(ACM_METRIC_COUNT_FILTERS);
    check_count(ACM_METRIC_COUNT_HARDWARE);
    check_count(ACM_METRIC_COUNT_LOCAL_CODECS);
    check_count(ACM_METRIC_COUNT_LOCAL_CONVERTERS);
    check_count(ACM_METRIC_COUNT_LOCAL_DISABLED);
    check_count(ACM_METRIC_COUNT_LOCAL_DRIVERS);
    check_count(ACM_METRIC_COUNT_LOCAL_FILTERS);

    if (winetest_interactive)
        trace("enabled drivers:\n");

    rc = acmDriverEnum(DriverEnumProc, 0, 0);
    ok(rc == MMSYSERR_NOERROR,
       "acmDriverEnum() failed, rc=%08x, should be 0x%08x\n",
       rc, MMSYSERR_NOERROR);
}
Пример #20
0
static int
eerr_ge1(POST_ARGS)
{
	return(check_count(mdoc, MDOC_ELEM, CHECK_ERROR, CHECK_GT, 0));
}
Пример #21
0
static int
post_rs(POST_ARGS)
{
	struct mdoc_node *nn, *next, *prev;
	int		  i, j;

	switch (mdoc->last->type) {
	case (MDOC_HEAD):
		check_count(mdoc, MDOC_HEAD, CHECK_WARN, CHECK_EQ, 0);
		return(1);
	case (MDOC_BODY):
		if (mdoc->last->child)
			break;
		check_count(mdoc, MDOC_BODY, CHECK_WARN, CHECK_GT, 0);
		return(1);
	default:
		return(1);
	}

	/*
	 * Make sure only certain types of nodes are allowed within the
	 * the `Rs' body.  Delete offending nodes and raise a warning.
	 * Do this before re-ordering for the sake of clarity.
	 */

	next = NULL;
	for (nn = mdoc->last->child; nn; nn = next) {
		for (i = 0; i < RSORD_MAX; i++)
			if (nn->tok == rsord[i])
				break;

		if (i < RSORD_MAX) {
			if (MDOC__J == rsord[i])
				mdoc->last->norm->Rs.child_J = nn;
			next = nn->next;
			continue;
		}

		next = nn->next;
		mdoc_nmsg(mdoc, nn, MANDOCERR_CHILD);
		mdoc_node_delete(mdoc, nn);
	}

	/*
	 * The full `Rs' block needs special handling to order the
	 * sub-elements according to `rsord'.  Pick through each element
	 * and correctly order it.  This is a insertion sort.
	 */

	next = NULL;
	for (nn = mdoc->last->child->next; nn; nn = next) {
		/* Determine order of `nn'. */
		for (i = 0; i < RSORD_MAX; i++)
			if (rsord[i] == nn->tok)
				break;

		/* 
		 * Remove `nn' from the chain.  This somewhat
		 * repeats mdoc_node_unlink(), but since we're
		 * just re-ordering, there's no need for the
		 * full unlink process.
		 */
		
		if (NULL != (next = nn->next))
			next->prev = nn->prev;

		if (NULL != (prev = nn->prev))
			prev->next = nn->next;

		nn->prev = nn->next = NULL;

		/* 
		 * Scan back until we reach a node that's
		 * ordered before `nn'.
		 */

		for ( ; prev ; prev = prev->prev) {
			/* Determine order of `prev'. */
			for (j = 0; j < RSORD_MAX; j++)
				if (rsord[j] == prev->tok)
					break;

			if (j <= i)
				break;
		}

		/*
		 * Set `nn' back into its correct place in front
		 * of the `prev' node.
		 */

		nn->prev = prev;

		if (prev) {
			if (prev->next)
				prev->next->prev = nn;
			nn->next = prev->next;
			prev->next = nn;
		} else {
			mdoc->last->child->prev = nn;
			nn->next = mdoc->last->child;
			mdoc->last->child = nn;
		}
	}

	return(1);
}
int main(int argc, char *argv[]) {
    boost::scoped_ptr<pg::tempdb> db;

    try {
        db.reset(new pg::tempdb);
    } catch (const std::exception &e) {
        std::cerr << "Unable to setup database: " << e.what() << "\n";
        return 77; // <-- code to skip this test.
    }

    try {
        boost::shared_ptr<middle_pgsql_t> mid_pgsql(new middle_pgsql_t());
        options_t options;
        options.conninfo = db->conninfo().c_str();
        options.num_procs = 1;
        options.prefix = "osm2pgsql_test";
        options.tblsslim_index = "tablespacetest";
        options.tblsslim_data = "tablespacetest";
        options.slim = 1;

        boost::shared_ptr<geometry_processor> processor = geometry_processor::create("polygon", &options);

        export_list columns;
        { taginfo info; info.name = "building"; info.type = "text"; columns.add(OSMTYPE_WAY, info); }

        boost::shared_ptr<output_multi_t> out_test(new output_multi_t("foobar_buildings", processor, columns, mid_pgsql.get(), options));

        osmdata_t osmdata(mid_pgsql, out_test);

        boost::scoped_ptr<parse_delegate_t> parser(new parse_delegate_t(options.extra_attributes, options.bbox, options.projection));

        osmdata.start();

        if (parser->streamFile("pbf", "tests/liechtenstein-2013-08-03.osm.pbf", options.sanitize, &osmdata) != 0) {
            throw std::runtime_error("Unable to read input file `tests/liechtenstein-2013-08-03.osm.pbf'.");
        }

        parser.reset(NULL);

        osmdata.stop();

        // start a new connection to run tests on
        pg::conn_ptr test_conn = pg::conn::connect(db->conninfo());

        check_count(test_conn, 1, "select count(*) from pg_catalog.pg_class where relname = 'osm2pgsql_test_foobar_buildings'");
        check_count(test_conn, 0, "select count(*) from osm2pgsql_test_foobar_buildings where building is null");
        check_count(test_conn, 3723, "select count(*) from osm2pgsql_test_foobar_buildings");

        //check that we have the right spread
        check_count(test_conn, 1, "select count(*) from osm2pgsql_test_foobar_buildings where building='barn'");
        check_count(test_conn, 1, "select count(*) from osm2pgsql_test_foobar_buildings where building='chapel'");
        check_count(test_conn, 5, "select count(*) from osm2pgsql_test_foobar_buildings where building='church'");
        check_count(test_conn, 3, "select count(*) from osm2pgsql_test_foobar_buildings where building='commercial'");
        check_count(test_conn, 6, "select count(*) from osm2pgsql_test_foobar_buildings where building='farm'");
        check_count(test_conn, 1, "select count(*) from osm2pgsql_test_foobar_buildings where building='garage'");
        check_count(test_conn, 2, "select count(*) from osm2pgsql_test_foobar_buildings where building='glasshouse'");
        check_count(test_conn, 1, "select count(*) from osm2pgsql_test_foobar_buildings where building='greenhouse'");
        check_count(test_conn, 153, "select count(*) from osm2pgsql_test_foobar_buildings where building='house'");
        check_count(test_conn, 4, "select count(*) from osm2pgsql_test_foobar_buildings where building='hut'");
        check_count(test_conn, 8, "select count(*) from osm2pgsql_test_foobar_buildings where building='industrial'");
        check_count(test_conn, 200, "select count(*) from osm2pgsql_test_foobar_buildings where building='residential'");
        check_count(test_conn, 6, "select count(*) from osm2pgsql_test_foobar_buildings where building='roof'");
        check_count(test_conn, 4, "select count(*) from osm2pgsql_test_foobar_buildings where building='school'");
        check_count(test_conn, 2, "select count(*) from osm2pgsql_test_foobar_buildings where building='station'");
        check_count(test_conn, 3, "select count(*) from osm2pgsql_test_foobar_buildings where building='warehouse'");
        check_count(test_conn, 3323, "select count(*) from osm2pgsql_test_foobar_buildings where building='yes'");
        return 0;

    } catch (const std::exception &e) {
        std::cerr << "ERROR: " << e.what() << std::endl;

    } catch (...) {
        std::cerr << "UNKNOWN ERROR" << std::endl;
    }

    return 1;
}
Пример #23
0
static int
hwarn_eq1(POST_ARGS)
{
	return(check_count(mdoc, MDOC_HEAD, CHECK_WARN, CHECK_EQ, 1));
}
Пример #24
0
static int
hwarn_le1(POST_ARGS)
{
	return(check_count(mdoc, MDOC_HEAD, CHECK_WARN, CHECK_LT, 2));
}
Пример #25
0
static cairo_test_status_t
preamble (cairo_test_context_t *ctx)
{
    cairo_surface_t        *surface;
    cairo_t                *cr;
    cairo_rectangle_list_t *rectangle_list;
    const char             *phase;
    cairo_status_t          status;

    surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 0, 0);
    cr = cairo_create (surface);
    cairo_surface_destroy (surface);


    /* first, test basic stuff. This should not be clipped, it should
       return the surface rectangle. */
    phase = "No clip set";
    rectangle_list = cairo_copy_clip_rectangle_list (cr);
    if (! check_count (ctx, phase, rectangle_list, 1) ||
        ! check_clip_extents (ctx, phase, cr, 0, 0, 100, 100) ||
        ! check_rectangles_contain (ctx, phase, rectangle_list, 0, 0, 100, 100))
    {
	goto FAIL;
    }
    cairo_rectangle_list_destroy (rectangle_list);

    /* Test simple clip rect. */
    phase = "Simple clip rect";
    cairo_save (cr);
    cairo_rectangle (cr, 10, 10, 80, 80);
    cairo_clip (cr);
    rectangle_list = cairo_copy_clip_rectangle_list (cr);
    if (! check_count (ctx, phase, rectangle_list, 1) ||
        ! check_clip_extents (ctx, phase, cr, 10, 10, 80, 80) ||
        ! check_rectangles_contain (ctx, phase, rectangle_list, 10, 10, 80, 80))
    {
	goto FAIL;
    }
    cairo_rectangle_list_destroy (rectangle_list);
    cairo_restore (cr);

    /* Test everything clipped out. */
    phase = "All clipped out";
    cairo_save (cr);
    cairo_clip (cr);
    rectangle_list = cairo_copy_clip_rectangle_list (cr);
    if (! check_count (ctx, phase, rectangle_list, 0))
    {
	goto FAIL;
    }
    cairo_rectangle_list_destroy (rectangle_list);
    cairo_restore (cr);

    /* test two clip rects */
    phase = "Two clip rects";
    cairo_save (cr);
    cairo_rectangle (cr, 10, 10, 10, 10);
    cairo_rectangle (cr, 20, 20, 10, 10);
    cairo_clip (cr);
    cairo_rectangle (cr, 15, 15, 10, 10);
    cairo_clip (cr);
    rectangle_list = cairo_copy_clip_rectangle_list (cr);
    if (! check_count (ctx, phase, rectangle_list, 2) ||
        ! check_clip_extents (ctx, phase, cr, 15, 15, 10, 10) ||
        ! check_rectangles_contain (ctx, phase, rectangle_list, 15, 15, 5, 5) ||
        ! check_rectangles_contain (ctx, phase, rectangle_list, 20, 20, 5, 5))
    {
	goto FAIL;
    }
    cairo_rectangle_list_destroy (rectangle_list);
    cairo_restore (cr);

    /* test non-rectangular clip */
    phase = "Nonrectangular clip";
    cairo_save (cr);
    cairo_move_to (cr, 0, 0);
    cairo_line_to (cr, 100, 100);
    cairo_line_to (cr, 100, 0);
    cairo_close_path (cr);
    cairo_clip (cr);
    rectangle_list = cairo_copy_clip_rectangle_list (cr);
     /* can't get this in one tight user-space rectangle */
    if (! check_unrepresentable (ctx, phase, rectangle_list) ||
        ! check_clip_extents (ctx, phase, cr, 0, 0, 100, 100))
    {
	goto FAIL;
    }
    cairo_rectangle_list_destroy (rectangle_list);
    cairo_restore (cr);

    phase = "User space, simple scale, getting clip with same transform";
    cairo_save (cr);
    cairo_scale (cr, 2, 2);
    cairo_rectangle (cr, 5, 5, 40, 40);
    cairo_clip (cr);
    rectangle_list = cairo_copy_clip_rectangle_list (cr);
    if (! check_count (ctx, phase, rectangle_list, 1) ||
        ! check_clip_extents (ctx, phase, cr, 5, 5, 40, 40) ||
        ! check_rectangles_contain (ctx, phase, rectangle_list, 5, 5, 40, 40))
    {
	goto FAIL;
    }
    cairo_rectangle_list_destroy (rectangle_list);
    cairo_restore (cr);

    phase = "User space, simple scale, getting clip with no transform";
    cairo_save (cr);
    cairo_save (cr);
    cairo_scale (cr, 2, 2);
    cairo_rectangle (cr, 5, 5, 40, 40);
    cairo_restore (cr);
    cairo_clip (cr);
    rectangle_list = cairo_copy_clip_rectangle_list (cr);
    if (! check_count (ctx, phase, rectangle_list, 1) ||
        ! check_clip_extents (ctx, phase, cr, 10, 10, 80, 80) ||
        ! check_rectangles_contain (ctx, phase, rectangle_list, 10, 10, 80, 80))
    {
	goto FAIL;
    }
    cairo_rectangle_list_destroy (rectangle_list);
    cairo_restore (cr);

    phase = "User space, rotation, getting clip with no transform";
    cairo_save (cr);
    cairo_save (cr);
    cairo_rotate (cr, 12);
    cairo_rectangle (cr, 5, 5, 40, 40);
    cairo_restore (cr);
    cairo_clip (cr);
    rectangle_list = cairo_copy_clip_rectangle_list (cr);
    if (! check_unrepresentable (ctx, phase, rectangle_list))
	goto FAIL;

FAIL:
    cairo_rectangle_list_destroy (rectangle_list);
    status = cairo_status (cr);
    cairo_destroy (cr);

    return cairo_test_status_from_status (ctx, status);
}
int main(int argc, char *argv[]) {
    std::unique_ptr<pg::tempdb> db;

    try {
        db.reset(new pg::tempdb);
    } catch (const std::exception &e) {
        std::cerr << "Unable to setup database: " << e.what() << "\n";
        return 77; // <-- code to skip this test.
    }

    try {
        options_t options;
        options.conninfo = db->conninfo().c_str();
        options.num_procs = 1;
        options.slim = true;

        options.projection.reset(new reprojection(PROJ_LATLONG));

        options.output_backend = "multi";
        options.style = "tests/test_output_multi_line_trivial.style.json";

        //setup the front (input)
        parse_delegate_t parser(options.extra_attributes, options.bbox, options.projection, options.append);

        //setup the middle
        std::shared_ptr<middle_t> middle = middle_t::create_middle(options.slim);

        //setup the backend (output)
        std::vector<std::shared_ptr<output_t> > outputs = output_t::create_outputs(middle.get(), options);

        //let osmdata orchestrate between the middle and the outs
        osmdata_t osmdata(middle, outputs);

        osmdata.start();

        parser.stream_file("libxml2", "tests/test_output_multi_line_storage.osm", &osmdata);

        osmdata.stop();

        // start a new connection to run tests on
        pg::conn_ptr test_conn = pg::conn::connect(db->conninfo());

        check_count(test_conn, 1, "select count(*) from pg_catalog.pg_class where relname = 'test_line'");
        check_count(test_conn, 3, "select count(*) from test_line");

        //check that we have the number of vertexes in each linestring
        check_count(test_conn, 3, "SELECT ST_NumPoints(way) FROM test_line WHERE osm_id = 1");
        check_count(test_conn, 2, "SELECT ST_NumPoints(way) FROM test_line WHERE osm_id = 2");
        check_count(test_conn, 2, "SELECT ST_NumPoints(way) FROM test_line WHERE osm_id = 3");

        check_count(test_conn, 3, "SELECT COUNT(*) FROM test_line WHERE foo = 'bar'");
        return 0;

    } catch (const std::exception &e) {
        std::cerr << "ERROR: " << e.what() << std::endl;

    } catch (...) {
        std::cerr << "UNKNOWN ERROR" << std::endl;
    }

    return 1;
}
static irqreturn_t msm_ts_irq(int irq, void *dev_id)
{
    struct msm_ts *ts = dev_id;
    struct msm_ts_platform_data *pdata = ts->pdata;
    uint32_t tmp, num_op, num_samp;
    uint32_t tssc_avg12, tssc_avg34, tssc_status, tssc_ctl;
    int x, y, z1, z2;
    int was_down;
    int down;

    tssc_ctl = tssc_readl(ts, TSSC_CTL);
    tssc_status = tssc_readl(ts, TSSC_STATUS);
    tssc_avg12 = tssc_readl(ts, TSSC_AVG_12);
    tssc_avg34 = tssc_readl(ts, TSSC_AVG_34);

    tssc_writel(ts, s_sampling_int, TSSC_SAMPLING_INT);
    setup_next_sample(ts);

#if defined(CONFIG_MACH_MSM7X27_SWIFT)
    y = tssc_avg12 & 0xffff;
    x = tssc_avg12 >> 16;

    z1 = 255;
    z2 = 0;
#else /* original */
    x = tssc_avg12 & 0xffff;
    y = tssc_avg12 >> 16;

    z1 = tssc_avg34 & 0xffff;
    z2 = tssc_avg34 >> 16;
#endif

    /* invert the inputs if necessary */
    if (pdata->inv_x)
        x = pdata->inv_x - x;
    if (pdata->inv_y)
        y = pdata->inv_y - y;
    if (x < 0)
        x = 0;
    if (y < 0)
        y = 0;

    down = !(tssc_ctl & TSSC_CTL_PENUP_IRQ);
    was_down = ts->ts_down;
    ts->ts_down = down;

    /* no valid data */
    if (down && !(tssc_ctl & TSSC_CTL_DATA_FLAG))
        return IRQ_HANDLED;

    if (msm_tsdebug & 2)
        printk("%s: down=%d, x=%d, y=%d, z1=%d, z2=%d, status %x\n",
               __func__, down, x, y, z1, z2, tssc_status);

    if (!was_down && down) {
        struct ts_virt_key *vkey = NULL;

        if (pdata->vkeys_y && (y > pdata->virt_y_start))
            vkey = find_virt_key(ts, pdata->vkeys_y, x);
        if (!vkey && ts->pdata->vkeys_x && (x > pdata->virt_x_start))
            vkey = find_virt_key(ts, pdata->vkeys_x, y);

        if (vkey) {
            WARN_ON(ts->vkey_down != NULL);
            if (msm_tsdebug)
                printk(KERN_INFO "%s: virtual key down %d\n",
                       __func__, vkey->key);
            ts->vkey_down = vkey;
            input_report_key(ts->input_dev, vkey->key, 1);
            input_sync(ts->input_dev);
            return IRQ_HANDLED;
        }
    } else if (ts->vkey_down != NULL) {
        if (!down) {
            if (msm_tsdebug)
                printk(KERN_INFO "%s: virtual key up %d\n", __func__,
                       ts->vkey_down->key);
            input_report_key(ts->input_dev, ts->vkey_down->key, 0);
            input_sync(ts->input_dev);
            ts->vkey_down = NULL;
        }
        if (y > 650)
            mod_timer(&ts->timer,
                      jiffies + msecs_to_jiffies(s_penup_time));

        return IRQ_HANDLED;
    }
    if (down) {
        if ((check_count(ts, x, y) != false) && (ts_check_region(ts, x, y) != false)) {
            input_report_abs(ts->input_dev, ABS_X, x);
            input_report_abs(ts->input_dev, ABS_Y, y);
            input_report_abs(ts->input_dev, ABS_PRESSURE, z1);
            input_report_key(ts->input_dev, BTN_TOUCH, down);
            input_sync(ts->input_dev);
        }
        mod_timer(&ts->timer,
                  jiffies + msecs_to_jiffies(TS_PENUP_TIMEOUT_MS));
    } else {
        input_report_key(ts->input_dev, BTN_TOUCH, down);
        input_sync(ts->input_dev);
    }
    ts->count = down;
    touch_press = down;

    if (down == 0)
        ts->count1 = down;

    return IRQ_HANDLED;
}