Commit 50f73ff2 authored by Michael Gratton's avatar Michael Gratton 🤞

Allow test fixtures and test methods to throw errors by default.

* test/testcase.vala (TestCase): Add a generic throws clause to both
  TestMethod and set_up and tear_down, update subclasses.
parent 6b24e07e
......@@ -19,7 +19,7 @@ class ConfigurationTest : Gee.TestCase {
this.test_config = new Configuration(GearyApplication.APP_ID);
}
public void desktop_environment() {
public void desktop_environment() throws Error {
assert(this.test_config.desktop_environment ==
Configuration.DesktopEnvironment.UNKNOWN);
......
......@@ -13,7 +13,7 @@ public class ClientWebViewTest : Gee.TestCase {
add_test("load_resources", load_resources);
}
public void init_web_context() {
public void init_web_context() throws Error {
Configuration config = new Configuration(GearyApplication.APP_ID);
ClientWebView.init_web_context(
config,
......@@ -23,7 +23,7 @@ public class ClientWebViewTest : Gee.TestCase {
);
}
public void load_resources() {
public void load_resources() throws Error {
try {
ClientWebView.load_scripts();
} catch (Error err) {
......
......@@ -22,7 +22,7 @@ public class ComposerWebViewTest : ClientWebViewTestCase<ComposerWebView> {
add_test("get_text_with_nbsp", get_text_with_nbsp);
}
public void load_resources() {
public void load_resources() throws Error {
try {
ComposerWebView.load_resources();
} catch (Error err) {
......@@ -30,7 +30,7 @@ public class ComposerWebViewTest : ClientWebViewTestCase<ComposerWebView> {
}
}
public void edit_context() {
public void edit_context() throws Error {
assert(!(new ComposerWebView.EditContext("0,,,").is_link));
assert(new ComposerWebView.EditContext("1,,,").is_link);
assert(new ComposerWebView.EditContext("1,url,,").link_url == "url");
......@@ -42,7 +42,7 @@ public class ComposerWebViewTest : ClientWebViewTestCase<ComposerWebView> {
assert(new ComposerWebView.EditContext("0,,,12").font_size == 12);
}
public void get_html() {
public void get_html() throws Error {
string html = "<p>para</p>";
load_body_fixture(html);
this.test_view.get_html.begin((obj, ret) => { async_complete(ret); });
......@@ -55,7 +55,7 @@ public class ComposerWebViewTest : ClientWebViewTestCase<ComposerWebView> {
}
}
public void get_text() {
public void get_text() throws Error {
load_body_fixture("<p>para</p>");
this.test_view.get_text.begin((obj, ret) => { async_complete(ret); });
try {
......@@ -66,7 +66,7 @@ public class ComposerWebViewTest : ClientWebViewTestCase<ComposerWebView> {
}
}
public void get_text_with_quote() {
public void get_text_with_quote() throws Error {
load_body_fixture("<p>pre</p> <blockquote><p>quote</p></blockquote> <p>post</p>");
this.test_view.get_text.begin((obj, ret) => { async_complete(ret); });
try {
......@@ -78,7 +78,7 @@ public class ComposerWebViewTest : ClientWebViewTestCase<ComposerWebView> {
}
}
public void get_text_with_nested_quote() {
public void get_text_with_nested_quote() throws Error {
load_body_fixture("<p>pre</p> <blockquote><p>quote1</p> <blockquote><p>quote2</p></blockquote></blockquote> <p>post</p>");
this.test_view.get_text.begin((obj, ret) => { async_complete(ret); });
try {
......@@ -90,7 +90,7 @@ public class ComposerWebViewTest : ClientWebViewTestCase<ComposerWebView> {
}
}
public void get_text_with_long_line() {
public void get_text_with_long_line() throws Error {
load_body_fixture("""
<p>A long, long, long, long, long, long para. Well, longer than MAX_BREAKABLE_LEN
at least. Really long, long, long, long, long long, long long, long long, long.</p>
......@@ -112,7 +112,7 @@ long long, long long, long.
}
}
public void get_text_with_long_quote() {
public void get_text_with_long_quote() throws Error {
load_body_fixture("""
<blockquote><p>A long, long, long, long, long, long line. Well, longer than MAX_BREAKABLE_LEN at least.</p></blockquote>
......@@ -138,7 +138,7 @@ long long, long long, long.
}
}
public void get_text_with_nbsp() {
public void get_text_with_nbsp() throws Error {
load_body_fixture("""On Sun, Jan 1, 2017 at 9:55 PM, Michael Gratton &lt;mike@vee.net&gt; wrote:<br>
<blockquote type="cite">long,&nbsp;long,&nbsp;long,&nbsp;long,&nbsp;long,&nbsp;long,&nbsp;long,&nbsp;long,&nbsp;long,&nbsp;long,&nbsp;long,&nbsp;long,&nbsp;long,&nbsp;long,&nbsp;long,&nbsp;long,&nbsp;long,&nbsp;long,&nbsp;long,&nbsp;long,&nbsp;long,&nbsp;long,&nbsp;long,&nbsp;long,&nbsp;long,&nbsp;long,&nbsp;long,&nbsp;long,&nbsp;long,&nbsp;long,&nbsp;long,&nbsp;long,&nbsp;long,&nbsp;long,&nbsp;long,&nbsp;long,&nbsp;long,&nbsp;long,&nbsp;long,&nbsp;long,&nbsp;long,&nbsp;long,&nbsp;long,&nbsp;long,&nbsp;long,&nbsp;long,&nbsp;long,&nbsp;long,&nbsp;long,
</blockquote><br>long, long, long, long, long, long, long, long, long, long, long, long, long, long, long, long, long, long, long, long, long, long, long, long, long, long, long, long, long, long, long, long, long, long, long, long, long, long, long, long, long, long, long, long, long, long, long, long, long, long, long, long, long, long, long, long, long, long,&nbsp;<div style="white-space: pre;">
......
......@@ -71,7 +71,7 @@ class Geary.AttachmentTest : Gee.TestCase {
}
}
public void get_safe_file_name_with_content_name() {
public void get_safe_file_name_with_content_name() throws Error {
const string TEST_FILENAME = "test-filename.png";
Attachment test = new TestAttachment(
ATTACHMENT_ID,
......@@ -91,7 +91,7 @@ class Geary.AttachmentTest : Gee.TestCase {
assert(test.get_safe_file_name.end(async_result()) == TEST_FILENAME);
}
public void get_safe_file_name_with_bad_content_name() {
public void get_safe_file_name_with_bad_content_name() throws Error {
const string TEST_FILENAME = "test-filename.jpg";
const string RESULT_FILENAME = "test-filename.jpg.png";
Attachment test = new TestAttachment(
......@@ -112,7 +112,7 @@ class Geary.AttachmentTest : Gee.TestCase {
assert(test.get_safe_file_name.end(async_result()) == RESULT_FILENAME);
}
public void get_safe_file_name_with_bad_file_name() {
public void get_safe_file_name_with_bad_file_name() throws Error {
const string TEST_FILENAME = "test-filename";
const string RESULT_FILENAME = "test-filename.png";
Attachment test = new TestAttachment(
......@@ -133,7 +133,7 @@ class Geary.AttachmentTest : Gee.TestCase {
assert(test.get_safe_file_name.end(async_result()) == RESULT_FILENAME);
}
public void get_safe_file_name_with_no_content_name() {
public void get_safe_file_name_with_no_content_name() throws Error {
const string RESULT_FILENAME = CONTENT_ID + ".png";
Attachment test = new TestAttachment(
ATTACHMENT_ID,
......@@ -153,7 +153,7 @@ class Geary.AttachmentTest : Gee.TestCase {
assert(test.get_safe_file_name.end(async_result()) == RESULT_FILENAME);
}
public void get_safe_file_name_with_no_content_name_or_id() {
public void get_safe_file_name_with_no_content_name_or_id() throws Error {
const string RESULT_FILENAME = ATTACHMENT_ID + ".png";
Attachment test = new TestAttachment(
ATTACHMENT_ID,
......@@ -173,7 +173,7 @@ class Geary.AttachmentTest : Gee.TestCase {
assert(test.get_safe_file_name.end(async_result()) == RESULT_FILENAME);
}
public void get_safe_file_name_with_alt_file_name() {
public void get_safe_file_name_with_alt_file_name() throws Error {
const string ALT_TEXT = "some text";
const string RESULT_FILENAME = "some text.png";
Attachment test = new TestAttachment(
......@@ -194,7 +194,7 @@ class Geary.AttachmentTest : Gee.TestCase {
assert(test.get_safe_file_name.end(async_result()) == RESULT_FILENAME);
}
public void get_safe_file_name_with_default_content_type() {
public void get_safe_file_name_with_default_content_type() throws Error {
const string TEST_FILENAME = "test-filename.png";
Attachment test = new TestAttachment(
ATTACHMENT_ID,
......@@ -214,7 +214,8 @@ class Geary.AttachmentTest : Gee.TestCase {
assert(test.get_safe_file_name.end(async_result()) == TEST_FILENAME);
}
public void get_safe_file_name_with_default_content_type_bad_file_name() {
public void get_safe_file_name_with_default_content_type_bad_file_name()
throws Error {
const string TEST_FILENAME = "test-filename.jpg";
const string RESULT_FILENAME = "test-filename.jpg.png";
Attachment test = new TestAttachment(
......
......@@ -72,7 +72,7 @@ class Geary.EngineTest : Gee.TestCase {
}
}
public void create_orphan_account() {
public void create_orphan_account() throws Error {
try {
AccountInformation info = this.engine.create_orphan_account();
assert(info.id == "account_01");
......@@ -94,7 +94,7 @@ class Geary.EngineTest : Gee.TestCase {
}
}
public void create_orphan_account_with_legacy() {
public void create_orphan_account_with_legacy() throws Error {
try {
this.engine.add_account(
new AccountInformation("foo", this.config, this.data),
......
......@@ -36,7 +36,7 @@ class Geary.App.ConversationSetTest : Gee.TestCase {
);
}
public void add_all_basic() {
public void add_all_basic() throws Error {
Email e1 = setup_email(1);
Email e2 = setup_email(2);
......@@ -83,7 +83,7 @@ class Geary.App.ConversationSetTest : Gee.TestCase {
assert(removed.is_empty);
}
public void add_all_duplicate() {
public void add_all_duplicate() throws Error {
Email e1 = setup_email(1);
Gee.LinkedList<Email> emails = new Gee.LinkedList<Email>();
......@@ -131,7 +131,7 @@ class Geary.App.ConversationSetTest : Gee.TestCase {
assert(removed.is_empty);
}
public void add_all_append_descendants() {
public void add_all_append_descendants() throws Error {
Email e1 = setup_email(1);
Email e2 = setup_email(2, e1);
......@@ -203,7 +203,7 @@ class Geary.App.ConversationSetTest : Gee.TestCase {
assert(removed.is_empty);
}
public void add_all_append_ancestors() {
public void add_all_append_ancestors() throws Error {
Email e1 = setup_email(1);
Email e2 = setup_email(2, e1);
......@@ -240,7 +240,7 @@ class Geary.App.ConversationSetTest : Gee.TestCase {
assert(removed.is_empty);
}
public void add_all_merge() {
public void add_all_merge() throws Error {
Email e1 = setup_email(1);
add_email_to_test_set(e1);
......@@ -308,7 +308,7 @@ class Geary.App.ConversationSetTest : Gee.TestCase {
}
public void add_all_multi_path() {
public void add_all_multi_path() throws Error {
Email e1 = setup_email(1);
MockFolderRoot other_path = new MockFolderRoot("other");
......@@ -336,7 +336,7 @@ class Geary.App.ConversationSetTest : Gee.TestCase {
assert(convo.get_folder_count(e1.id) == 2);
}
public void add_all_append_path() {
public void add_all_append_path() throws Error {
Email e1 = setup_email(1);
add_email_to_test_set(e1);
......@@ -369,7 +369,7 @@ class Geary.App.ConversationSetTest : Gee.TestCase {
assert(convo.get_folder_count(e1.id) == 2);
}
public void remove_all_removed() {
public void remove_all_removed() throws Error {
Email e1 = setup_email(1);
add_email_to_test_set(e1);
......@@ -395,7 +395,7 @@ class Geary.App.ConversationSetTest : Gee.TestCase {
assert(trimmed.size == 0);
}
public void remove_all_trimmed() {
public void remove_all_trimmed() throws Error {
Email e1 = setup_email(1);
add_email_to_test_set(e1);
......@@ -425,7 +425,7 @@ class Geary.App.ConversationSetTest : Gee.TestCase {
assert(trimmed.get(convo).contains(e1) == true);
}
public void remove_all_remove_path() {
public void remove_all_remove_path() throws Error {
MockFolderRoot other_path = new MockFolderRoot("other");
Email e1 = setup_email(1);
add_email_to_test_set(e1, other_path);
......
......@@ -31,7 +31,7 @@ class Geary.App.ConversationTest : Gee.TestCase {
this.test = new Conversation(this.base_folder);
}
public void add_basic() {
public void add_basic() throws Error {
Geary.Email e1 = setup_email(1);
Geary.Email e2 = setup_email(2);
uint appended = 0;
......@@ -52,7 +52,7 @@ class Geary.App.ConversationTest : Gee.TestCase {
assert(this.test.get_count() == 2);
}
public void add_duplicate() {
public void add_duplicate() throws Error {
Geary.Email e1 = setup_email(1);
uint appended = 0;
this.test.appended.connect(() => {
......@@ -68,7 +68,7 @@ class Geary.App.ConversationTest : Gee.TestCase {
assert(this.test.get_count() == 1);
}
public void add_multipath() {
public void add_multipath() throws Error {
Geary.Email e1 = setup_email(1);
this.test.add(e1, singleton(this.base_folder.path));
......@@ -91,7 +91,7 @@ class Geary.App.ConversationTest : Gee.TestCase {
assert(this.test.get_folder_count(e1.id) == 1);
}
public void remove_basic() {
public void remove_basic() throws Error {
Geary.Email e1 = setup_email(1);
this.test.add(e1, singleton(this.base_folder.path));
......@@ -118,7 +118,7 @@ class Geary.App.ConversationTest : Gee.TestCase {
assert(this.test.get_count() == 0);
}
public void remove_nonexistent() {
public void remove_nonexistent() throws Error {
Geary.Email e1 = setup_email(1);
Geary.Email e2 = setup_email(2);
......
......@@ -58,10 +58,10 @@ public class Geary.ImapEngine.AccountProcessorTest : Gee.TestCase {
public AccountProcessorTest() {
base("Geary.ImapEngine.AccountProcessorTest");
add_test("test_success", test_success);
add_test("test_failure", test_failure);
add_test("test_duplicate", test_duplicate);
add_test("test_stop", test_stop);
add_test("success", success);
add_test("failure", failure);
add_test("duplicate", duplicate);
add_test("stop", stop);
// XXX this has to be here instead of in set_up for some
// reason...
......@@ -81,7 +81,7 @@ public class Geary.ImapEngine.AccountProcessorTest : Gee.TestCase {
this.completed = 0;
}
public void test_success() {
public void success() throws Error {
TestOperation op = setup_operation(new TestOperation(this.account));
this.processor.enqueue(op);
......@@ -95,7 +95,7 @@ public class Geary.ImapEngine.AccountProcessorTest : Gee.TestCase {
assert(this.completed == 1);
}
public void test_failure() {
public void failure() throws Error {
TestOperation op = setup_operation(new TestOperation(this.account));
op.throw_error = true;
......@@ -116,7 +116,7 @@ public class Geary.ImapEngine.AccountProcessorTest : Gee.TestCase {
assert(error is AccountProcessorTestError.TEST);
}
public void test_duplicate() {
public void duplicate() throws Error {
TestOperation op1 = setup_operation(new TestOperation(this.account));
TestOperation op2 = setup_operation(new TestOperation(this.account));
TestOperation op3 = setup_operation(new OtherOperation(this.account));
......@@ -129,7 +129,7 @@ public class Geary.ImapEngine.AccountProcessorTest : Gee.TestCase {
assert(this.processor.waiting == 2);
}
public void test_stop() {
public void stop() throws Error {
TestOperation op1 = setup_operation(new TestOperation(this.account));
op1.wait_for_cancel = true;
TestOperation op2 = setup_operation(new OtherOperation(this.account));
......
......@@ -10,16 +10,16 @@ class Geary.Imap.CreateCommandTest : Gee.TestCase {
public CreateCommandTest() {
base("Geary.Imap.CreateCommandTest");
add_test("test_basic_create", test_basic_create);
add_test("test_special_use", test_special_use);
add_test("basic_create", basic_create);
add_test("special_use", special_use);
}
public void test_basic_create() {
public void basic_create() throws Error {
assert(new CreateCommand(new MailboxSpecifier("owatagusiam/")).to_string() ==
"---- create owatagusiam/");
}
public void test_special_use() {
public void special_use() throws Error {
assert(new CreateCommand.special_use(
new MailboxSpecifier("Everything"),
SpecialFolderType.ALL_MAIL
......
......@@ -10,13 +10,13 @@ class Geary.Imap.NamespaceResponseTest : Gee.TestCase {
public NamespaceResponseTest() {
base("Geary.Imap.NamespaceResponseTest");
add_test("test_minimal", test_minimal);
add_test("test_complete", test_complete);
add_test("test_cyrus", test_cyrus);
add_test("test_anonymous", test_anonymous);
add_test("minimal", minimal);
add_test("complete", complete);
add_test("cyrus", cyrus);
add_test("anonymous", anonymous);
}
public void test_minimal() {
public void minimal() throws Error {
// * NAMESPACE NIL NIL NIL
try {
ServerData data = newNamespaceServerData(null, null, null);
......@@ -30,7 +30,7 @@ class Geary.Imap.NamespaceResponseTest : Gee.TestCase {
}
}
public void test_complete() {
public void complete() throws Error {
// * NAMESPACE (("" "/")) (("~" "/")) (("#shared/" "/")
ListParameter personal = new ListParameter();
personal.add(newNamespace("", "/"));
......@@ -61,7 +61,7 @@ class Geary.Imap.NamespaceResponseTest : Gee.TestCase {
}
}
public void test_cyrus() {
public void cyrus() throws Error {
// * NAMESPACE (("INBOX." ".")) NIL (("" "."))
ListParameter personal = new ListParameter();
personal.add(newNamespace("INBOX.", "."));
......@@ -84,7 +84,7 @@ class Geary.Imap.NamespaceResponseTest : Gee.TestCase {
}
}
public void test_anonymous() {
public void anonymous() throws Error {
// * NAMESPACE NIL NIL (("" "."))
ListParameter shared = new ListParameter();
shared.add(newNamespace("", ","));
......
......@@ -19,21 +19,21 @@ class Geary.Imap.DeserializerTest : Gee.TestCase {
public DeserializerTest() {
base("Geary.Imap.DeserializerTest");
add_test("test_gmail_greeting", test_gmail_greeting);
add_test("test_cyrus_2_4_greeting", test_cyrus_2_4_greeting);
add_test("test_aliyun_greeting", test_aliyun_greeting);
add_test("gmail_greeting", gmail_greeting);
add_test("cyrus_2_4_greeting", cyrus_2_4_greeting);
add_test("aliyun_greeting", aliyun_greeting);
add_test("test_invalid_atom_prefix", test_invalid_atom_prefix);
add_test("invalid_atom_prefix", invalid_atom_prefix);
add_test("test_gmail_flags", test_gmail_flags);
add_test("test_gmail_permanent_flags", test_gmail_permanent_flags);
add_test("test_cyrus_flags", test_cyrus_flags);
add_test("gmail_flags", gmail_flags);
add_test("gmail_permanent_flags", gmail_permanent_flags);
add_test("cyrus_flags", cyrus_flags);
add_test("test_runin_special_flag", test_runin_special_flag);
add_test("test_invalid_flag_prefix", test_invalid_flag_prefix);
add_test("runin_special_flag", runin_special_flag);
add_test("invalid_flag_prefix", invalid_flag_prefix);
add_test("test_instant_eos", test_instant_eos);
add_test("test_bye_eos", test_bye_eos);
add_test("instant_eos", instant_eos);
add_test("bye_eos", bye_eos);
}
public override void set_up() {
......@@ -46,7 +46,7 @@ class Geary.Imap.DeserializerTest : Gee.TestCase {
async_result();
}
public void test_gmail_greeting() {
public void gmail_greeting() throws Error {
string greeting = "* OK Gimap ready for requests from 115.187.245.46 c194mb399904375ivc";
this.stream.add_data(greeting.data);
this.stream.add_data(EOL.data);
......@@ -57,7 +57,7 @@ class Geary.Imap.DeserializerTest : Gee.TestCase {
assert(message.to_string() == greeting);
}
public void test_cyrus_2_4_greeting() {
public void cyrus_2_4_greeting() throws Error {
string greeting = "* OK [CAPABILITY IMAP4rev1 LITERAL+ ID ENABLE AUTH=PLAIN SASL-IR] mogul Cyrus IMAP v2.4.12-Debian-2.4.12-2 server ready";
this.stream.add_data(greeting.data);
this.stream.add_data(EOL.data);
......@@ -68,7 +68,7 @@ class Geary.Imap.DeserializerTest : Gee.TestCase {
assert(message.to_string() == greeting);
}
public void test_aliyun_greeting() {
public void aliyun_greeting() throws Error {
string greeting = "* OK AliYun IMAP Server Ready(10.147.40.164)";
string parsed = "* OK AliYun IMAP Server Ready (10.147.40.164)";
this.stream.add_data(greeting.data);
......@@ -80,7 +80,7 @@ class Geary.Imap.DeserializerTest : Gee.TestCase {
assert(message.to_string() == parsed);
}
public void test_invalid_atom_prefix() {
public void invalid_atom_prefix() throws Error {
string flags = """* OK %atom""";
this.stream.add_data(flags.data);
this.stream.add_data(EOL.data);
......@@ -89,7 +89,7 @@ class Geary.Imap.DeserializerTest : Gee.TestCase {
this.process.end(async_result());
}
public void test_gmail_flags() {
public void gmail_flags() throws Error {
string flags = """* FLAGS (\Answered \Flagged \Draft \Deleted \Seen $NotPhishing $Phishing)""";
this.stream.add_data(flags.data);
this.stream.add_data(EOL.data);
......@@ -100,7 +100,7 @@ class Geary.Imap.DeserializerTest : Gee.TestCase {
assert(message.to_string() == flags);
}
public void test_gmail_permanent_flags() {
public void gmail_permanent_flags() throws Error {
string flags = """* OK [PERMANENTFLAGS (\Answered \Flagged \Draft \Deleted \Seen $NotPhishing $Phishing \*)] Flags permitted.""";
this.stream.add_data(flags.data);
this.stream.add_data(EOL.data);
......@@ -111,7 +111,7 @@ class Geary.Imap.DeserializerTest : Gee.TestCase {
assert(message.to_string() == flags);
}
public void test_cyrus_flags() {
public void cyrus_flags() throws Error {
string flags = """* 2934 FETCH (FLAGS (\Answered \Seen $Quuxo::Spam::Trained) UID 3041)""";
this.stream.add_data(flags.data);
this.stream.add_data(EOL.data);
......@@ -122,7 +122,7 @@ class Geary.Imap.DeserializerTest : Gee.TestCase {
assert(message.to_string() == flags);
}
public void test_runin_special_flag() {
public void runin_special_flag() throws Error {
// since we must terminate a special flag upon receiving the
// '*', the following atom will be treated as a run-on but
// distinct atom.
......@@ -137,7 +137,7 @@ class Geary.Imap.DeserializerTest : Gee.TestCase {
assert(message.to_string() == expected);
}
public void test_invalid_flag_prefix() {
public void invalid_flag_prefix() throws Error {
string flags = """* OK \%atom""";
this.stream.add_data(flags.data);
this.stream.add_data(EOL.data);
......@@ -146,13 +146,13 @@ class Geary.Imap.DeserializerTest : Gee.TestCase {
this.process.end(async_result());
}
public void test_instant_eos() {
public void instant_eos() throws Error {
this.process.begin(Expect.EOS, (obj, ret) => { async_complete(ret); });
this.process.end(async_result());
assert(this.deser.is_halted());
}
public void test_bye_eos() {
public void bye_eos() throws Error {
string bye = """* OK bye""";
this.stream.add_data(bye.data);
......
......@@ -15,16 +15,16 @@ class Geary.Mime.ContentTypeTest : Gee.TestCase {
add_test("guess_type_from_buf", guess_type_from_buf);
}
public void is_default() {
public void is_default() throws Error {
assert(new ContentType("application", "octet-stream", null).is_default());
}
public void get_file_name_extension() {
public void get_file_name_extension() throws Error {
assert(new ContentType("image", "jpeg", null).get_file_name_extension() == ".jpeg");
assert(new ContentType("test", "unknown", null).get_file_name_extension() == null);
}
public void guess_type_from_name() {
public void guess_type_from_name() throws Error {
try {
assert(ContentType.guess_type("test.png", null).is_type("image", "png"));
} catch (Error err) {
......@@ -38,7 +38,7 @@ class Geary.Mime.ContentTypeTest : Gee.TestCase {
}
}
public void guess_type_from_buf() {
public void guess_type_from_buf() throws Error {
Memory.ByteBuffer png = new Memory.ByteBuffer(
{0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a}, 8 // PNG magic
);
......
......@@ -21,7 +21,7 @@ class Geary.RFC822.MailboxAddressTest : Gee.TestCase {
add_test("to_rfc822_string", to_rfc822_string);
}
public void is_valid_address() {
public void is_valid_address() throws Error {
assert(Geary.RFC822.MailboxAddress.is_valid_address("john@dep.aol.museum") == true);
assert(Geary.RFC822.MailboxAddress.is_valid_address("test@example.com") == true);
assert(Geary.RFC822.MailboxAddress.is_valid_address("test.other@example.com") == true);
......@@ -39,7 +39,7 @@ class Geary.RFC822.MailboxAddressTest : Gee.TestCase {
assert(Geary.RFC822.MailboxAddress.is_valid_address("") == false);
}
public void unescaped_constructor() {
public void unescaped_constructor() throws Error {
MailboxAddress addr1 = new MailboxAddress("test1", "test2@example.com");
assert(addr1.name == "test1");
assert(addr1.address == "test2@example.com");
......@@ -67,7 +67,7 @@ class Geary.RFC822.MailboxAddressTest : Gee.TestCase {
assert(addr5.domain == "");
}
public void from_rfc822_string_encoded() {
public void from_rfc822_string_encoded() throws Error {
try {
MailboxAddress addr = new MailboxAddress.from_rfc822_string("test@example.com");
assert(addr.name == null);
......@@ -148,7 +148,7 @@ class Geary.RFC822.MailboxAddressTest : Gee.TestCase {
}
}
public void is_spoofed() {
public void is_spoofed() throws Error {
assert(new MailboxAddress(null, "example@example.com").is_spoofed() == false);
assert(new MailboxAddress("", "example@example.com").is_spoofed() == false);
assert(new MailboxAddress("", "example@example.com").is_spoofed() == false);
......@@ -173,7 +173,7 @@ class Geary.RFC822.MailboxAddressTest : Gee.TestCase {
}
}
public void has_distinct_name() {
public void has_distinct_name() throws Error {
assert(new MailboxAddress("example", "example@example.com").has_distinct_name() == true);
assert(new MailboxAddress("", "example@example.com").has_distinct_name() == false);
......@@ -183,7 +183,7 @@ class Geary.RFC822.MailboxAddressTest : Gee.TestCase {
assert(new MailboxAddress(" example@example.com ", "example@example.com").has_distinct_name() == false);
}
public void to_full_display() {
public void to_full_display() throws Error {
assert(new MailboxAddress("", "example@example.com").to_full_display() ==
"example@example.com");
assert(new MailboxAddress("Test", "example@example.com").to_full_display() ==
......@@ -194,7 +194,7 @@ class Geary.RFC822.MailboxAddressTest : Gee.TestCase {
"example@example@example.com");
}
public void to_short_display() {
public void to_short_display() throws Error {
assert(new MailboxAddress("", "example@example.com").to_short_display() ==
"example@example.com");
assert(new MailboxAddress("Test", "example@example.com").to_short_display() ==
......@@ -205,7 +205,7 @@ class Geary.RFC822.MailboxAddressTest : Gee.TestCase {
"example@example@example.com");
}
public void to_rfc822_address() {
public void to_rfc822_address() throws Error {
assert(new MailboxAddress(null, "example@example.com").to_rfc822_address() ==
"example@example.com");
//assert(new MailboxAddress(null, "test test@example.com").to_rfc822_address() ==
......@@ -222,7 +222,7 @@ class Geary.RFC822.MailboxAddressTest : Gee.TestCase {
"\"=?UTF-8?b?8J+YuA==?=\"@example.com");
}
public void to_rfc822_string() {
public void to_rfc822_string() throws Error {
assert(new MailboxAddress("", "example@example.com").to_rfc822_string() ==
"example@example.com");
assert(new MailboxAddress(" ", "example@example.com").to_rfc822_string() ==
......
......@@ -13,7 +13,7 @@ class Geary.RFC822.MailboxAddressesTest : Gee.TestCase {
add_test("to_rfc822_string", to_rfc822_string);
}
public void from_rfc822_string_encoded() {
public void from_rfc822_string_encoded() throws Error {
MailboxAddresses addrs = new MailboxAddresses.from_rfc822_string("test@example.com");
assert(addrs.size == 1);
......@@ -29,7 +29,7 @@ class Geary.RFC822.MailboxAddressesTest : Gee.TestCase {
assert(addrs.size == 2);
}
public void to_rfc822_string() {
public void to_rfc822_string() throws Error {
assert(new MailboxAddresses().to_rfc822_string() == "");
assert(new_addreses({ "test1@example.com" })
.to_rfc822_string() == "test1@example.com");
......
......@@ -12,7 +12,7 @@ class Geary.RFC822.MessageDataTest : Gee.TestCase {
add_test("PreviewText.with_header", preview_text_with_header);
}