Signed-off-by: Peter Hutterer <[email protected]>
---
 test/wacom-tests.c |   36 ++++++++++++++++++++++++++++++++++++
 1 files changed, 36 insertions(+), 0 deletions(-)

diff --git a/test/wacom-tests.c b/test/wacom-tests.c
index 8209397..c4c78fe 100644
--- a/test/wacom-tests.c
+++ b/test/wacom-tests.c
@@ -4,10 +4,46 @@
 
 #include <glib.h>
 #include "fake-symbols.h"
+#include <xf86Wacom.h>
+
+
+/**
+ * Test refcounting of the common struct.
+ */
+static void
+test_common_ref(void)
+{
+    WacomCommonPtr common;
+    WacomCommonPtr second;
+
+    common = wcmNewCommon();
+    g_assert(common);
+    g_assert(common->refcnt == 1);
+
+    second = wcmRefCommon(common);
+
+    g_assert(second == common);
+    g_assert(second->refcnt == 2);
+
+    wcmFreeCommon(&second);
+    g_assert(common);
+    g_assert(!second);
+    g_assert(common->refcnt == 1);
+
+    second = wcmRefCommon(NULL);
+    g_assert(common != second);
+    g_assert(second->refcnt == 1);
+    g_assert(common->refcnt == 1);
+
+    wcmFreeCommon(&second);
+    wcmFreeCommon(&common);
+    g_assert(!second && !common);
+}
 
 
 int main(int argc, char** argv)
 {
     g_test_init(&argc, &argv, NULL);
+    g_test_add_func("/common/refcounting", test_common_ref);
     return g_test_run();
 }
-- 
1.7.3.4


------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
Linuxwacom-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to