[virt-tools-list] [RFC virt-viewer 09/12] util: Add some runtime testing of virt_viewer_compare_buildid()

Christophe Fergeau cfergeau at redhat.com
Tue Jun 2 14:29:26 UTC 2015


---
 src/virt-viewer-file.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/src/virt-viewer-file.c b/src/virt-viewer-file.c
index 240a111..6865e04 100644
--- a/src/virt-viewer-file.c
+++ b/src/virt-viewer-file.c
@@ -818,6 +818,34 @@ virt_viewer_file_fill_app(VirtViewerFile* self, VirtViewerApp *app, GError **err
     g_return_val_if_fail(VIRT_VIEWER_IS_FILE(self), FALSE);
     g_return_val_if_fail(VIRT_VIEWER_IS_APP(app), FALSE);
 
+    g_assert(virt_viewer_compare_buildid("1-1", "1-1") == 0);
+    g_assert(virt_viewer_compare_buildid("1-1", "1-1.1") == -1);
+    g_assert(virt_viewer_compare_buildid("1-1", "1-2") == -1);
+    g_assert(virt_viewer_compare_buildid("1-3", "1-2") == 1);
+    g_assert(virt_viewer_compare_buildid("2-3", "1-2") == 1);
+    g_assert(virt_viewer_compare_buildid("2-3", "3-2") == -1);
+    g_assert(virt_viewer_compare_buildid("2-3", "3-4") == -1);
+    g_assert(virt_viewer_compare_buildid("4-3", "3-4") == 1);
+
+    g_assert(virt_viewer_compare_buildid("4-", "3-4") == 1);
+    g_assert(virt_viewer_compare_buildid("4-3", "3-") == 1);
+    g_assert(virt_viewer_compare_buildid("-3", "3-4") == -1);
+    g_assert(virt_viewer_compare_buildid("4-3", "-4") == 1);
+    g_assert(virt_viewer_compare_buildid("-3", "-4") == -1);
+    g_assert(virt_viewer_compare_buildid("4", "3-4") == 1);
+    g_assert(virt_viewer_compare_buildid("4-3", "3") == 1);
+    g_assert(virt_viewer_compare_buildid("3", "3-4") == -1);
+    g_assert(virt_viewer_compare_buildid("4-3", "4") == 1);
+    g_assert(virt_viewer_compare_buildid("-3", "-4") == -1);
+
+#if 0
+    /* These trigger runtime warnings */
+    g_assert(virt_viewer_compare_buildid("-3", "-") == 1);
+    g_assert(virt_viewer_compare_buildid("", "-") == 0);
+    g_assert(virt_viewer_compare_buildid("", "") == 0);
+    g_assert(virt_viewer_compare_buildid("", NULL) == 0);
+    g_assert(virt_viewer_compare_buildid(NULL, NULL) == 0);
+#endif
     if (!virt_viewer_file_check_min_version(self, error)) {
         return FALSE;
     }
-- 
2.4.2




More information about the virt-tools-list mailing list