pike.git / src / modules / Image / testsuite.in

version» Context lines:

pike.git/src/modules/Image/testsuite.in:1:   START_MARKER      test_eq([[ Image.PNM.decode("P1\n5 5\n0 1 1 1 1\n1 0 1 1 1\n"    "1 1 0 1 1\n1 1 1 0 1\n1 1 1 1 0") ]],   Image.PNM.decode("P4\n5 5\nx¸Øèð") )      test_eq([[ Image.GIF.decode(MIME.decode_base64(    "R0lGODlhBQAFAIAAAAAAAP///ywAAAAABQAFAAACCAxwEWrY8BwoADs=")) ]],   Image.PNM.decode("P4\n5 5\nx\00èØèð") )    + dnl netpbm wikipedia examples + test_do(add_constant("IMAGE",lambda(string in) { return decode_value(Gz.uncompress(String.hex2string(in))); })) + test_eq(Image.PNM.decode(#{P1 + # This is an example bitmap of the letter "J" + 6 10 + 0 0 0 0 1 0 + 0 0 0 0 1 0 + 0 0 0 0 1 0 + 0 0 0 0 1 0 + 0 0 0 0 1 0 + 0 0 0 0 1 0 + 1 0 0 0 1 0 + 0 1 1 1 0 0 + 0 0 0 0 0 0 + 0 0 0 0 0 0 + #}), IMAGE("78dadb969d6a90fc9423e1010713071bdb86ff48808181e13f2aa0ae08b2389ccd0003ff89060072d39782")) +  + test_eq(Image.PNM.decode(#{P2 + # Shows the word "FEEP" (example from Netpbm man page on PGM) + 24 7 + 15 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 3 3 3 3 0 0 7 7 7 7 0 0 11 11 11 11 0 0 15 15 15 15 0 + 0 3 0 0 0 0 0 7 0 0 0 0 0 11 0 0 0 0 0 15 0 0 15 0 + 0 3 3 3 0 0 0 7 7 7 0 0 0 11 11 11 0 0 0 15 15 15 15 0 + 0 3 0 0 0 0 0 7 0 0 0 0 0 11 0 0 0 0 0 15 0 0 0 0 + 0 3 0 0 0 0 0 7 7 7 7 0 0 11 11 11 11 0 0 15 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + #}), IMAGE("78dadb969d6a90fc9423e101870807b31bc31706ea01632400112947021091dd480022f21f09c0cd413319ae1d0ee0dae100ae1dd91c64c720bb07d91c64c7d0c23dc8e183690e31e1c34003000052ea5e1c")) +  + test_eq(Image.PNM.decode(#{P3 + # The P3 means colors are in ASCII, then 3 columns and 2 rows, + # then 255 for max color, then RGB triplets + 3 2 + 255 + 255 0 0 0 255 0 0 0 255 + 255 255 0 255 255 255 0 0 0 + #}), IMAGE("78dadb969d6a90fc9423e1c18b156c7cff191818c0f8ff7f3066600000dfef0de3")) +  + test_eq(Image.PNM.decode(#{P3 + # The same image with width 3 and height 2, + # using 0 or 1 per color (red, green, blue) + 3 2 1 + 1 0 0 0 1 0 0 0 1 + 1 1 0 1 1 1 0 0 0 + #}), IMAGE("78dadb969d6a90fc9423e1c18b156c7cff191818c0f8ff7f3066600000dfef0de3")) +  + test_eq(Image.PNM.decode("P3 3 2 1 1 0 0 0 1 0 0 0 1 1 1 0 1 1 1 0 0 0"), IMAGE("78dadb969d6a90fc9423e1c18b156c7cff191818c0f8ff7f3066600000dfef0de3")) +  + test_eval_error(Image.PNM.decode("P2 1 1 0 0")) +  + test_eq(Image.PNM.decode("P4\n" +  "3 3\n" +  "\240@\240"), IMAGE("78dadb969d6a90fc9423e1c10b7d3671060686ffffff63250165b1116f")) +  + test_do(add_constant("IMAGE")) +    test_true( objectp(Image.Image()) )   test_false( Image.Image()->xsize() )   test_false( Image.Image()->ysize() )      test_true( objectp(Image.Image(100,100)) )   test_eq( Image.Image(100,100)->xsize(), 100)   test_eq( Image.Image(100,100)->ysize(), 100)   test_false( Image.Image(100,100)!=0 )      test_do([[
pike.git/src/modules/Image/testsuite.in:421:   test_do( img()->color(128,128,255) )      test_do( img()->copy() )   test_do( img()->copy(5,5,45,45) )   test_do( img()->copy(-5,-5,55,55) )   test_do( img()->copy(-5,-5,55,55,255,0,0) )   test_do( img()->copy(-5,-5,55,55,255,0,0,99) )      test_do( Image.Image() )   test_do( Image.Image(100,100) ) - test_do( Image.Image(100,100, Image.Color("red")) ) - test_do( Image.Image(100,100, "red") ) - test_do( Image.Image(100,100, "grey", 128) ) - test_do( Image.Image(100,100, "rgb", 11,22,33) ) - test_do( Image.Image(100,100, "cmyk", 10,20,30,40) ) + test_eq( (string)Image.Image(1,1, Image.Color("red")), "\377\0\0" ) + test_eq( (string)Image.Image(1,1, "red"), "\377\0\0" ) + test_eq( (string)Image.Image(1,1, "grey"), "\276\276\276") + test_eq( (string)Image.Image(1,1, "grey", 128), "\200\200\200") + test_eq( (string)Image.Image(1,1, "rgb", 11,22,33), "\v\26!" ) + test_eq( (string)Image.Image(1,1, "cmyk", 10,20,30,40), "\316\306\275" )   test_do( Image.Image(100,100, "test") )   test_do( Image.Image(100,100, "gradients") )   test_do( Image.Image(100,100, "noise",    ({0, ({0,0,0}), 0.8, ({255,255,255}) }) ) )   test_do( Image.Image(100,100, "turbulence",    ({0, ({0,0,0}), 0.8, ({255,255,255}) }) ) )   test_do( Image.Image(100,100, "random") )   test_do( Image.Image(100,100, "randomgrey") )   test_do( Image.Image(100,100, "tuned_box",    ({ Image.Color.black, Image.Color.black,    Image.Color.white, Image.Color.white}) ) )   test_eval_error( Image.Image(100,100, "bacon") ) - test_do( Image.Image(100,100, 255,255,0) ) + test_eq( (string)Image.Image(1,1, 255,255,0), "\377\377\0" )   dnl test_do( Image.Image(100,100, 255,255,0,40) ) -  + test_eq( (string)Image.Image(Image.Image(1,1,"red")), "\377\0\0" )      test_do( img()->dct(100,100) ) -  + test_do( img()->dct(0,0) )      test_do( img()->distancesq() )   test_do( img()->distancesq(0,255,255) )    - // find_autocrp above + // find_autocrop above      // MISSING TEST: find_max   // MISSING TEST: find_min      test_do( img()->gamma(0.8) )   test_do( img()->gamma(0.9, 0.8, 1.1) )      // MISSING TEST: get_pixel   // MISSING TEST: gradients   
pike.git/src/modules/Image/testsuite.in:538:      test_do( img()->phaseh() )   test_do( img()->phasev() )   test_do( img()->phasevh() )   test_do( img()->phasehv() )      test_do( Image.Image(100,100)->setcolor(255,0,0,128)->    polyfill( ({20,20, 80,20, 80,80 }) ) )      test_true( img()->random() != img()->random() ) - test_true( img()->random(17) == img()->random(17) ) + test_eq( (string)Image.Image(4,4)->random(42), + String.hex2string("aacb8f50fe20afc5db8d2f676a5e56bd8dc87ac09bc2805b34156d026685411a793213af0518233d7bf0439233d7a6fc") ) + test_do( img()->random(Random.Deterministic(42)->random_string) )    - test_do( img()->randomgrey() ) + test_do( img()->randomgrey() != img()->randomgrey() ) + test_eq( (string)Image.Image(4,4)->randomgrey(42), + String.hex2string("bdbdbd5656565e5e5e6a6a6a6767672f2f2f8d8d8ddbdbdbc5c5c5afafaf202020fefefe5050508f8f8fcbcbcbaaaaaa") ) + test_do( img()->randomgrey(Random.Deterministic(42)->random_string) )      test_eq( img()->write_lsb_rgb("hello")->read_lsb_rgb(), "hello"+"\0"*933 )   test_eq( img()->write_lsb_grey("hello")->read_lsb_grey(), "hello"+"\0"*308 )      test_do( img()->rgb_to_hsv() )      test_do( img()->rotate(17) )   test_do( img()->rotate(33.333) )   test_do( img()->rotate(44, 250, 1, 2) )   
pike.git/src/modules/Image/testsuite.in:591:   test_do( img()->skewx(22.8, 100, 75, 26) )      test_do( img()->skewy(10) )   test_do( img()->skewy(16.4) )   test_do( img()->skewy(13, 26, 36, 47) )   test_do( img()->skewy(22.8, 100, 75, 26) )      // sum tests above   // sumf tests above    - // test tests above + test_any([[ +  string i = (string)Image.Image(4,4)->test(42); +  string expected = String.hex2string("f15a00af68556c879b539aac904c946c70ad35a0cd35aebf5000fe4a77e100bafc24cbb2a0b4ff6393e32dc3b929ff67"); +  if (i == expected) return 0; +  // The test image is generated with doubles, and my be off by 1 +  // in a few places if the mantissa is small. +  if (sizeof(i) != sizeof(expected)) return String.string2hex(i); +  for (int j = 0; j < sizeof(i); j++) { +  if ((i[j] > expected[j] + 1) || (i[j] < expected[j] - 1)) { +  return String.string2hex(i); +  } +  }    -  +  // All pixels are within the tolerance limits. +  return 0; + ]], 0) + test_do( img()->test(Random.Deterministic(42)->random) ) +    test_do( img()->threshold() )   test_do( img()->threshold(28) )   test_do( img()->threshold(128, 255, 111) )   test_do( img()->threshold(Image.Color.green) )      test_do( img()->tuned_box(10,10,40,40,    ({({255,0,0}),({255,255,255}),({128,100,0}),({0,70,255})}) ) )   test_do( img()->tuned_box(10,10,40,40,    ({({255,0,0,0}),({255,255,255,240}),({128,100,0,230}),({0,70,255,7})}) ) )   
pike.git/src/modules/Image/testsuite.in:693:    test_true( img-(c*img)<32 )    test_do( add_constant("c") )   ]])      test_true( Image.Colortable(Image.Image(10,10)->randomgrey())->greyp() )   test_false( Image.Colortable(Image.Image(10,10,255,0,0))->greyp() )         dnl #### Encodings    + define(test_image_any,[[ +  cond_resolv(Image.$1, [[ +  test_any([[ +  return Image.ANY.decode(Image.$1.encode(Image.Image(10,10)))->xsize(); +  ]],10) +  test_any([[ +  mapping m=Image.ANY._decode(Image.$1.encode(Image.Image(10,10))); +  if(!m->image || !m->type) return -1; +  if(!has_prefix(m->type, "image/")) return -2; +  return 1; +  ]], 1) +  ]]) + ]]) +  + ; Missing tests for XCF, PSD, TIM, XWD + test_image_any(PNM) + test_image_any(JPEG) + test_image_any(PNG) + test_image_any(GIF) + test_image_any(ILBM) + test_image_any(BMP) + test_image_any(RAS) + test_image_any(PVR) + test_image_any(PCX) +  +    define(test_encoding,[[    cond( (master()->resolv("Image.$1")||([]))->encode,[[    test_any([[    object img=Image.Image(100,100)->test(40);    $2    object img1=Image.$1.decode(Image.$1.encode(img$3));    return img==img1;    ]],1)    ]])   ]])
pike.git/src/modules/Image/testsuite.in:776:   ]],1)      test_encoding(ILBM,[[    img=Image.Colortable(img,16)*img;   ]],)      cond( (master()->resolv("Image.JPEG")||([]))->encode,[[    test_any([[    object img=Image.Image(100,100)->test(43);    object img1=Image.JPEG.decode(Image.JPEG.encode(img,(["quality":100]))); -  return img-img1<10; +  return img-img1<20;    ]],1)   ]])      test_encoding(PCX,,)   test_encoding(PNG,,)   test_encoding(PNM,,)   dnl test_encoding(PVR,,)   test_encoding(RAS,,)   test_encoding(TGA,,)   dnl test_encoding(WBF,[[
pike.git/src/modules/Image/testsuite.in:821:    dnl FIXME: Test that alpha is actually encoded    dnl FIXME: Test "palette" attribute    test_eval_error( Image.PNG.encode(Image.Image(5,5), (["zlevel":"x"])) )    test_true( Image.PNG.encode(Image.Image(5,5), (["zlevel":0])) )    test_true( Image.PNG.encode(Image.Image(5,5), (["zlevel":9])) )    test_true( Image.PNG.encode(Image.Image(5,5), (["zstrategy":Gz.DEFAULT_STRATEGY])) )    test_true( Image.PNG.encode(Image.Image(5,5), (["zstrategy":Gz.FILTERED])) )    test_true( Image.PNG.encode(Image.Image(5,5), (["zstrategy":Gz.HUFFMAN_ONLY])) )   ]])    + cond_resolv( Image.PSD.decode, [[ +  test_true( arrayp(Image.decode_layers(Stdio.read_bytes("SRCDIR/corner2.psd"), +  ([ "crop_to_bounds":1 ]))) ) + ]]) +    dnl ACK! cond_resolv does not nest. But if Gz.RLE or Gz.FIXED exists, it   dnl means the Gz module is there, and in that case Image.PNG should be too...   cond_resolv( Gz.RLE, [[    test_true( Image.PNG.encode(Image.Image(5,5), (["zstrategy":Gz.RLE])) )   ]])   cond_resolv( Gz.FIXED, [[    test_true( Image.PNG.encode(Image.Image(5,5), (["zstrategy":Gz.FIXED])) )   ]])      cond( (master()->resolv("Image.XFace")||([]))->encode,[[