[virt-tools-list] [RFC virt-viewer 09/12] util: Add some runtime testing of virt_viewer_compare_buildid()
Christophe Fergeau
cfergeau at redhat.com
Wed Jun 3 15:01:35 UTC 2015
Hey,
On Wed, Jun 03, 2015 at 09:51:12AM -0500, Jonathon Jongsma wrote:
> On Tue, 2015-06-02 at 16:29 +0200, Christophe Fergeau wrote:
> > ---
> > 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;
> > }
>
>
> I don't like adding these tests to the actual code. Why don't you think
> the previous test case you added was sufficient?
I forgot to drop that patch after adding the test case ;)
Thanks!
Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/virt-tools-list/attachments/20150603/a422ceed/attachment.sig>
More information about the virt-tools-list
mailing list