+
+#define CHECK_QUOTE(INPUT, EXPECT) do { \
+ s = quote822(INPUT, 0); \
+ insist(s != 0); \
+ check_string(s, EXPECT); \
+ s = mime_parse_word(s, &t, mime_http_separator); \
+ check_string(t, INPUT); \
+} while(0)
+ CHECK_QUOTE("wibble", "wibble");
+ CHECK_QUOTE("wibble spong", "\"wibble spong\"");
+ CHECK_QUOTE("wibble\\spong", "\"wibble\\\\spong\"");
+ CHECK_QUOTE("wibble\"spong", "\"wibble\\\"spong\"");
+ CHECK_QUOTE("(wibble)", "\"(wibble)\"");
+
+ s = mime_encode_text("wibble\n", &cs, &enc);
+ insist(s != 0);
+ check_string(s, "wibble\n");
+ check_string(cs, "us-ascii");
+ check_string(enc, "7bit");
+
+ s = mime_encode_text("wibble\xC3\xB7\n", &cs, &enc);
+ insist(s != 0);
+ check_string(s, "wibble=C3=B7\n");
+ check_string(cs, "utf-8");
+ check_string(enc, "quoted-printable");