← Back to team overview

zeitgeist team mailing list archive

[Branch ~zeitgeist/zeitgeist/bluebird] Rev 425: Make sure we mangle dots

 

------------------------------------------------------------
revno: 425
committer: Michal Hruby <michal.mhr@xxxxxxxxx>
branch nick: zeitgeist
timestamp: Wed 2012-03-14 13:58:22 +0100
message:
  Make sure we mangle dots
modified:
  extensions/fts++/stringutils.cpp
  extensions/fts++/test/test-indexer.cpp
  extensions/fts++/test/test-stringutils.cpp


--
lp:zeitgeist
https://code.launchpad.net/~zeitgeist/zeitgeist/bluebird

Your team Zeitgeist Framework Team is subscribed to branch lp:zeitgeist.
To unsubscribe from this branch go to https://code.launchpad.net/~zeitgeist/zeitgeist/bluebird/+edit-subscription
=== modified file 'extensions/fts++/stringutils.cpp'
--- extensions/fts++/stringutils.cpp	2012-03-14 12:50:33 +0000
+++ extensions/fts++/stringutils.cpp	2012-03-14 12:58:22 +0000
@@ -71,7 +71,7 @@
 {
   string s(orig);
   size_t pos = 0;
-  while ((pos = s.find_first_of (": /-", pos)) != string::npos)
+  while ((pos = s.find_first_of (": /-.", pos)) != string::npos)
   {
     s.replace (pos, 1, 1, '_');
     pos++;

=== modified file 'extensions/fts++/test/test-indexer.cpp'
--- extensions/fts++/test/test-indexer.cpp	2012-03-14 12:50:33 +0000
+++ extensions/fts++/test/test-indexer.cpp	2012-03-14 12:58:22 +0000
@@ -190,7 +190,7 @@
   
   zeitgeist_subject_set_interpretation (subject, ZEITGEIST_NFO_PRESENTATION);
   zeitgeist_subject_set_manifestation (subject, ZEITGEIST_NFO_FILE_DATA_OBJECT);
-  zeitgeist_subject_set_uri (subject, "file:///home/username/directory-with-dashes/CamelCasePresentation.pdf");
+  zeitgeist_subject_set_uri (subject, "file:///home/username/directory-with-dashes/and.dot/CamelCasePresentation.pdf");
   zeitgeist_subject_set_text (subject, NULL);
   zeitgeist_subject_set_mimetype (subject, "application/pdf");
 
@@ -602,6 +602,49 @@
 }
 
 static void
+test_simple_dots_prefix (Fixture *fix, gconstpointer data)
+{
+  guint matches;
+  guint event_id;
+  ZeitgeistEvent* event;
+  ZeitgeistSubject *subject;
+
+  // add test events to DBs
+  index_event (fix, create_test_event1 ());
+  index_event (fix, create_test_event2 ());
+  index_event (fix, create_test_event3 ());
+  index_event (fix, create_test_event4 ());
+  index_event (fix, create_test_event5 ());
+  index_event (fix, create_test_event6 ());
+  event_id = index_event (fix, create_test_event7 ());
+
+  GPtrArray *event_template = g_ptr_array_new ();
+  event = zeitgeist_event_new ();
+  subject = zeitgeist_subject_new ();
+  zeitgeist_subject_set_uri (subject,
+      "file:///home/username/directory-with-dashes/and.dot/*");
+  zeitgeist_event_add_subject (event, subject);
+  g_ptr_array_add (event_template, event);
+
+  GPtrArray *results =
+    zeitgeist_indexer_search (fix->indexer,
+                              "pdf",
+                              zeitgeist_time_range_new_anytime (),
+                              event_template,
+                              0,
+                              10,
+                              ZEITGEIST_RESULT_TYPE_MOST_RECENT_EVENTS,
+                              &matches,
+                              NULL);
+
+  g_assert_cmpuint (matches, >, 0);
+  g_assert_cmpuint (results->len, ==, 1);
+
+  event = (ZeitgeistEvent*) results->pdata[0];
+  g_assert_cmpuint (zeitgeist_event_get_id (event), ==, event_id);
+}
+
+static void
 test_simple_cjk (Fixture *fix, gconstpointer data)
 {
   guint matches;
@@ -781,6 +824,8 @@
               setup, test_simple_camelcase, teardown);
   g_test_add ("/Zeitgeist/FTS/Indexer/PrefixWithDashes", Fixture, 0,
               setup, test_simple_dashes_prefix, teardown);
+  g_test_add ("/Zeitgeist/FTS/Indexer/PrefixWithDots", Fixture, 0,
+              setup, test_simple_dots_prefix, teardown);
   g_test_add ("/Zeitgeist/FTS/Indexer/URLUnescape", Fixture, 0,
               setup, test_simple_url_unescape, teardown);
   g_test_add ("/Zeitgeist/FTS/Indexer/IDNSupport", Fixture, 0,

=== modified file 'extensions/fts++/test/test-stringutils.cpp'
--- extensions/fts++/test/test-stringutils.cpp	2012-03-14 12:50:33 +0000
+++ extensions/fts++/test/test-stringutils.cpp	2012-03-14 12:58:22 +0000
@@ -76,7 +76,7 @@
 
   g_assert_cmpstr ("file", ==, StringUtils::MangleUri("file").c_str ());
   g_assert_cmpstr ("file___", ==, StringUtils::MangleUri("file://").c_str ());
-  g_assert_cmpstr ("http___www.zeitgeist_project.com", ==,
+  g_assert_cmpstr ("http___www_zeitgeist_project_com", ==,
       StringUtils::MangleUri("http://www.zeitgeist-project.com";).c_str ());
 
   g_assert_cmpstr ("scheme_no_spaces_in_uris", ==,