[gxml] Added unit tests for SerializableBool



commit 7c384e9b3cb3e1e8238371e273b09a349203a844
Author: Daniel Espinosa <esodan gmail com>
Date:   Sat Sep 26 17:06:16 2015 -0700

    Added unit tests for SerializableBool

 test/GXmlTest.vala                     |    1 +
 test/Makefile.am                       |    1 +
 test/SerializablePropertyBoolTest.vala |   56 ++++++++++++++++++++++++++++++++
 3 files changed, 58 insertions(+), 0 deletions(-)
---
diff --git a/test/GXmlTest.vala b/test/GXmlTest.vala
index 3f92356..d188d58 100644
--- a/test/GXmlTest.vala
+++ b/test/GXmlTest.vala
@@ -76,6 +76,7 @@ class GXmlTest {
                TwCommentTest.add_tests ();
                TwDocumentTest.add_tests ();
                TwProcessingInstructionTest.add_tests ();
+               SerializablePropertyBoolTest.add_tests ();
 
                Test.run ();
 
diff --git a/test/Makefile.am b/test/Makefile.am
index 06cda7d..a9031dd 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -38,6 +38,7 @@ sources = \
        ValaLibxml2Test.vala \
        EnumerationTest.vala \
        SerializableTest.vala \
+       SerializablePropertyBoolTest.vala \
        SerializationTest.vala \
        SerializableObjectModelTest.vala \
        SerializableObjectModel-Tw-Test.vala \
diff --git a/test/SerializablePropertyBoolTest.vala b/test/SerializablePropertyBoolTest.vala
new file mode 100644
index 0000000..e2ca3e1
--- /dev/null
+++ b/test/SerializablePropertyBoolTest.vala
@@ -0,0 +1,56 @@
+/* -*- Mode: vala; indent-tabs-mode: nil; tab-width: 2 -*- */
+/**
+ *
+ *  GXml.Serializable.BasicTypeTest
+ *
+ *  Authors:
+ *
+ *       Daniel Espinosa <esodan gmail com>
+ *
+ *
+ *  Copyright (c) 2015 Daniel Espinosa
+ *
+ *  This program is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU Lesser General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public License
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+using GXml;
+class SerializablePropertyBoolTest : GXmlTest {
+  public class BoolNode : SerializableObjectModel
+  {
+    public SerializableBool boolean { get; set; }
+    public int  integer { get; set; default = 0; }
+    public string name { get; set; }
+    public override string node_name () { return "BooleanNode"; }
+    public override string to_string () { return get_type ().name (); }
+  }
+  public static void add_tests () {
+    Test.add_func ("/gxml/serializable/Bool/basic",
+    () => {
+      try {
+        var bn = new BoolNode ();
+        var doc = new xDocument ();
+        bn.serialize (doc);
+        var element = doc.document_element;
+        var b = element.get_attribute_node ("boolean");
+        assert (b == null);
+        var s = element.get_attribute_node ("name");
+        assert (s == null);
+        var i = element.get_attribute_node ("integer");
+        assert (i.value == "0");
+      } catch (GLib.Error e) {
+        Test.message (@"ERROR: $(e.message)");
+        assert_not_reached ();
+      }
+    });
+  }
+}


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