summaryrefslogtreecommitdiff
path: root/testsuite/indexers
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@gmail.com>2003-01-05 16:50:35 +0000
committerWim Taymans <wim.taymans@gmail.com>2003-01-05 16:50:35 +0000
commitd4881f29fdc93d62cd547548364525c05ed93f5b (patch)
tree936b32e398413f6d685b5cd7b94bdf6c89e60e78 /testsuite/indexers
parent841f9b14f4798c1bd4ca0b628bb2e6065af93294 (diff)
Applied patch 13357
Original commit message from CVS: Applied patch 13357
Diffstat (limited to 'testsuite/indexers')
-rw-r--r--testsuite/indexers/cache1.c73
1 files changed, 45 insertions, 28 deletions
diff --git a/testsuite/indexers/cache1.c b/testsuite/indexers/cache1.c
index 36922e5a0..0392a196c 100644
--- a/testsuite/indexers/cache1.c
+++ b/testsuite/indexers/cache1.c
@@ -20,73 +20,90 @@
#include <gst/gst.h>
static void
-lookup (GstCache *cache, GstCacheLookupMethod method,
+lookup (GstIndex *index, GstIndexLookupMethod method,
GstFormat src_format, gint64 src_value,
- GstFormat dest_format)
+ GstFormat dest_format, gint64 expecting)
{
- GstCacheEntry *entry;
+ GstIndexEntry *entry;
gint64 result;
- entry = gst_cache_get_assoc_entry (cache, 0, method,
+ entry = gst_index_get_assoc_entry (index, 0, method, 0,
src_format, src_value);
if (entry) {
- gst_cache_entry_assoc_map (entry, dest_format, &result);
+ gst_index_entry_assoc_map (entry, dest_format, &result);
- g_print ("%lld\n", result);
+ if (result == expecting) {
+ g_print ("OK (%lld)\n", result);
+ } else {
+ g_print ("FAIL - expecting %lld, got %lld\n", expecting, result);
+ }
}
else {
const GstFormatDefinition *def = gst_format_get_details (src_format);
- g_print ("no cache entry found for %lld %s\n", src_value, def->nick);
+ if (expecting == -1)
+ g_print ("OK (not found)\n");
+ else
+ g_print ("FAIL - no index entry found for %lld %s, expecting %lld\n",
+ src_value, def->nick, expecting);
}
}
-typedef struct _GstCacheTestCase
+typedef struct _GstIndexTestCase
{
- GstCacheLookupMethod method;
+ GstIndexLookupMethod method;
GstFormat src_format;
gint64 src_value;
GstFormat dest_format;
-} GstCacheTestCase;
+ gint64 expecting;
+} GstIndexTestCase;
-const static GstCacheTestCase cases[] =
+const static GstIndexTestCase cases[] =
{
- { GST_CACHE_LOOKUP_EXACT, GST_FORMAT_BYTES, 3, GST_FORMAT_TIME },
- { GST_CACHE_LOOKUP_EXACT, GST_FORMAT_TIME, 5000, GST_FORMAT_BYTES },
- { GST_CACHE_LOOKUP_EXACT, GST_FORMAT_TIME, 5010, GST_FORMAT_BYTES },
- { GST_CACHE_LOOKUP_BEFORE, GST_FORMAT_TIME, 5010, GST_FORMAT_BYTES },
- { GST_CACHE_LOOKUP_BEFORE, GST_FORMAT_TIME, 0, GST_FORMAT_BYTES },
- { GST_CACHE_LOOKUP_AFTER, GST_FORMAT_TIME, G_MAXINT64, GST_FORMAT_BYTES },
- { GST_CACHE_LOOKUP_AFTER, GST_FORMAT_TIME, 0, GST_FORMAT_BYTES },
- { GST_CACHE_LOOKUP_BEFORE, GST_FORMAT_TIME, -1, GST_FORMAT_BYTES },
- { GST_CACHE_LOOKUP_BEFORE, GST_FORMAT_TIME, G_MAXINT64, GST_FORMAT_BYTES },
- { GST_CACHE_LOOKUP_AFTER, GST_FORMAT_TIME, G_MAXINT64, GST_FORMAT_BYTES },
+ { GST_INDEX_LOOKUP_EXACT, GST_FORMAT_BYTES, 3, GST_FORMAT_TIME, 3000 },
+ { GST_INDEX_LOOKUP_EXACT, GST_FORMAT_TIME, 5000, GST_FORMAT_BYTES, 5 },
+ { GST_INDEX_LOOKUP_EXACT, GST_FORMAT_TIME, 5010, GST_FORMAT_BYTES, -1 },
+ { GST_INDEX_LOOKUP_BEFORE, GST_FORMAT_TIME, 5010, GST_FORMAT_BYTES, 5 },
+ { GST_INDEX_LOOKUP_AFTER, GST_FORMAT_TIME, 5010, GST_FORMAT_BYTES, 6 },
+ { GST_INDEX_LOOKUP_BEFORE, GST_FORMAT_TIME, 0, GST_FORMAT_BYTES, 0 },
+ { GST_INDEX_LOOKUP_AFTER, GST_FORMAT_TIME, G_MAXINT64, GST_FORMAT_BYTES, -1 },
+ { GST_INDEX_LOOKUP_AFTER, GST_FORMAT_TIME, 0, GST_FORMAT_BYTES, 0 },
+ { GST_INDEX_LOOKUP_BEFORE, GST_FORMAT_TIME, -1, GST_FORMAT_BYTES, -1 },
+ { GST_INDEX_LOOKUP_BEFORE, GST_FORMAT_TIME, G_MAXINT64, GST_FORMAT_BYTES, 99999 },
+ { GST_INDEX_LOOKUP_AFTER, GST_FORMAT_TIME, G_MAXINT64, GST_FORMAT_BYTES, -1 },
};
gint
main (gint argc, gchar *argv[])
{
- GstCache *cache;
+ GstIndex *index;
GstElement *element;
gint i, id;
gst_init (&argc, &argv);
- cache = gst_cache_factory_make ("memcache");
- g_assert (cache != NULL);
+ if (argc != 2)
+ { g_print ("usage: cache1 (memindex | fileindex)\n"); exit (0); }
+
+ index = gst_index_factory_make (argv[1]);
+ g_assert (index != NULL);
element = gst_element_factory_make ("identity", "element");
g_assert (element != NULL);
- gst_cache_get_writer_id (cache, GST_OBJECT (element), &id);
+ gst_index_get_writer_id (index, GST_OBJECT (element), &id);
+
+ g_print ("Building index...\n");
for (i = 0; i < 100000; i++) {
- gst_cache_add_association (cache, 0, 0, GST_FORMAT_BYTES, (gint64)i, GST_FORMAT_TIME,
+ gst_index_add_association (index, 0, 0, GST_FORMAT_BYTES, (gint64)i, GST_FORMAT_TIME,
(gint64) (i * 1000), 0);
}
- for (i = 0; i < (sizeof (cases) / sizeof (GstCacheTestCase)); i++) {
- lookup (cache, cases[i].method, cases[i].src_format, cases[i].src_value, cases[i].dest_format);
+ g_print ("Testing index...\n");
+
+ for (i = 0; i < (sizeof (cases) / sizeof (GstIndexTestCase)); i++) {
+ lookup (index, cases[i].method, cases[i].src_format, cases[i].src_value, cases[i].dest_format, cases[i].expecting);
}
return 0;