You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

89 lines
2.3 KiB

From 879b15857cdc5b4442f5c9cda6bd58bd8613fcc3 Mon Sep 17 00:00:00 2001
From: Matej Habrnal <mhabrnal@redhat.com>
Date: Thu, 11 Sep 2014 08:39:48 +0200
Subject: [LIBREPORT PATCH 69/93] testsuite: add a test for
index_of_string_in_list
Testing index_of_string_in_list to get right result.
Related:rhbz#1067440
Signed-off-by: Matej Habrnal <mhabrnal@redhat.com>
Conflicts:
tests/Makefile.am
---
tests/Makefile.am | 3 ++-
tests/string_list.at | 36 ++++++++++++++++++++++++++++++++++++
tests/testsuite.at | 1 +
3 files changed, 39 insertions(+), 1 deletion(-)
create mode 100644 tests/string_list.at
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 664c43f..4731bad 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -40,7 +40,8 @@ TESTSUITE_AT = \
libreport_types.at \
xml_definition.at \
report_python.at \
- xfuncs.at
+ xfuncs.at \
+ string_list.at
EXTRA_DIST += $(TESTSUITE_AT)
TESTSUITE = $(srcdir)/testsuite
diff --git a/tests/string_list.at b/tests/string_list.at
new file mode 100644
index 0000000..f66f5fa
--- /dev/null
+++ b/tests/string_list.at
@@ -0,0 +1,36 @@
+# -*- Autotest -*-
+
+AT_BANNER([string_list])
+
+## ----------------------- ##
+## index_of_string_in_list ##
+## ----------------------- ##
+
+AT_TESTFUN([index_of_string_in_list],
+[[
+#include "internal_libreport.h"
+#include <assert.h>
+int main(void)
+{
+ static const char *const list_order[] = {
+ FILENAME_REASON ,
+ FILENAME_TIME ,
+ FILENAME_CMDLINE ,
+ FILENAME_PACKAGE ,
+ FILENAME_UID ,
+ FILENAME_COUNT ,
+ NULL
+ };
+
+ int index = index_of_string_in_list(FILENAME_REASON, (char**) list_order);
+ assert(index == 0);
+
+ index = index_of_string_in_list(FILENAME_COUNT, (char**) list_order);
+ assert(index == 5);
+
+ index = index_of_string_in_list("other", (char**) list_order);
+ assert(index < 0);
+
+ return 0;
+}
+]])
diff --git a/tests/testsuite.at b/tests/testsuite.at
index 92129d8..60b2e94 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -15,3 +15,4 @@ m4_include([make_description.at])
m4_include([libreport_types.at])
m4_include([xml_definition.at])
m4_include([report_python.at])
+m4_include([string_list.at])
--
1.8.3.1