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

version» Context lines:

pike.git/src/modules/Image/testsuite.in:1:   START_MARKER - dnl $Id$ +       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:539:      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_do( img()->randomgrey() )      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) )
pike.git/src/modules/Image/testsuite.in:694:    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,[[ +  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:777:   ]],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:800:   dnl ]],)   dnl test_encoding(WBMP,[[   dnl object c=Image.Colortable(({Image.Color.white,Image.Color.black}));   dnl img=c*img;   dnl ]],)   test_encoding(XBM,[[    object c=Image.Colortable(({Image.Color.white,Image.Color.black}));    img=c*img;   ]],)    + cond_resolv( Image.PNG.decode_header, [[    test_equal( Image.PNG.decode_header(Image.PNG.encode(Image.Image(20,20))),    (["bpp":8, "type":2, "xsize":20, "ysize":20 ]) ) -  + ]])    -  + cond_resolv( Image.PNG.encode, [[    test_true( Image.PNG.encode(Image.Image(5,5)) )    test_true( Image.PNG.encode(Image.Image(5,5), ([])) )    test_true( Image.PNG.encode(Image.Image(5,5), (["alpha":0])) )    test_eval_error( Image.PNG.encode(Image.Image(5,5), (["alpha":"x"])) )    test_eval_error( Image.PNG.encode(Image.Image(5,5), (["alpha":Image.Image(4,4)])) )    test_true( Image.PNG.encode(Image.Image(5,5), (["alpha":Image.Image(5,5)])) )    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])) )   ]]) - test_true( Image.PNG.encode(Image.Image(5,5), (["zstrategy":Gz.HUFFMAN_ONLY])) ) +    cond_resolv( Gz.FIXED, [[    test_true( Image.PNG.encode(Image.Image(5,5), (["zstrategy":Gz.FIXED])) )   ]])      cond( (master()->resolv("Image.XFace")||([]))->encode,[[    test_any([[    object img=Image.Image(48,48)->test(43);    object c=Image.Colortable(({Image.Color.white,Image.Color.black}));    c->floyd_steinberg();    img=c*img;    return Image.XFace.decode(Image.XFace.encode(img))==img;    ]],1)   ]])      test_encoding(XPM,[[    object c=Image.Colortable(16,16,16);    img=c*img;   ]],[[,(["colortable":c]) ]])   test_encoding(TIFF,,)   END_MARKER