[Spice-devel] [PATCH spice-common v2] test-region: Create proper test for region from source code

Christophe Fergeau cfergeau at redhat.com
Wed Jun 27 07:47:06 UTC 2018


On Tue, Jun 26, 2018 at 01:42:20PM -0400, Frediano Ziglio wrote:
> Why use GTest API ?

Mostly for consistency.

> I honestly just created a test and I prefer to have at least a first commit
> with a verbatim copy of the old test, in case we found some bugs later.
> For me is more important to have a test than the style of it.
> Was working, why changing it, is just more work (honestly I didn't spend
> much to say with GTest would be better or not... was doing some experiments
> with Meson+Gitlab+coverage output and I found that region.c was not that
> tested... so I found the test code there and I turned into a test
> see https://freddy77.pages.freedesktop.org/spice-common/)

I'm not asking for huge changes to the copied code, just suggesting
this:

diff --git a/tests/test-region.c b/tests/test-region.c
index 38b3203..5a00cce 100644
--- a/tests/test-region.c
+++ b/tests/test-region.c
@@ -127,7 +127,7 @@ enum {
     EXPECT_CONT,
 };

-int main(void)
+static void test_region(void)
 {
     QRegion _r1, _r2, _r3;
     QRegion *r1 = &_r1;
@@ -396,6 +396,13 @@ int main(void)
     region_destroy(r3);
     region_destroy(r1);
     region_destroy(r2);
+}
+
+int main(int argc, char **argv)
+{
+    g_test_init(&argc, &argv, NULL);
+
+    g_test_add_func("/spice-common/region", test_region);

-    return 0;
+    return g_test_run();
 }

Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20180627/0d658d1e/attachment.sig>


More information about the Spice-devel mailing list