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

version» Context lines:

pike.git/src/modules/MIME/testsuite.in:1:   START_MARKER    - // MIME - test_true([[objectp(MIME)]]) - test_true([[programp(MIME.Message)]]) -  +    // Global functions      // Bug 3171   test_eq([[(MIME.parse_headers("\r\nBody\r\n\r\nMore Body\r\n")[1])]],    "Body\r\n\r\nMore Body\r\n")   test_eq([[(MIME.parse_headers("\nBody\n\nMore Body\n")[1])]],    "Body\n\nMore Body\n")    - test_eq([[MIME.decode_base64("Zm9vCg==")]],"foo\n") - test_eq([[MIME.encode_base64("bar")]],"YmFy") - test_eq([[MIME.encode_base64("bar ")]],"YmFyIA==") - test_eq([[MIME.encode_base64("bar ")]],"YmFyICA=") - test_eq([[MIME.encode_base64("bar ")]],"YmFyICAg") + define(test_base64,[[ +  test_eq(MIME.encode_base64($1),$2) +  test_eq(MIME.decode_base64($2),$1) + ]]) + define(test_base64url,[[ +  test_eq(MIME.encode_base64url($1),$2) +  test_eq(MIME.decode_base64url($2),$1) + ]]) +  + // Test vectors from RFC 4648 + test_base64("","") + test_base64("f","Zg==") + test_base64("fo","Zm8=") + test_base64("foo","Zm9v") + test_base64("foob","Zm9vYg==") + test_base64("fooba","Zm9vYmE=") + test_base64("foobar","Zm9vYmFy") + test_base64url("","") + test_base64url("f","Zg") + test_base64url("fo","Zm8") + test_base64url("foo","Zm9v") + test_base64url("foob","Zm9vYg") + test_base64url("fooba","Zm9vYmE") + test_base64url("foobar","Zm9vYmFy") +  + test_base64("\0\0\0", "AAAA") + test_base64("\0\377", "AP8=") + test_base64url("\0\0\0", "AAAA") + test_base64url("\0\377", "AP8") + test_eval_error(MIME.encode_base64("\400"))   test_eq([[MIME.encode_base64("How much wood could a woodchuck "    "chuck if a woodchuck could chuck wood?")]],    "SG93IG11Y2ggd29vZCBjb3VsZCBhIHdvb2RjaHVjayBjaHVjayBpZiBhI"    "Hdvb2RjaHVjayBjb3Vs\r\nZCBjaHVjayB3b29kPw==")   test_eq([[MIME.encode_base64("How much wood could a woodchuck "    "chuck if a woodchuck could chuck wood?", 1)]],    "SG93IG11Y2ggd29vZCBjb3VsZCBhIHdvb2RjaHVjayBjaHVjayBpZiBhI"    "Hdvb2RjaHVjayBjb3VsZCBjaHVjayB3b29kPw==") - test_any([[string data=Stdio.read_file("Makefile"); -  return MIME.decode_base64(MIME.encode_base64(data))==data]],1) +       test_eq([[MIME.decode_qp("AbC=3a=4C=25z=\nxyz")]],"AbC:L%zxyz")   test_eq([[MIME.encode_qp("åäöÅÄÖ=Ff")]],"=E5=E4=F6=C5=C4=D6=3DFf")   test_eq([[MIME.encode_qp("How much wood could a woodchuck "    "chuck if a woodchuck could chuck wood?")]],    "How=20much=20wood=20could=20a=20woodchuck=20chuck=20if=20"    "a=20woodchuck=20=\r\ncould=20chuck=20wood?")   test_eq([[MIME.encode_qp("How much wood could a woodchuck "    "chuck if a woodchuck could chuck wood?", 1)]],    "How=20much=20wood=20could=20a=20woodchuck=20chuck=20if=20"    "a=20woodchuck=20could=20chuck=20wood?") - test_any([[string data=Stdio.read_file("Makefile"); -  return MIME.decode_qp(MIME.encode_qp(data))==data]],1) +       test_eq([[MIME.decode_uue("begin 644 foo\n#8F%R\n`\nend\n")]], "bar")   test_eq([[MIME.encode_uue("fie")]],    [["begin 644 attachment\r\n#9FEE\r\n`\r\nend\r\n"]])   test_eq([[MIME.encode_uue("fie ", "fum")]],    [["begin 644 fum\r\n$9FEE(```\r\n`\r\nend\r\n"]])   test_eq([[MIME.encode_uue("fie ")]],    [["begin 644 attachment\r\n%9FEE(\"``\r\n`\r\nend\r\n"]])   test_eq([[MIME.encode_uue("fie ")]],    [["begin 644 attachment\r\n&9FEE(\"`@\r\n`\r\nend\r\n"]])   test_eq([[MIME.encode_uue("fie ")]],    [["begin 644 attachment\r\n'9FEE(\"`@(```\r\n`\r\nend\r\n"]])   test_eq([[MIME.encode_uue("How much wood could a woodchuck "    "chuck if a woodchuck could chuck wood?", "WOOD")]],    [["begin 644 WOOD\r\nM2&]W\050&UU8V@@=V]O9\"!C;W5L9\"!A\050'=O;V1C:'5C:"    "R!C:'5C:R!I9B!A\050'=O\r\n9;V1C:'5C:R!C;W5L9\"!C:'5C:R!W;V]D/P``"    "\r\n`\r\nend\r\n"]]) - test_any([[string data=Stdio.read_file("Makefile"); -  return MIME.decode_uue(MIME.encode_uue(data, "foo bar"))==data]],1) +       test_equal([[MIME.tokenize("foo&bar,fu.m:\"asdf(z\\\"\\\\)x\"afn(xy(z))ds")]],    ({"foo&bar",44,"fu.m",58,"asdf(z\"\\)x","afn","ds"}))   test_equal([[MIME.tokenize(" asdf \t[foo\"bar\"ga(zonk)] \"ghjk\" ")]],    ({"asdf","[foo\"bar\"ga(zonk)]","ghjk"}))   test_equal([[MIME.quote(({"asdf","ghij","a:b","foo",44,"bar",58,44,"åäö"}))]],    [["asdf ghij \"a:b\" foo,bar:,\"åäö\""]])      test_equal([[MIME.tokenize_labled("\":sysmail\"@ Some-Group. Some-Org, "    "Muhammed.(I am the greatest) Ali @(t()\\)he)Vegas.[10.0.3.19]")]],
pike.git/src/modules/MIME/testsuite.in:131:   test_true([[objectp(MIME.Message())]])      test_eq([[MIME.Message("MIME-Version: 1.0\r\n\r\nfoo\r\n")->type]], "text")   test_eq([[MIME.Message("MIME-Version: 1.0\r\n\r\nfoo\r\n")->subtype]], "plain")   test_eq([[MIME.Message("MIME-Version: 1.0\r\n\r\nfoo\r\n")->charset]], "us-ascii")   test_eq([[MIME.Message("MIME-Version: 1.0\r\n\r\nfoo\r\n")->getdata()]], "foo\r\n")   test_eq([[MIME.Message("MIME-Version: 1.0\r\n\r\nfoo\r\n")->getencoded()]], "foo\r\n")   test_equal([[MIME.Message((string)MIME.Message("foo\r\n",    (["mImE-veRsion":"1.0"])))->headers]],    (["mime-version":"1.0","content-length":"5"])) +  + test_any([[ +  string pf_in = "My-Pr3f1x(.0/9)"; +  MIME.set_boundary_prefix(pf_in); +  string pf_out = MIME.get_boundary_prefix(); +  string boundary = MIME.generate_boundary(); +  int nm = sscanf(boundary, pf_out + "%d%s", int n, string suffix); +  return pf_in == pf_out && +  boundary[0..sizeof(pf_out)-1] == pf_out && +  nm == 2 && n <= 1000000000 && suffix == ""; + ]], 1) +    END_MARKER