You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by ma...@apache.org on 2012/10/03 20:48:20 UTC
[lucy-commits] svn commit: r1393666 - in /lucy/trunk/clownfish/runtime/core/Clownfish/Test:
TestUtils.c TestUtils.cfh
Author: marvin
Date: Wed Oct 3 18:48:19 2012
New Revision: 1393666
URL: http://svn.apache.org/viewvc?rev=1393666&view=rev
Log:
Remove unused routines from TestUtils.
Remove routines which were needed by Lucy but aren't needed for
Clownfish.
Modified:
lucy/trunk/clownfish/runtime/core/Clownfish/Test/TestUtils.c
lucy/trunk/clownfish/runtime/core/Clownfish/Test/TestUtils.cfh
Modified: lucy/trunk/clownfish/runtime/core/Clownfish/Test/TestUtils.c
URL: http://svn.apache.org/viewvc/lucy/trunk/clownfish/runtime/core/Clownfish/Test/TestUtils.c?rev=1393666&r1=1393665&r2=1393666&view=diff
==============================================================================
--- lucy/trunk/clownfish/runtime/core/Clownfish/Test/TestUtils.c (original)
+++ lucy/trunk/clownfish/runtime/core/Clownfish/Test/TestUtils.c Wed Oct 3 18:48:19 2012
@@ -117,155 +117,8 @@ TestUtils_random_string(size_t length) {
return string;
}
-VArray*
-TestUtils_doc_set() {
- VArray *docs = VA_new(10);
-
- VA_Push(docs, (Obj*)TestUtils_get_cb("x"));
- VA_Push(docs, (Obj*)TestUtils_get_cb("y"));
- VA_Push(docs, (Obj*)TestUtils_get_cb("z"));
- VA_Push(docs, (Obj*)TestUtils_get_cb("x a"));
- VA_Push(docs, (Obj*)TestUtils_get_cb("x a b"));
- VA_Push(docs, (Obj*)TestUtils_get_cb("x a b c"));
- VA_Push(docs, (Obj*)TestUtils_get_cb("x foo a b c d"));
-
- return docs;
-}
-
CharBuf*
TestUtils_get_cb(const char *ptr) {
return CB_new_from_utf8(ptr, strlen(ptr));
}
-PolyQuery*
-TestUtils_make_poly_query(uint32_t boolop, ...) {
- va_list args;
- Query *child;
- PolyQuery *retval;
- VArray *children = VA_new(0);
-
- va_start(args, boolop);
- while (NULL != (child = va_arg(args, Query*))) {
- VA_Push(children, (Obj*)child);
- }
- va_end(args);
-
- retval = boolop == BOOLOP_OR
- ? (PolyQuery*)ORQuery_new(children)
- : (PolyQuery*)ANDQuery_new(children);
- DECREF(children);
- return retval;
-}
-
-TermQuery*
-TestUtils_make_term_query(const char *field, const char *term) {
- CharBuf *field_cb = (CharBuf*)ZCB_WRAP_STR(field, strlen(field));
- CharBuf *term_cb = (CharBuf*)ZCB_WRAP_STR(term, strlen(term));
- return TermQuery_new((CharBuf*)field_cb, (Obj*)term_cb);
-}
-
-PhraseQuery*
-TestUtils_make_phrase_query(const char *field, ...) {
- CharBuf *field_cb = (CharBuf*)ZCB_WRAP_STR(field, strlen(field));
- va_list args;
- VArray *terms = VA_new(0);
- PhraseQuery *query;
- char *term_str;
-
- va_start(args, field);
- while (NULL != (term_str = va_arg(args, char*))) {
- VA_Push(terms, (Obj*)TestUtils_get_cb(term_str));
- }
- va_end(args);
-
- query = PhraseQuery_new(field_cb, terms);
- DECREF(terms);
- return query;
-}
-
-LeafQuery*
-TestUtils_make_leaf_query(const char *field, const char *term) {
- CharBuf *term_cb = (CharBuf*)ZCB_WRAP_STR(term, strlen(term));
- CharBuf *field_cb = field
- ? (CharBuf*)ZCB_WRAP_STR(field, strlen(field))
- : NULL;
- return LeafQuery_new(field_cb, term_cb);
-}
-
-NOTQuery*
-TestUtils_make_not_query(Query* negated_query) {
- NOTQuery *not_query = NOTQuery_new(negated_query);
- DECREF(negated_query);
- return not_query;
-}
-
-RangeQuery*
-TestUtils_make_range_query(const char *field, const char *lower_term,
- const char *upper_term, bool_t include_lower,
- bool_t include_upper) {
- CharBuf *f = (CharBuf*)ZCB_WRAP_STR(field, strlen(field));
- CharBuf *lterm = (CharBuf*)ZCB_WRAP_STR(lower_term, strlen(lower_term));
- CharBuf *uterm = (CharBuf*)ZCB_WRAP_STR(upper_term, strlen(upper_term));
- return RangeQuery_new(f, (Obj*)lterm, (Obj*)uterm, include_lower,
- include_upper);
-}
-
-Obj*
-TestUtils_freeze_thaw(Obj *object) {
- if (object) {
- RAMFile *ram_file = RAMFile_new(NULL, false);
- OutStream *outstream = OutStream_open((Obj*)ram_file);
- FREEZE(object, outstream);
- OutStream_Close(outstream);
- DECREF(outstream);
-
- InStream *instream = InStream_open((Obj*)ram_file);
- Obj *retval = THAW(instream);
- DECREF(instream);
- DECREF(ram_file);
- return retval;
- }
- else {
- return NULL;
- }
-}
-
-void
-TestUtils_test_analyzer(TestBatch *batch, Analyzer *analyzer, CharBuf *source,
- VArray *expected, const char *message) {
- Token *seed = Token_new((char*)CB_Get_Ptr8(source), CB_Get_Size(source),
- 0, 0, 1.0f, 1);
- Inversion *starter = Inversion_new(seed);
- Inversion *transformed = Analyzer_Transform(analyzer, starter);
- VArray *got = VA_new(1);
- Token *token;
- while (NULL != (token = Inversion_Next(transformed))) {
- CharBuf *token_text
- = CB_new_from_utf8(Token_Get_Text(token), Token_Get_Len(token));
- VA_Push(got, (Obj*)token_text);
- }
- TEST_TRUE(batch, VA_Equals(expected, (Obj*)got),
- "Transform(): %s", message);
- DECREF(transformed);
-
- transformed = Analyzer_Transform_Text(analyzer, source);
- VA_Clear(got);
- while (NULL != (token = Inversion_Next(transformed))) {
- CharBuf *token_text
- = CB_new_from_utf8(Token_Get_Text(token), Token_Get_Len(token));
- VA_Push(got, (Obj*)token_text);
- }
- TEST_TRUE(batch, VA_Equals(expected, (Obj*)got),
- "Transform_Text(): %s", message);
- DECREF(transformed);
-
- DECREF(got);
- got = Analyzer_Split(analyzer, source);
- TEST_TRUE(batch, VA_Equals(expected, (Obj*)got), "Split(): %s", message);
-
- DECREF(got);
- DECREF(starter);
- DECREF(seed);
-}
-
-
Modified: lucy/trunk/clownfish/runtime/core/Clownfish/Test/TestUtils.cfh
URL: http://svn.apache.org/viewvc/lucy/trunk/clownfish/runtime/core/Clownfish/Test/TestUtils.cfh?rev=1393666&r1=1393665&r2=1393666&view=diff
==============================================================================
--- lucy/trunk/clownfish/runtime/core/Clownfish/Test/TestUtils.cfh (original)
+++ lucy/trunk/clownfish/runtime/core/Clownfish/Test/TestUtils.cfh Wed Oct 3 18:48:19 2012
@@ -60,70 +60,5 @@ inert class Lucy::Test::TestUtils {
*/
inert incremented CharBuf*
random_string(size_t length);
-
- /** Return a VArray of CharBufs, each representing the content for a
- * document in the shared collection.
- */
- inert incremented VArray*
- doc_set();
-
- /** Testing-only TermQuery factory.
- */
- inert incremented TermQuery*
- make_term_query(const char *field, const char *term);
-
- /** Testing-only PhraseQuery factory.
- */
- inert incremented PhraseQuery*
- make_phrase_query(const char *field, ...);
-
- /** Testing-only LeafQuery factory.
- */
- inert incremented LeafQuery*
- make_leaf_query(const char *field, const char *term);
-
- /** Return a new NOTQuery, decrementing the refcount for
- * <code>negated_query</code>.
- */
- inert incremented NOTQuery*
- make_not_query(Query *negated_query);
-
- inert incremented RangeQuery*
- make_range_query(const char *field, const char *lower_term = NULL,
- const char *upper_term = NULL,
- bool_t include_lower = true,
- bool_t include_upper = true);
-
- /** Return either an ORQuery or an ANDQuery depending on the value of
- * <code>boolop</code>. Takes a NULL-terminated list of Query objects.
- * Decrements the refcounts of all supplied children, under the assumption
- * that they were created solely for inclusion within the aggregate query.
- */
- inert incremented PolyQuery*
- make_poly_query(uint32_t boolop, ...);
-
- /** Return the result of round-tripping the object through FREEZE and
- * THAW.
- */
- inert incremented Obj*
- freeze_thaw(Obj *object);
-
- /** Verify an Analyzer's transform, transform_text, and split methods.
- */
- inert void
- test_analyzer(TestBatch *batch, Analyzer *analyzer, CharBuf *source,
- VArray *expected, const char *message);
}
-__C__
-
-#define LUCY_TESTUTILS_BOOLOP_OR 1
-#define LUCY_TESTUTILS_BOOLOP_AND 2
-#ifdef LUCY_USE_SHORT_NAMES
- #define BOOLOP_OR LUCY_TESTUTILS_BOOLOP_OR
- #define BOOLOP_AND LUCY_TESTUTILS_BOOLOP_AND
-#endif
-
-__END_C__
-
-