[gxml] Applying patch from bug #682711



commit c3259aba00f9c26dae98498491803c33060c8419
Author: Richard Schwarting <aquarichy gmail com>
Date:   Sat Sep 1 09:47:30 2012 -0400

    Applying patch from bug #682711
    
     Arnel A. Borja [reporter] 2012-08-26 01:25:35 UTC
    
    Created an attachment (id=222446) [details] [review]
    Assert patches
    
    Four patches for doing the following (merged into one file):
    - Use assert_not_reached instead of `assert (false)'
    - Remove unnecessary `assert (true)'
    - Catch errors, assert catch block as not reached
    - Use assert_not_reached instead of GLib.Test.fail
    - Use Test.message instead of GLib.warning/error/message
    
    I based these changes by looking into other GNOME projects, like GTK+ and
    gedit. Seems like they don't use hardcoded asserts, instead using
    assert_not_reached, and other things I listed above.

 test/AttrTest.vala          |   54 +++++++++++++-------------
 test/CharacterDataTest.vala |   28 +++++++-------
 test/DocumentTest.vala      |   74 +++++++++++++++++-----------------
 test/DomNodeTest.vala       |   64 +++++++++++++++---------------
 test/ElementTest.vala       |   72 +++++++++++++++++-----------------
 test/GXmlTest.vala          |    5 +--
 test/SerializableTest.vala  |   47 +++++++++++++++--------
 test/SerializationTest.vala |   91 ++++++++++++++++++++++--------------------
 test/TextTest.vala          |   10 ++---
 test/ValaLibxml2Test.vala   |    4 +-
 10 files changed, 232 insertions(+), 217 deletions(-)
---
diff --git a/test/AttrTest.vala b/test/AttrTest.vala
index e34f6bc..338b123 100644
--- a/test/AttrTest.vala
+++ b/test/AttrTest.vala
@@ -17,8 +17,8 @@ class AttrTest : GXmlTest {
 					assert (shell.namespace_uri == "http://mom.co.uk/wands";);
 					assert (price.namespace_uri == null);
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/element/prefix", () => {
@@ -35,8 +35,8 @@ class AttrTest : GXmlTest {
 					assert (shell.prefix == "wands");
 					assert (price.prefix == null);
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/element/local_name", () => {
@@ -53,8 +53,8 @@ class AttrTest : GXmlTest {
 					assert (shell.local_name == "shell");
 					assert (price.local_name == "price");
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 
@@ -65,8 +65,8 @@ class AttrTest : GXmlTest {
 
 					assert (attr.node_name == "broomSeries");
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/attribute/node_value", () => {
@@ -83,8 +83,8 @@ class AttrTest : GXmlTest {
 					attr.value = "Gringots";
 					assert (attr.node_value == "Gringots");
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/attribute/name", () => {
@@ -94,8 +94,8 @@ class AttrTest : GXmlTest {
 
 					assert (attr.name == "broomSeries");
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/attribute/node_value", () => {
@@ -112,8 +112,8 @@ class AttrTest : GXmlTest {
 					attr.node_value = "Gringots";
 					assert (attr.value == "Gringots");
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/attribute/specified", () => {
@@ -129,8 +129,8 @@ class AttrTest : GXmlTest {
 					elem.set_attribute_node (attr);
 					assert (attr.parent_node == null);
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/attribute/previous_sibling", () => {
@@ -146,8 +146,8 @@ class AttrTest : GXmlTest {
 					assert (attr1.previous_sibling == null);
 					assert (attr2.previous_sibling == null);
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/attribute/next_sibling", () => {
@@ -163,8 +163,8 @@ class AttrTest : GXmlTest {
 					assert (attr1.next_sibling == null);
 					assert (attr2.next_sibling == null);
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/attribute/insert_before", () => {
@@ -179,8 +179,8 @@ class AttrTest : GXmlTest {
 					// the Text nodes should be merged
 					assert (attr.child_nodes.length == 1);
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/attribute/replace_child", () => {
@@ -193,8 +193,8 @@ class AttrTest : GXmlTest {
 					attr.replace_child (txt, attr.child_nodes.item (0));
 					assert (attr.value == "Gryffindor");
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/attribute/remove_child", () => {
@@ -207,9 +207,9 @@ class AttrTest : GXmlTest {
 					attr.remove_child (attr.child_nodes.last ());
 					assert (attr.value == "");
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 	}
-}
\ No newline at end of file
+}
diff --git a/test/CharacterDataTest.vala b/test/CharacterDataTest.vala
index 1d87e3e..6936c3f 100644
--- a/test/CharacterDataTest.vala
+++ b/test/CharacterDataTest.vala
@@ -11,8 +11,8 @@ class CharacterDataTest : GXmlTest  {
 					assert (txt.data == str);
 					assert (txt.data == txt.node_value);
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/characterdata/length", () => {
@@ -22,8 +22,8 @@ class CharacterDataTest : GXmlTest  {
 
 					assert (txt.length == str.length);
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/characterdata/substring_data", () => {
@@ -35,8 +35,8 @@ class CharacterDataTest : GXmlTest  {
 
 					// TODO: test bounds
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/characterdata/append_data", () => {
@@ -49,8 +49,8 @@ class CharacterDataTest : GXmlTest  {
 					txt.append_data (" if you can't see where it keeps its brain.");
 					assert (txt.data == str_whole);
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/characterdata/insert_data", () => {
@@ -60,8 +60,8 @@ class CharacterDataTest : GXmlTest  {
 					assert (txt.data == "It is our choices that show what we truly are, far more than our abilities.");
 					// TODO: test bounds
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/characterdata/delete_data", () => {
@@ -71,8 +71,8 @@ class CharacterDataTest : GXmlTest  {
 					assert (txt.data == "Happiness can turn on the light.");
 					// TODO: test bounds
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/characterdata/replace_data", () => {
@@ -83,8 +83,8 @@ class CharacterDataTest : GXmlTest  {
 					txt.replace_data (3, 6, "the refrigerator");
 					assert (txt.data == "In the refrigerator, we enter a world that's entirely our own.");
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 	}
diff --git a/test/DocumentTest.vala b/test/DocumentTest.vala
index 8c1cc94..8cc4f4c 100644
--- a/test/DocumentTest.vala
+++ b/test/DocumentTest.vala
@@ -10,7 +10,7 @@ class DocumentTest : GXmlTest {
 				// Document doc = get_doc ();
 				DocumentType type = doc.doctype;
 				HashTable<string,Entity> entities = type.entities;
-				assert (false);
+				assert_not_reached ();
 				// TODO: need to find an example file with a DTD that actually sets entities, annotations
 				// TODO: fill in
 				*/
@@ -27,8 +27,8 @@ class DocumentTest : GXmlTest {
 					assert (impl.has_feature ("html") == false);
 					assert (impl.has_feature ("nonsense") == false);
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/document/document_element", () => {
@@ -39,8 +39,8 @@ class DocumentTest : GXmlTest {
 					assert (root.node_name == "Sentences");
 					assert (root.has_child_nodes ());
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 
@@ -50,8 +50,8 @@ class DocumentTest : GXmlTest {
 
 					check_contents (doc);
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/document/construct_from_stream", () => {
@@ -64,8 +64,8 @@ class DocumentTest : GXmlTest {
 
 					check_contents (doc);
 				} catch (GLib.Error e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/document/construct_from_string", () => {
@@ -79,8 +79,8 @@ class DocumentTest : GXmlTest {
 					assert (root.first_child.node_name == "Apple");
 					assert (root.last_child.node_name == "Orange");
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/document/save", () => {
@@ -92,8 +92,8 @@ class DocumentTest : GXmlTest {
 					Process.spawn_sync (null,  { "/usr/bin/diff", GLib.Environment.get_tmp_dir () + "/test_out_path.xml", GXmlTest.get_test_dir () + "/test_out_path_expected.xml" }, null, 0, null, null /* stdout */, null /* stderr */, out exit_status);
 					assert (exit_status == 0);
 				} catch (GLib.Error e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/document/save_to_stream", () => {
@@ -113,8 +113,8 @@ class DocumentTest : GXmlTest {
 					Process.spawn_sync (null,  { "/usr/bin/diff", GLib.Environment.get_tmp_dir () + "/test_out_stream.xml", GXmlTest.get_test_dir () + "/test_out_stream_expected.xml" }, null, 0, null, null /* stdout */, null /* stderr */, out exit_status);
 					assert (exit_status == 0);
 				} catch (GLib.Error e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/document/create_element", () => {
@@ -128,7 +128,7 @@ class DocumentTest : GXmlTest {
 						assert (elem.tag_name == "Banana");
 						assert (elem.tag_name != "banana");
 					} catch (DomError e) {
-						assert (false);
+						assert_not_reached ();
 					}
 
 					try {
@@ -140,13 +140,13 @@ class DocumentTest : GXmlTest {
 						   but not us? :S
 
 						   // We should not get this far
-						   assert (false);
+						   assert_not_reached ();
 						*/
 					} catch (DomError.INVALID_CHARACTER e) {
 					}
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/document/create_document_fragment", () => {
@@ -218,8 +218,8 @@ class DocumentTest : GXmlTest {
 					// TODO: want to find a way to flattern the string, strip whitespace
 					assert (doc.to_string () == expected);
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/document/create_text_node", () => {
@@ -230,8 +230,8 @@ class DocumentTest : GXmlTest {
 					assert (text.node_name == "#text");
 					assert (text.node_value == "Star of my dreams");
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/document/create_comment", () => {
@@ -242,8 +242,8 @@ class DocumentTest : GXmlTest {
 					assert (comment.node_name == "#comment");
 					assert (comment.node_value == "Ever since the day we promised.");
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/document/create_cdata_section", () => {
@@ -254,8 +254,8 @@ class DocumentTest : GXmlTest {
 					assert (cdata.node_name == "#cdata-section");
 					assert (cdata.node_value == "put in real cdata");
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/document/create_processing_instruction", () => {
@@ -268,8 +268,8 @@ class DocumentTest : GXmlTest {
 					assert (instruction.data == "data");
 					assert (instruction.node_value == "data");
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/document/create_attribute", () => {
@@ -281,8 +281,8 @@ class DocumentTest : GXmlTest {
 					assert (attr.node_name == "attrname");
 					assert (attr.node_value == "");
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/document/create_entity_reference", () => {
@@ -293,8 +293,8 @@ class DocumentTest : GXmlTest {
 					assert (entity.node_name == "entref");
 					// TODO: think of at least one other smoke test
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/document/get_elements_by_tag_name", () => {
@@ -307,8 +307,8 @@ class DocumentTest : GXmlTest {
 					/* more thorough test exists in Element, since right now
 					   Document uses that one */
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/document/to_string", () => {
@@ -332,8 +332,8 @@ class DocumentTest : GXmlTest {
 ");
 					// TODO: want to test with format on and off
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 
 			});
diff --git a/test/DomNodeTest.vala b/test/DomNodeTest.vala
index b746d23..6db9596 100644
--- a/test/DomNodeTest.vala
+++ b/test/DomNodeTest.vala
@@ -52,8 +52,8 @@ class DomNodeTest : GXmlTest {
 					// node = doc.create_notation ("some notation");
 					// assert (node.node_name == ...); // notation name
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/domnode/node_type_get", () => {
@@ -99,8 +99,8 @@ class DomNodeTest : GXmlTest {
 					// assert (node.node_type == NodeType.NOTATION);
 
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/domnode/node_value_get", () => {
@@ -146,8 +146,8 @@ class DomNodeTest : GXmlTest {
 					   DomNode wants to get it from DomNode's Xml.Node* node,
 					   while Attr wants to get it from Attr's Xml.Attr* node. :( */
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/domnode/parent_node", () => {
@@ -165,8 +165,8 @@ class DomNodeTest : GXmlTest {
 					assert (doc.parent_node == null);
 					// assert (document fragment's parent_node == null); // TODO
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/domnode/child_nodes", () => {
@@ -185,8 +185,8 @@ class DomNodeTest : GXmlTest {
 					assert (parent.child_nodes.nth_data (0) == child_0);
 					assert (parent.child_nodes.nth_data (2) == child_2);
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/domnode/first_child", () => {
@@ -204,8 +204,8 @@ class DomNodeTest : GXmlTest {
 
 					assert (parent.first_child == child_0);
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/domnode/last_child", () => {
@@ -223,8 +223,8 @@ class DomNodeTest : GXmlTest {
 
 					assert (parent.last_child == child_2);
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/domnode/previous_sibling", () => {
@@ -244,8 +244,8 @@ class DomNodeTest : GXmlTest {
 					assert (child_1.previous_sibling == child_0);
 					assert (child_2.previous_sibling == child_1);
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/domnode/next_sibling", () => {
@@ -265,8 +265,8 @@ class DomNodeTest : GXmlTest {
 					assert (child_1.next_sibling == child_2);
 					assert (child_2.next_sibling == null);
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/domnode/attributes", () => {
@@ -281,8 +281,8 @@ class DomNodeTest : GXmlTest {
 					// TODO: test more
 					// TODO: test compatibility between live changes and stuff
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/domnode/owner_document", () => {
@@ -294,8 +294,8 @@ class DomNodeTest : GXmlTest {
 					assert (elem.owner_document == doc1);
 					assert (elem.owner_document != doc2);
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/domnode/insert_before", () => {
@@ -324,8 +324,8 @@ class DomNodeTest : GXmlTest {
 					assert (child_1.next_sibling == child_2);
 					assert (child_2.next_sibling == null);
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/domnode/replace_child", () => {
@@ -354,8 +354,8 @@ class DomNodeTest : GXmlTest {
 					assert (child_0.next_sibling == child_1);
 					assert (child_1.next_sibling == null);
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/domnode/remove_child", () => {
@@ -401,8 +401,8 @@ class DomNodeTest : GXmlTest {
 					assert (parent.last_child == null);
 					assert (parent.child_nodes.length == 0);
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/domnode/append_child", () => {
@@ -431,8 +431,8 @@ class DomNodeTest : GXmlTest {
 					assert (child_1.next_sibling == child_2);
 					assert (child_2.next_sibling == null);
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/domnode/has_child_nodes", () => {
@@ -447,8 +447,8 @@ class DomNodeTest : GXmlTest {
 
 					assert (parent.has_child_nodes () == true);
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/domnode/clone_nodes", () => {
diff --git a/test/ElementTest.vala b/test/ElementTest.vala
index 6d113fb..9ba9d50 100644
--- a/test/ElementTest.vala
+++ b/test/ElementTest.vala
@@ -44,8 +44,8 @@ class ElementTest : GXmlTest  {
 					assert (node.local_name == "Potion");
 					assert (node.node_name == "Potion");
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/element/namespace_uri", () => {
@@ -57,8 +57,8 @@ class ElementTest : GXmlTest  {
 
 					assert (node.namespace_uri == "http://hogwarts.co.uk/magic";);
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/element/testing", () => {
@@ -80,8 +80,8 @@ class ElementTest : GXmlTest  {
 					// 	message ("attrkey: %s, value: %s", attr.node_name, attr.node_value);
 					// }
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/element/prefix", () => {
@@ -92,8 +92,8 @@ class ElementTest : GXmlTest  {
 
 					assert (node.prefix == "magic");
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/element/local_name", () => {
@@ -104,8 +104,8 @@ class ElementTest : GXmlTest  {
 
 					assert (node.local_name == "Potion");
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/element/namespace_definitions", () => {
@@ -126,8 +126,8 @@ class ElementTest : GXmlTest  {
 					assert (namespaces.item (1).node_value == "http://diagonalley.co.uk/products";);
 					assert (node.local_name == "Potion");
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/element/attributes", () => {
@@ -165,8 +165,8 @@ class ElementTest : GXmlTest  {
 					assert (elem.get_attribute ("alley") == "");
 
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		/* by accessing .attributes, the element is marked as
@@ -187,8 +187,8 @@ class ElementTest : GXmlTest  {
 
 					str = doc.to_string ();
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/element/get_set_attribute", () => {
@@ -202,8 +202,8 @@ class ElementTest : GXmlTest  {
 					elem.set_attribute ("name", "Lovegood");
 					assert ("Lovegood" == elem.get_attribute ("name"));
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/element/remove_attribute", () => {
@@ -219,8 +219,8 @@ class ElementTest : GXmlTest  {
 
 					// Consider testing default attributes (see Attr and specified)
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/element/get_attribute_node", () => {
@@ -231,8 +231,8 @@ class ElementTest : GXmlTest  {
 					elem.set_attribute ("name", "Severus");
 					assert (elem.get_attribute_node ("name").value == "Severus");
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/element/set_attribute_node", () => {
@@ -252,8 +252,8 @@ class ElementTest : GXmlTest  {
 					assert (elem.set_attribute_node (attr2).value == "Snape");
 					assert (elem.get_attribute_node ("name").value == "Moody");
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 
@@ -274,8 +274,8 @@ class ElementTest : GXmlTest  {
 					assert (elem.get_attribute_node ("name") == null);
 					assert (elem.get_attribute ("name") == "");
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 
@@ -316,8 +316,8 @@ class ElementTest : GXmlTest  {
 
 					// TODO: need to test that preorder traversal order is correct
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/element/get_elements_by_tag_name.live", () => {
@@ -425,8 +425,8 @@ class ElementTest : GXmlTest  {
 					bs.append_child (b4);
 					assert (ts.length == 11);
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/element/normalize", () => {
@@ -436,8 +436,8 @@ class ElementTest : GXmlTest  {
 
 					// STUB
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/element/to_string", () => {
@@ -451,15 +451,15 @@ class ElementTest : GXmlTest  {
 					elem2.append_child (elem.owner_document.create_text_node ("&lt;<>&gt;"));
 					string expected = "<messy>&amp;lt;&lt;&gt;&amp;gt;</messy>";
 					if (elem2.to_string () != expected) {
-						GLib.warning ("Expected [%s] found [%s]",
+						Test.message ("Expected [%s] found [%s]",
 							      expected, elem2.to_string ());
-						GLib.Test.fail ();
+						assert_not_reached ();
 					}
 
 					// TODO: want to test with format on and off
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 	}
diff --git a/test/GXmlTest.vala b/test/GXmlTest.vala
index f52ce67..7b0440f 100644
--- a/test/GXmlTest.vala
+++ b/test/GXmlTest.vala
@@ -15,9 +15,6 @@ class GXmlTest {
 		SerializationTest.add_tests ();
 		SerializableTest.add_tests ();
 
-		// Prevent WARNING from aborting the test suite
-		GLib.Log.set_always_fatal (GLib.LogLevelFlags.LEVEL_ERROR);
-
 		Test.run ();
 
 		return 0;
@@ -67,4 +64,4 @@ class GXmlTest {
 		Text txt = doc.create_text_node (data);
 		return txt;
 	}
-}
\ No newline at end of file
+}
diff --git a/test/SerializableTest.vala b/test/SerializableTest.vala
index 52b1c44..845c05d 100644
--- a/test/SerializableTest.vala
+++ b/test/SerializableTest.vala
@@ -95,7 +95,8 @@ public class SerializableCapsicum : GLib.Object, GXml.Serializable {
 			this.height = (int)outvalue.get_int64 () - 1;
 			return true;
 		default:
-			GLib.error ("Wasn't expecting the SerializableCapsicum property '%s'", property_name);
+			Test.message ("Wasn't expecting the SerializableCapsicum property '%s'", property_name);
+			assert_not_reached ();
 		}
 
 		return false;
@@ -107,18 +108,22 @@ public class SerializableCapsicum : GLib.Object, GXml.Serializable {
 		switch (property_name) {
 		case "ratings":
 			GXml.DocumentFragment frag = doc.create_document_fragment ();
-			foreach (int rating_int in ratings) {
-				rating = doc.create_element ("rating");
-				rating.content = "%d".printf (rating_int);
-				frag.append_child (rating);
+			try {
+				foreach (int rating_int in ratings) {
+					rating = doc.create_element ("rating");
+					rating.content = "%d".printf (rating_int);
+					frag.append_child (rating);
+				}
+			} catch (GXml.DomError e) {
+				Test.message ("%s", e.message);
+				assert_not_reached ();
 			}
 			return frag;
-			break;
 		case "height":
 			return doc.create_text_node ("%d".printf (height + 1));
-			break;
 		default:
-			GLib.error ("Wasn't expecting the SerializableCapsicum property '%s'", property_name);
+			Test.message ("Wasn't expecting the SerializableCapsicum property '%s'", property_name);
+			assert_not_reached ();
 		}
 
 		// returning null does a normal serialization
@@ -249,26 +254,36 @@ class SerializableTest : GXmlTest {
 				ratings.append (21);
 
 				capsicum = new SerializableCapsicum (2, 3, 5, ratings);
-				node = Serialization.serialize_object (capsicum);
+				try {
+					node = Serialization.serialize_object (capsicum);
+				} catch (GXml.SerializationError e) {
+					Test.message ("%s", e.message);
+					assert_not_reached ();
+				}
 
 				expectation = "<Object otype=\"SerializableCapsicum\" oid=\"0x[0-9a-f]+\"><Property pname=\"height\" ptype=\"gint\">6</Property><Property pname=\"ratings\" ptype=\"gpointer\"><rating>8</rating><rating>13</rating><rating>21</rating></Property></Object>";
 
 				try {
 					regex = new Regex (expectation);
 					if (! regex.match (node.to_string ())) {
-						GLib.warning ("Did not serialize as expected.  Got [%s] but expected [%s]", node.to_string (), expectation);
-						GLib.Test.fail ();
+						Test.message ("Did not serialize as expected.  Got [%s] but expected [%s]", node.to_string (), expectation);
+						assert_not_reached ();
 					}
 
-					capsicum_new = (SerializableCapsicum)Serialization.deserialize_object (node);
+					try {
+						capsicum_new = (SerializableCapsicum)Serialization.deserialize_object (node);
+					} catch (GXml.SerializationError e) {
+						Test.message ("%s", e.message);
+						assert_not_reached ();
+					}
 					if (capsicum_new.height != 5 || ratings.length () != 3 || ratings.nth_data (0) != 8 || ratings.nth_data (2) != 21) {
-						GLib.warning ("Did not deserialize as expected.  Got [%s] but expected height and ratings from [%s]", capsicum_new.to_string (), capsicum.to_string ());
-						GLib.Test.fail ();
+						Test.message ("Did not deserialize as expected.  Got [%s] but expected height and ratings from [%s]", capsicum_new.to_string (), capsicum.to_string ());
+						assert_not_reached ();
 					}
 				} catch (RegexError e) {
-					GLib.warning ("Regular expression [%s] for test failed: %s",
+					Test.message ("Regular expression [%s] for test failed: %s",
 						      expectation, e.message);
-					GLib.Test.fail ();
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/serializable/interface_override_properties_view", () => {
diff --git a/test/SerializationTest.vala b/test/SerializationTest.vala
index d5ac5d9..4696f81 100644
--- a/test/SerializationTest.vala
+++ b/test/SerializationTest.vala
@@ -254,13 +254,13 @@ class SerializationTest : GXmlTest {
 			object_new = Serialization.deserialize_object (doc.document_element);
 
 			if (! equals (object, object_new)) {
-				GLib.warning ("Expected [%s] but got [%s]",
+				Test.message ("Expected [%s] but got [%s]",
 					      stringify (object), stringify (object_new));
-				GLib.Test.fail ();
+				assert_not_reached ();
 			}
 		} catch (GLib.Error e) {
-			GLib.message ("%s", e.message);
-			GLib.Test.fail ();
+			Test.message ("%s", e.message);
+			assert_not_reached ();
 		}
 
 		return object_new;
@@ -291,17 +291,17 @@ class SerializationTest : GXmlTest {
 
 					regex = new Regex (expectation);
 					if (! regex.match (fruit_xml.to_string ())) {
-						GLib.warning ("Expected [%s] but found [%s]",
+						Test.message ("Expected [%s] but found [%s]",
 							      expectation, fruit_xml.to_string ());
-						GLib.Test.fail ();
+						assert_not_reached ();
 					}
 				} catch (RegexError e) {
-					GLib.warning ("Regular expression [%s] for test failed: %s",
+					Test.message ("Regular expression [%s] for test failed: %s",
 						      expectation, e.message);
-					GLib.Test.fail ();
+					assert_not_reached ();
 				} catch (GXml.SerializationError e) {
-					GLib.warning ("%s", e.message);
-					GLib.Test.fail ();
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 
 			});
@@ -315,12 +315,12 @@ class SerializationTest : GXmlTest {
 
 					// we expect 9 because Fruit triples it in the setter
 					if (fruit.age != 9) {
-						GLib.warning ("Expected fruit.age [%d] but found [%d]", 9, fruit.age);
-						GLib.Test.fail (); // TODO: check weight?
+						Test.message ("Expected fruit.age [%d] but found [%d]", 9, fruit.age);
+						assert_not_reached (); // TODO: check weight?
 					}
 				} catch (GLib.Error e) {
-					GLib.message ("%s", e.message);
-					GLib.Test.fail ();
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/serialization/xml_deserialize_no_type", () => {
@@ -332,8 +332,8 @@ class SerializationTest : GXmlTest {
 					doc = new Document.from_string ("<Object otype='Fruit'><Property pname='age'>3</Property></Object>");
 					fruit = (Fruit)Serialization.deserialize_object (doc.document_element);
 				} catch (GLib.Error e) {
-					GLib.message ("%s", e.message);
-					GLib.Test.fail ();
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/serialization/xml_deserialize_bad_property_name", () => {
@@ -342,13 +342,13 @@ class SerializationTest : GXmlTest {
 				try {
 					doc = new Document.from_string ("<Object otype='Fruit'><Property name='badname'>3</Property></Object>");
 					Serialization.deserialize_object (doc.document_element);
-					GLib.message ("Expected SerializationError.UNKNOWN_PROPERTY to be thrown for property 'badname' in object 'Fruit' :(  Did not happen.");
-					GLib.Test.fail ();
+					Test.message ("Expected SerializationError.UNKNOWN_PROPERTY to be thrown for property 'badname' in object 'Fruit' :(  Did not happen.");
+					assert_not_reached ();
 				} catch (GXml.SerializationError.UNKNOWN_PROPERTY e) {
 					// Pass
 				} catch (GLib.Error e) {
-					GLib.message ("%s", e.message);
-					GLib.Test.fail ();
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/serialization/xml_deserialize_bad_object_type", () => {
@@ -357,12 +357,12 @@ class SerializationTest : GXmlTest {
 				try {
 					doc = new Document.from_string ("<Object otype='BadType'></Object>");
 					Serialization.deserialize_object (doc.document_element);
-					GLib.Test.fail ();
+					assert_not_reached ();
 				} catch (GXml.SerializationError.UNKNOWN_TYPE e) {
 					// Pass
 				} catch (GLib.Error e) {
-					GLib.message ("%s", e.message);
-					GLib.Test.fail ();
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/serialization/xml_deserialize_bad_property_type", () => {
@@ -375,12 +375,12 @@ class SerializationTest : GXmlTest {
 				try {
 					doc = new Document.from_string ("<Object otype='Fruit'><Property pname='age' ptype='badtype'>blue</Property></Object>");
 					fruit = (Fruit)Serialization.deserialize_object (doc.document_element);
-					GLib.Test.fail ();
+					assert_not_reached ();
 				} catch (GXml.SerializationError.UNSUPPORTED_TYPE e) {
 					// Pass
 				} catch (GLib.Error e) {
-					GLib.message ("%s", e.message);
-					GLib.Test.fail ();
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/serialization/simple_properties", () => {
@@ -412,13 +412,18 @@ class SerializationTest : GXmlTest {
 				simple_properties = new SimpleProperties (3, 4.2, "catfish", true, 0);
 				obj = new ComplexDuplicateProperties (simple_properties);
 
-				xml = Serialization.serialize_object (obj);
+				try {
+					xml = Serialization.serialize_object (obj);
 
-				restored = (ComplexDuplicateProperties)Serialization.deserialize_object (xml);
+					restored = (ComplexDuplicateProperties)Serialization.deserialize_object (xml);
+				} catch (GXml.SerializationError e) {
+					Test.message ("%s", e.message);
+					assert_not_reached ();
+				}
 
 				if (restored.a != restored.b) {
-					GLib.message ("Properties a (%p) and b (%p) should reference the same object but do not", restored.a, restored.b);
-					GLib.Test.fail ();
+					Test.message ("Properties a (%p) and b (%p) should reference the same object but do not", restored.a, restored.b);
+					assert_not_reached ();
 				}
 			});
 		Test.add_func ("/gxml/serialization/complex_complex_properties", () => {
@@ -438,7 +443,7 @@ class SerializationTest : GXmlTest {
 			});
 		// TODO: more to do, for structs and stuff and things that do interfaces
 		if (auto_fields) {
-			GLib.message ("WARNING: thorough tests are expected to fail, as they test " +
+			Test.message ("WARNING: thorough tests are expected to fail, as they test " +
 				      "feature not yet implemented, pertaining to automatic handling " +
 				      "of fields and private properties.  You can achieve the same " +
 				      "effect as these features, though, by making a class implement " +
@@ -509,17 +514,17 @@ class SerializationTest : GXmlTest {
 
 						regex = new Regex (expectation);
 						if (! regex.match (fruit_xml.to_string ())) {
-							GLib.warning ("Expected [%s] but found [%s]",
+							Test.message ("Expected [%s] but found [%s]",
 								      expectation, fruit_xml.to_string ());
-							GLib.Test.fail ();
+							assert_not_reached ();
 						}
 					} catch (RegexError e) {
-						GLib.warning ("Regular expression [%s] for test failed: %s",
+						Test.message ("Regular expression [%s] for test failed: %s",
 							      expectation, e.message);
-						GLib.Test.fail ();
+						assert_not_reached ();
 					} catch (GXml.SerializationError e) {
-						GLib.warning ("%s", e.message);
-						GLib.Test.fail ();
+						Test.message ("%s", e.message);
+						assert_not_reached ();
 					}
 				});
 			Test.add_func ("/gxml/serialization/xml_deserialize_fields", () => {
@@ -537,15 +542,15 @@ class SerializationTest : GXmlTest {
 						fruit = (Fruit)Serialization.deserialize_object (doc.document_element);
 
 						if (! fruit.test ("blue", 11, "fish", 3)) {
-							GLib.warning ("Expected [\"%s\", %d, \"%s\", %d] but found [%s]", "blue", 11, "fish", 3, fruit.to_string ());
-							GLib.Test.fail (); // Note that age sets weight normally
+							Test.message ("Expected [\"%s\", %d, \"%s\", %d] but found [%s]", "blue", 11, "fish", 3, fruit.to_string ());
+							assert_not_reached (); // Note that age sets weight normally
 						}
 					} catch (GXml.SerializationError e) {
-						GLib.message ("%s", e.message);
-						GLib.Test.fail ();
+						Test.message ("%s", e.message);
+						assert_not_reached ();
 					} catch (GXml.DomError e) {
-						GLib.message ("%s", e.message);
-						GLib.Test.fail ();
+						Test.message ("%s", e.message);
+						assert_not_reached ();
 					}
 				});
 			Test.add_func ("/gxml/serialization/simple_fields", () => {
diff --git a/test/TextTest.vala b/test/TextTest.vala
index cfee7a2..79a2ab5 100644
--- a/test/TextTest.vala
+++ b/test/TextTest.vala
@@ -33,22 +33,20 @@ class TextTest : GXmlTest {
 
 					try {
 						txt2.split_text (-1);
-						assert (false);
+						assert_not_reached ();
 					} catch (DomError.INDEX_SIZE e) {
-						assert (true);
 					}
 					try {
 						txt2.split_text (10);
-						assert (false);
+						assert_not_reached ();
 					} catch (DomError.INDEX_SIZE e) {
-						assert (true);
 					}
 					assert (txt2.node_value == "Const");
 
 
 				} catch (GXml.DomError e) {
-					GLib.warning ("%s", e.message);
-					assert (false);
+					Test.message ("%s", e.message);
+					assert_not_reached ();
 				}
 			});
 	}
diff --git a/test/ValaLibxml2Test.vala b/test/ValaLibxml2Test.vala
index f6f503d..d75c6ea 100644
--- a/test/ValaLibxml2Test.vala
+++ b/test/ValaLibxml2Test.vala
@@ -32,8 +32,8 @@ class ValaLibxml2Test : GXmlTest {
 					/* deallocator: takes (void *payload, string name), just frees payload */
 					// TODO: figure out a way to test whether table was freed
 				// } catch (Error e) {
-				// 	GLib.warning ("%s", e.message);
-				// 	assert (false);
+				// 	Test.message ("%s", e.message);
+				// 	assert_not_reached ();
 				// }
 			});
 	}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]