delete database picturetest; create database picturetest; open database picturetest; # # create test pictures # #stop Test disabled since it produces many differnt results on 64 bit linux #testcase "create pic1" #yields success let pic1 = [ const picture value ( "test-nebel-orig.jpg" "2004-12-01-00:26:40.740" "test" FALSE test-nebel-orig.jpg ) ] #testcase "create pic2" #yields success let pic2 = [ const picture value ( "test-nebel-scaled1.jpg" "2004-12-02-00:26:40.740" "test" FALSE test-nebel-scaled1.jpg ) ] #testcase "create pic3" #yields success let pic3 = [ const picture value ( "test-nebel-scaled2.jpg" "2004-12-03-00:26:40.740" "test" FALSE test-nebel-scaled2.jpg ) ] #testcase "create pic4" #yields success let pic4 = [ const picture value ( "test-nebel-cut.jpg" "2004-12-04-00:26:40.740" "test" FALSE test-nebel-cut.jpg ) ] #testcase "create pic5" #yields success let pic5 = [ const picture value ( "test-nebel-flipped0.jpg" "2004-12-05-00:26:40.740" "test" FALSE test-nebel-flipped0.jpg ) ] #testcase "create pic6" #yields success let pic6 = [ const picture value ( "test-nebel-flipped1.jpg" "2004-12-06-00:26:40.740" "test" FALSE test-nebel-flipped1.jpg ) ] #testcase "create pic7" #yields success let pic7 = [ const picture value ( "test-nebel-flipped2.jpg" "2004-12-07-00:26:40.740" "test" FALSE test-nebel-flipped2.jpg ) ] #testcase "create pic8" #yields success let pic8 = [ const picture value ( "test-nebel-flipped3.jpg" "2004-12-08-00:26:40.740" "test" FALSE test-nebel-flipped3.jpg ) ] #testcase "create pic9" #yields success let pic9 = [ const picture value ( "test-nebel-mirrored1.jpg" "2004-12-09-00:26:40.740" "test" FALSE test-nebel-mirrored1.jpg ) ] #testcase "create pic10" #yields success let pic10 = [ const picture value ( "test-nebel-mirrored2.jpg" "2004-12-10-00:26:40.740" "test" FALSE test-nebel-mirrored2.jpg ) ] #testcase "create pic14" #yields success let pic14 = [ const picture value ( "test-nebel-grayscale.jpg" "2004-12-14-00:26:40.740" "test" FALSE test-nebel-grayscale.jpg ) ] #testcase "create pic15" #yields success let pic15 = [ const picture value ( "test-nebel-rgb.jpg" "2004-12-15-00:26:40.740" "test" FALSE test-rgb.jpg ) ] # # create test relation # #testcase "create rel1" #yields success (create rel1 : (rel (tuple ((id int) (pic picture))))) #testcase "update rel1" #yields success (update rel1 := ((rel (tuple ((id int) (pic picture)))) ((1 ("test-nebel-orig.jpg" "2004-12-01-00:26:40.740" "test" FALSE test-nebel-orig.jpg )) (2 ("test-nebel-scaled1.jpg" "2004-12-02-00:26:40.740" "test" FALSE test-nebel-scaled1.jpg )) (3 ("test-nebel-scaled2.jpg" "2004-12-03-00:26:40.740" "test" FALSE test-nebel-scaled2.jpg )) (4 ("test-rgb.jpg" "2004-12-03-00:26:40.740" "test" FALSE test-rgb.jpg ))))) # # test simple operators # #testcase "pic1 getHeight" #yields (int 533) query pic1 getHeight #testcase "pic1 getWidth" #yields (int 800) query pic1 getWidth #testcase "pic1 isgrayscale" #yields (bool FALSE) query pic1 isgrayscale #testcase "pic14 isgrayscale" #yields (bool TRUE) query pic14 isgrayscale #testcase "pic1 getFilename" #yields (string "test-nebel-orig.jpg") query pic1 getFilename #testcase "pic1 getCategory" #yields (string "test") query pic1 getCategory #testcase "pic1 picturedate" #yields (instant "2004-12-01-00:26:40.740") query pic1 picturedate #testcase "pic1 isportrait" #yields (bool FALSE) query pic1 isportrait #testcase "compare pic1 and pic1 with simpleequals" #yields (bool TRUE) query pic1 simpleequals pic1 #testcase "compare pic1 and pic2 with simpleequals" #yields (bool FALSE) query pic1 simpleequals pic2 #testcase "getHeight on undef" #yields (int undef) query pic1 flipleft [ -1 ] getHeight #testcase "getWidth on undef" #yields (int undef) query pic1 flipleft [ -1 ] getWidth #testcase "isgrayscale on undef" #yields (bool undef) query pic1 flipleft [ -1 ] isgrayscale #testcase "getFilename on undef" #yields (string undef) query pic1 flipleft [ -1 ] getFilename #testcase "getCategory on undef" #yields (string undef) query pic1 flipleft [ -1 ] getCategory #testcase "getPictureDate on undef" #yields (instant undef) query pic1 flipleft [ -1 ] getPictureDate #testcase "isportrait on undef" #yields (bool undef) query pic1 flipleft [ -1 ] isportrait #testcase "compare with simplequals on undef #1" #yields (bool undef) query pic1 flipleft [ -1 ] simpleequals pic1 #testcase "compare with simpleequals on undef #2" #yields (bool undef) query pic1 simpleequals (pic1 flipleft [ -1 ]) # # test scale # #testcase "compare scaled pic1 and pic2" #yields (bool TRUE) query pic1 scale [ 1600, 1066 ] simpleequals pic2 #testcase "compare scaled pic1 and pic3" #yields (bool TRUE) query pic1 scale [ 400, 266 ] simpleequals pic3 #testcase "invalid scale (1)" #yields (picture undef) query pic1 scale [ 0, 100 ] #testcase "invalid scale (2)" #yields (picture undef) query pic1 scale [ 100, 0 ] #testcase "scale results in portrait format" #yields (bool TRUE) query pic1 scale [ 100, 200 ] isportrait #testcase "scale results in landscape format" #yields (bool FALSE) query pic1 scale [ 200, 100 ] isportrait #testcase "scale on undef" #yields (picture undef) query pic1 flipleft [ -1 ] scale [ 50, 50 ] # # test cut # #testcase "compare cut pic1 and pic4" #yields (bool TRUE) query pic1 cut [ 150, 150, 500, 233 ] simpleequals pic4 #testcase "invalid cut (1)" #yields (picture undef) query pic1 cut [ -1, 150, 500, 233 ] #testcase "invalid cut (2)" #yields (picture undef) query pic1 cut [ 150, -1, 500, 233 ] #testcase "invalid cut (3)" #yields (picture undef) query pic1 cut [ 150, 150, 0, 233 ] #testcase "invalid cut (4)" #yields (picture undef) query pic1 cut [ 150, 150, 500, 0 ] #testcase "invalid cut (5)" #yields (picture undef) query pic1 cut [ 301, 150, 500, 233 ] #testcase "invalid cut (6)" #yields (picture undef) query pic1 cut [ 150, 301, 500, 233 ] #testcase "cut results in portrait format" #yields (bool TRUE) query pic1 cut [ 150, 150, 100, 200 ] isportrait #testcase "cut results in landscape format" #yields (bool FALSE) query pic1 cut [ 150, 150, 200, 100 ] isportrait #testcase "cut on undef" #yields (picture undef) query pic1 flipleft [ -1 ] cut [ 50, 50, 50, 50 ] # # test flip # #testcase "compare flipped pic1 and pic5 (1)" #yields (bool TRUE) query pic1 flipleft [ 0 ] simpleequals pic5 #testcase "compare flipped pic1 and pic6 (1)" #yields (bool TRUE) query pic1 flipleft [ 1 ] simpleequals pic6 #testcase "compare flipped pic1 and pic7" #yields (bool TRUE) query pic1 flipleft [ 2 ] simpleequals pic7 #testcase "compare flipped pic1 and pic8" #yields (bool TRUE) query pic1 flipleft [ 3 ] simpleequals pic8 #testcase "compare flipped pic1 and pic5 (2)" #yields (bool TRUE) query pic1 flipleft [ 4 ] simpleequals pic5 #testcase "compare flipped pic1 and pic6 (2)" #yields (bool TRUE) query pic1 flipleft [ 5 ] simpleequals pic6 #testcase "invalid flipleft" #yields (picture undef) query pic1 flipleft [ -1 ] #testcase "flipleft results in portrait format #1" #yields (bool TRUE) query pic1 flipleft [ 1 ] isportrait #testcase "flipleft results in landscape format #1" #yields (bool FALSE) query pic1 flipleft [ 2 ] isportrait #testcase "flipleft results in portrait format #2" #yields (bool TRUE) query pic1 flipleft [ 3 ] isportrait #testcase "flipleft results in landscape format #2" #yields (bool FALSE) query pic1 flipleft [ 4 ] isportrait #testcase "flipleft on undef" #yields (picture undef) query pic1 flipleft [ -1 ] flipleft [ 1 ] # # test mirror # #testcase "compare mirrored pic1 and pic9" #yields (bool TRUE) query pic1 mirror [ TRUE ] simpleequals pic9 #testcase "compare mirrored pic1 and pic10" #yields (bool TRUE) query pic1 mirror [ FALSE ] simpleequals pic10 #testcase "pic15 like (1)" #yields (bool TRUE) query pic15 like [ 3, 2, 250, 255 ] #testcase "pic15 like (2)" #yields (bool FALSE) query pic15 like [ 10, 2, 250, 255 ] #testcase "pic15 like (3)" #yields (bool TRUE) query pic15 like [ 15, 2, 0, 0 ] #testcase "mirror on undef" #yields (picture undef) query pic1 flipleft [ -1 ] mirror [ TRUE ] # # test histogram operations # #testcase "pic15 like (4)" #yields (bool FALSE) query pic15 like [ 5, 2, 0, 0 ] #testcase "pic15 like (5)" #yields (bool TRUE) query pic15 like [ 21.0, 1.0, 0, 9 ] #testcase "pic15 like (6)" #yields (bool FALSE) query pic15 like [ 21.0, 1.0, 0, 50 ] #testcase "pic1 equals pic1" #yields (real 0.0) query pic1 pic1 equals [ 1, 0 ] #testcase "pic1 equals pic2" #yields (bool TRUE) query (pic1 pic2 equals [ 1, 0 ]) < 3.7 #testcase "pic1 equals pic6" #yields (bool TRUE) query (pic1 pic6 equals [ 1, 0 ]) < 4.7 #testcase "pic1 equals pic6" #yields (bool TRUE) query (pic1 pic6 equals [ 1, 1 ]) < 4.7 #testcase "pic1 equals scaled pic1 (1)" #yields (bool TRUE) query (pic1 scale [ 25, 15 ] pic1 equals [ 5, 1 ]) < 29.0 #testcase "pic1 equals scaled pic1 (2)" #yields (bool TRUE) query (pic1 scale [ 25, 15 ] pic1 equals [ 6, 1 ]) < 26.0 #testcase "invalid like (1)" #yields (bool undef) query pic1 like [ 1, 2, 0, 255 ] #testcase "invalid like (2)" #yields (bool undef) query pic1 like [ 99, 2, 0, 255 ] #testcase "invalid like (3)" #yields (bool undef) query pic1 like [ 50, 2, -1, 255 ] #testcase "invalid like (4)" #yields (bool undef) query pic1 like [ 50, 2, 0, 256 ] #testcase "invalid like (5)" #yields (bool undef) query pic1 like [ 1.0, 2.0, 0, 255 ] #testcase "invalid like (6)" #yields (bool undef) query pic1 like [ 99.0, 2.0, 0, 255 ] #testcase "invalid like (7)" #yields (bool undef) query pic1 like [ 50.0, 2.0, -1, 255 ] #testcase "invalid like (8)" #yields (bool undef) query pic1 like [ 50.0, 2.0, 0, 256 ] #testcase "invalid colordist" #yields (histogram undef) query pic1 colordist [ 4 ] #testcase "like on undef #1" #yields (bool undef) query pic1 flipleft [ -1 ] like [ 50, 2, 0, 50 ] #testcase "like on undef #2" #yields (bool undef) query pic1 flipleft [ -1 ] like [ 50.0, 2.0, 0, 50 ] #testcase "equals on undef #1" #yields (real undef) query pic1 flipleft [ -1 ] pic1 equals [ 50, 2 ] #testcase "equals on undef #2" #yields (real undef) query pic1 pic1 flipleft [ -1 ] equals [ 50, 2 ] # # test picture and histogram in relations # (as there are no operations on histograms, testing is a bit limited) # #testcase "rel1 operation (1)" #yields (int 1) query rel1 feed filter [ .pic like [ 21.0, 1.0, 0, 9 ] ] count #testcase "rel1 operation (2)" #yields (int 1) query rel1 feed filter [ .pic pic1 equals [ 1, 0 ] = 0.0 ] count #testcase "rel1 operation (3)" #yields (int 3) query rel1 feed filter [ .pic pic1 equals [ 5, 100 ] < 3.0 ] count #testcase "rel1 operation (4)" #yields (int 1) query rel1 feed filter [ .pic pic1 equals [ 1, 0 ] = 0.0 ] extend [ pic_hist_red: .pic colordist [ 0 ], pic_hist_green: .pic colordist [ 1 ], pic_hist_blue: .pic colordist [ 2 ], pic_hist_brightness: .pic colordist [ 3 ] ] count #testcase "rel1 operation (5)" #yields (int 1) query rel1 feed extend [ pic_hist_red: .pic colordist [ 0 ], pic_hist_green: .pic colordist [ 1 ], pic_hist_blue: .pic colordist [ 2 ], pic_hist_brightness: .pic colordist [ 3 ] ] filter [ .pic pic1 equals [ 1, 0 ] = 0.0 ] count #testcase "rel1 operation (6)" #yields (int 1) query rel1 feed extend [ pic_hist_red: .pic colordist [ 0 ], pic_hist_green: .pic colordist [ 1 ], pic_hist_blue: .pic colordist [ 2 ], pic_hist_brightness: .pic colordist [ 3 ], pica: .pic colordist [ -1 ], picb: .pic scale [ -1, -1 ], picc: .pic flipleft [ -1 ] colordist [ 4 ], picd: .pic cut [ -1, -1, -1, -1 ] ] filter [ .pic pic1 equals [ 1, 0 ] = 0.0 ] count #teardown close database;