[aravis] tests: check integer and string implementations of boolean and enumeration nodes.
- From: Emmanuel Pacaud <emmanuel src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [aravis] tests: check integer and string implementations of boolean and enumeration nodes.
- Date: Mon, 4 Jun 2012 20:56:02 +0000 (UTC)
commit b54000c5a163058c39ca57a03f25c760d4ac27ab
Author: Emmanuel Pacaud <emmanuel gnome org>
Date: Mon Jun 4 22:54:57 2012 +0200
tests: check integer and string implementations of boolean and enumeration nodes.
And fix an issue in enumeration:string_get_max_length.
src/arvgcenumeration.c | 2 +-
tests/genicam.c | 35 ++++++++++++++++++++++++++++++++++-
2 files changed, 35 insertions(+), 2 deletions(-)
---
diff --git a/src/arvgcenumeration.c b/src/arvgcenumeration.c
index f444adb..7c4b35e 100644
--- a/src/arvgcenumeration.c
+++ b/src/arvgcenumeration.c
@@ -417,7 +417,7 @@ arv_gc_enumeration_get_max_string_length (ArvGcString *gc_string, GError **error
name = arv_gc_feature_node_get_name (iter->data);
length = name != NULL ? strlen (name) : 0;
if (length > max_length)
- length = max_length;
+ max_length = length;
}
return max_length;
diff --git a/tests/genicam.c b/tests/genicam.c
index 21b76bb..bd9d3c1 100644
--- a/tests/genicam.c
+++ b/tests/genicam.c
@@ -1,5 +1,6 @@
#include <glib.h>
#include <arv.h>
+#include <string.h>
static void
integer_test (void)
@@ -65,6 +66,7 @@ boolean_test (void)
ArvGcNode *node_b;
gboolean v_boolean;
const char *v_string;
+ gint64 v_int64;
device = arv_fake_device_new ("TEST0");
g_assert (ARV_IS_FAKE_DEVICE (device));
@@ -74,10 +76,14 @@ boolean_test (void)
node = arv_gc_get_node (genicam, "RWBoolean");
g_assert (ARV_IS_GC_BOOLEAN (node));
+ g_assert (ARV_IS_GC_INTEGER (node));
v_boolean = arv_gc_boolean_get_value (ARV_GC_BOOLEAN (node), NULL);
g_assert_cmpint (v_boolean, ==, TRUE);
+ v_int64 = arv_gc_integer_get_value (ARV_GC_INTEGER (node), NULL);
+ g_assert_cmpint (v_int64, ==, 1);
+
v_string = arv_gc_feature_node_get_value_as_string (ARV_GC_FEATURE_NODE (node), NULL);
g_assert_cmpstr (v_string, ==, "true");
@@ -85,6 +91,9 @@ boolean_test (void)
v_boolean = arv_gc_boolean_get_value (ARV_GC_BOOLEAN (node), NULL);
g_assert_cmpint (v_boolean, ==, FALSE);
+ v_int64 = arv_gc_integer_get_value (ARV_GC_INTEGER (node), NULL);
+ g_assert_cmpint (v_int64, ==, 0);
+
v_string = arv_gc_feature_node_get_value_as_string (ARV_GC_FEATURE_NODE (node), NULL);
g_assert_cmpstr (v_string, ==, "false");
@@ -169,6 +178,7 @@ enumeration_test (void)
gint64 v_int64;
gint64 *values;
guint n_values;
+ const char *v_string;
device = arv_fake_device_new ("TEST0");
g_assert (ARV_IS_FAKE_DEVICE (device));
@@ -178,6 +188,8 @@ enumeration_test (void)
node = arv_gc_get_node (genicam, "Enumeration");
g_assert (ARV_IS_GC_ENUMERATION (node));
+ g_assert (ARV_IS_GC_INTEGER (node));
+ g_assert (ARV_IS_GC_STRING (node));
v_int64 = arv_gc_enumeration_get_int_value (ARV_GC_ENUMERATION (node), NULL);
g_assert_cmpint (v_int64, ==, 0);
@@ -185,9 +197,30 @@ enumeration_test (void)
values = arv_gc_enumeration_get_available_int_values (ARV_GC_ENUMERATION (node), &n_values, NULL);
g_assert_cmpint (n_values, ==, 2);
g_assert (values != NULL);
-
g_free (values);
+ arv_gc_enumeration_set_string_value (ARV_GC_ENUMERATION (node), "Entry1", NULL);
+
+ v_int64 = arv_gc_enumeration_get_int_value (ARV_GC_ENUMERATION (node), NULL);
+ g_assert_cmpint (v_int64, ==, 1);
+
+ v_int64 = arv_gc_integer_get_value (ARV_GC_INTEGER (node), NULL);
+ g_assert_cmpint (v_int64, ==, 1);
+
+ v_string = arv_gc_string_get_value (ARV_GC_STRING (node), NULL);
+ g_assert_cmpstr (v_string, ==, "Entry1");
+
+ arv_gc_string_set_value (ARV_GC_STRING (node), "Entry0", NULL);
+
+ v_int64 = arv_gc_integer_get_value (ARV_GC_INTEGER (node), NULL);
+ g_assert_cmpint (v_int64, ==, 0);
+
+ v_string = arv_gc_string_get_value (ARV_GC_STRING (node), NULL);
+ g_assert_cmpstr (v_string, ==, "Entry0");
+
+ v_int64 = arv_gc_string_get_max_length (ARV_GC_STRING (node), NULL);
+ g_assert_cmpint (v_int64, ==, strlen ("EntryNotImplemented"));
+
g_object_unref (device);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]