summaryrefslogtreecommitdiff
path: root/tests/libtracker-fts
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2013-10-11 09:07:27 +0200
committerSam Thursfield <sam.thursfield@codethink.co.uk>2013-11-25 16:38:43 +0000
commit7896ad6f6ed4c559509dd27eb7e62aa330a70a2c (patch)
treee486e7632d7d23a8c67a159a7add6481adfb2d74 /tests/libtracker-fts
parent3ad3b79ef9f9e0ffbd6d00796007d70c6684a747 (diff)
downloadtracker-7896ad6f6ed4c559509dd27eb7e62aa330a70a2c.tar.gz
test,libtracker-fts: allow alternate number of expected words
In ICU 50 the word splitting algorithm changed, so this test may get different results depending on the host environment. The test simply needs to verifying that word splitting works, so it should allow either value. As of November 2013 Ubuntu is still shipping an older version of ICU so it would be awkward to simply increase the version we depend on. https://bugzilla.gnome.org/show_bug.cgi?id=699412
Diffstat (limited to 'tests/libtracker-fts')
-rw-r--r--tests/libtracker-fts/tracker-parser-test.c38
1 files changed, 25 insertions, 13 deletions
diff --git a/tests/libtracker-fts/tracker-parser-test.c b/tests/libtracker-fts/tracker-parser-test.c
index 9d3c2c93c..6dd0cbbde 100644
--- a/tests/libtracker-fts/tracker-parser-test.c
+++ b/tests/libtracker-fts/tracker-parser-test.c
@@ -94,6 +94,7 @@ struct TestDataExpectedNWords {
const gchar *str;
gboolean ignore_numbers;
guint expected_nwords;
+ gint alternate_expected_nwords;
};
/* Common expected_word test method */
@@ -130,8 +131,19 @@ expected_nwords_check (TrackerParserTestFixture *fixture,
nwords++;
}
- /* Check if input is same as expected */
- g_assert_cmpuint (nwords, == , testdata->expected_nwords);
+ /* Some tests will yield different results when using different versions of
+ * libicu (e.g. chinese ones). Handle this by allowing an alternate number
+ * of words expected in the test. Note that our whole purpose is to test
+ * that we can split different words, not much about the number of words
+ * itself (althogh we should check that as well) */
+
+ if (testdata->alternate_expected_nwords < 0)
+ /* Check if input is same as expected */
+ g_assert_cmpuint (nwords, == , testdata->expected_nwords);
+ else
+ /* We'll assert if both expected number of words fail */
+ g_assert ((nwords == testdata->expected_nwords) ||
+ (nwords == testdata->alternate_expected_nwords));
}
/* -------------- EXPECTED WORD TESTS ----------------- */
@@ -290,19 +302,19 @@ static const TestDataExpectedWord test_data_casefolding[] = {
/* Number of expected words tests */
static const TestDataExpectedNWords test_data_nwords[] = {
- { "The quick (\"brown\") fox can’t jump 32.3 feet, right?", TRUE, 8 },
- { "The quick (\"brown\") fox can’t jump 32.3 feet, right?", FALSE, 10 },
+ { "The quick (\"brown\") fox can’t jump 32.3 feet, right?", TRUE, 8, -1 },
+ { "The quick (\"brown\") fox can’t jump 32.3 feet, right?", FALSE, 10, -1 },
/* Note: as of 0.9.15, the dot is always a word breaker, even between
* numbers. */
- { "filename.txt", TRUE, 2 },
- { ".hidden.txt", TRUE, 2 },
- { "noextension.", TRUE, 1 },
- { "ホモ・サピエンス", TRUE, 2 }, /* katakana */
- { "喂人类", TRUE, 2 }, /* chinese */
- { "Американские суда находятся в международных водах.", TRUE, 6 }, /* russian */
- { "Bần chỉ là một anh nghèo xác", TRUE, 7 }, /* vietnamese */
- { "ホモ・サピエンス 喂人类 katakana, chinese, english", TRUE, 7 }, /* mixed */
- { NULL, FALSE, 0 }
+ { "filename.txt", TRUE, 2, -1 },
+ { ".hidden.txt", TRUE, 2, -1 },
+ { "noextension.", TRUE, 1, -1 },
+ { "ホモ・サピエンス", TRUE, 2, -1 }, /* katakana */
+ { "喂人类", TRUE, 2, 3 }, /* chinese */
+ { "Американские суда находятся в международных водах.", TRUE, 6, -1 }, /* russian */
+ { "Bần chỉ là một anh nghèo xác", TRUE, 7, -1 }, /* vietnamese */
+ { "ホモ・サピエンス 喂人类 katakana, chinese, english", TRUE, 7, 8 }, /* mixed */
+ { NULL, FALSE, 0, 0 }
};
/* Stop-word tests (for english only) */