Exemple #1
0
ppm<color> rand_ppm(image_coordinate_t w=Rand.next_int(50,200),
		    image_coordinate_t h=Rand.next_int(50,200),
		    rgb<color> bc=rgb<color> 
		    (Rand.next_int(256),Rand.next_int(256),Rand.next_int(256))){

  ppm<color> p(w,h,bc);
  for(int y=0;y<p.height();++y){
    for(int x=0;x<p.width();++x){
      p(x,y)=rand_rgb<color>();
    }
  }
  return p;
}
Exemple #2
0
ratio<int> gen_ratio(){
  static pfi::math::random::random<mersenne_twister> r;
  int num=r.next_int(0,1000)-500;
  int den=r.next_int(0,1000)-500;
  if(den>=0)++den;
  if(num>=0)++num;
  return ratio<int>(num,den);
}
Exemple #3
0
TEST(ppm,out_of_range_access_safety){
  for(int n=0;n<N;++n){
    ppm<uint8_t> p=rand_ppm<uint8_t>(), p_orig=p;
    for(int t=0;t<100;++t){
      int x,y; 
      *((uint32_t*)&x)=Rand.next_int();
      *((uint32_t*)&y)=Rand.next_int();
      EXPECT_TRUE(p(x,y)==p.bgcolor);
      p(x,y)=rand_rgb<uint8_t>();
    }

    for(int y=0;y<p.height();++y){
      for(int x=0;x<p.width();++x){
	p(x,y)==p_orig(x,y);
      }
    }
  }
}
Exemple #4
0
rgb<color> rand_rgb(){
  return rgb<color>((color)Rand.next_int(256),
		    (color)Rand.next_int(256),
		    (color)Rand.next_int(256));
}