Beispiel #1
0
void compute(fractal* f){
	int i, j;
	int sum = 0;
	for(i=0; i < fractal_get_height(f); i++){
		for(j=0; j < fractal_get_width(f); j++){
			fractal_compute_value(f,i,j);
			sum+=fractal_get_value(f,i,j);
		}
	}
	f->avg=(sum*1.0)/(f->height*f->width);
}
void test_libfractal_get_set_value() {
	fractal_t *ptr = fractal_new(name, 10, 10, a, b);
	int w = fractal_get_width(ptr);
	int h = fractal_get_height(ptr);
	int x = 0;
	int y = 0;
	for ( y = 0; y < h ; y++) {
		for( x = 0; x < w ; x++)  {
			fractal_set_value(ptr, x, y, x+y*10);
		}
	}

	for ( y = 0; y < h ; y++) {
		for( x = 0; x < w ; x++)  {
			CU_ASSERT_EQUAL(fractal_get_value(ptr, x, y), x+y*10);
		}
	}

	fractal_free(ptr);
}