You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by nw...@apache.org on 2013/05/28 19:47:50 UTC

[lucy-commits] [17/19] git commit: refs/heads/separate-clownfish-wip1 - Use Clownfish::TestHarness::TestUtils in Lucy tests

Use Clownfish::TestHarness::TestUtils in Lucy tests


Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/b03c47fc
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/b03c47fc
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/b03c47fc

Branch: refs/heads/separate-clownfish-wip1
Commit: b03c47fc52c32571d79c6d803401d1e8bcc9b8b0
Parents: bfc96f6
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Mon May 27 22:55:09 2013 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Tue May 28 17:07:28 2013 +0200

----------------------------------------------------------------------
 core/Lucy/Test/Object/TestBitVector.c   |    1 +
 core/Lucy/Test/Search/TestQueryParser.c |    1 +
 core/Lucy/Test/Search/TestSortSpec.c    |    1 +
 core/Lucy/Test/Store/TestIOChunks.c     |    1 +
 core/Lucy/Test/Store/TestIOPrimitives.c |    1 +
 core/Lucy/Test/TestUtils.c              |  108 +-------------------------
 core/Lucy/Test/TestUtils.cfh            |   49 ------------
 7 files changed, 6 insertions(+), 156 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/b03c47fc/core/Lucy/Test/Object/TestBitVector.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/Object/TestBitVector.c b/core/Lucy/Test/Object/TestBitVector.c
index cd04fbb..669ae67 100644
--- a/core/Lucy/Test/Object/TestBitVector.c
+++ b/core/Lucy/Test/Object/TestBitVector.c
@@ -19,6 +19,7 @@
 #include "Lucy/Util/ToolSet.h"
 
 #include "Clownfish/TestHarness/TestFormatter.h"
+#include "Clownfish/TestHarness/TestUtils.h"
 #include "Lucy/Test.h"
 #include "Lucy/Test/TestUtils.h"
 #include "Lucy/Test/Object/TestBitVector.h"

http://git-wip-us.apache.org/repos/asf/lucy/blob/b03c47fc/core/Lucy/Test/Search/TestQueryParser.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/Search/TestQueryParser.c b/core/Lucy/Test/Search/TestQueryParser.c
index 665b275..eef20e3 100644
--- a/core/Lucy/Test/Search/TestQueryParser.c
+++ b/core/Lucy/Test/Search/TestQueryParser.c
@@ -19,6 +19,7 @@
 #include "Lucy/Util/ToolSet.h"
 #include <string.h>
 
+#include "Clownfish/TestHarness/TestUtils.h"
 #include "Lucy/Test/Search/TestQueryParser.h"
 #include "Lucy/Test/TestUtils.h"
 #include "Lucy/Search/TermQuery.h"

http://git-wip-us.apache.org/repos/asf/lucy/blob/b03c47fc/core/Lucy/Test/Search/TestSortSpec.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/Search/TestSortSpec.c b/core/Lucy/Test/Search/TestSortSpec.c
index e889b0e..9b4dd3b 100644
--- a/core/Lucy/Test/Search/TestSortSpec.c
+++ b/core/Lucy/Test/Search/TestSortSpec.c
@@ -22,6 +22,7 @@
 #include <stdlib.h>
 
 #include "Clownfish/TestHarness/TestFormatter.h"
+#include "Clownfish/TestHarness/TestUtils.h"
 #include "Lucy/Test.h"
 #include "Lucy/Test/Search/TestSortSpec.h"
 #include "Lucy/Test/TestUtils.h"

http://git-wip-us.apache.org/repos/asf/lucy/blob/b03c47fc/core/Lucy/Test/Store/TestIOChunks.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/Store/TestIOChunks.c b/core/Lucy/Test/Store/TestIOChunks.c
index cae365c..cbf4f10 100644
--- a/core/Lucy/Test/Store/TestIOChunks.c
+++ b/core/Lucy/Test/Store/TestIOChunks.c
@@ -23,6 +23,7 @@
 #define TESTLUCY_USE_SHORT_NAMES
 #include "Lucy/Util/ToolSet.h"
 #include "Clownfish/TestHarness/TestFormatter.h"
+#include "Clownfish/TestHarness/TestUtils.h"
 #include "Lucy/Test.h"
 #include "Lucy/Test/TestUtils.h"
 #include "Lucy/Test/Store/TestIOChunks.h"

http://git-wip-us.apache.org/repos/asf/lucy/blob/b03c47fc/core/Lucy/Test/Store/TestIOPrimitives.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/Store/TestIOPrimitives.c b/core/Lucy/Test/Store/TestIOPrimitives.c
index 55e3c78..38635d8 100644
--- a/core/Lucy/Test/Store/TestIOPrimitives.c
+++ b/core/Lucy/Test/Store/TestIOPrimitives.c
@@ -23,6 +23,7 @@
 #define TESTLUCY_USE_SHORT_NAMES
 #include "Lucy/Util/ToolSet.h"
 #include "Clownfish/TestHarness/TestFormatter.h"
+#include "Clownfish/TestHarness/TestUtils.h"
 #include "Lucy/Test.h"
 #include "Lucy/Test/TestUtils.h"
 #include "Lucy/Test/Store/TestIOPrimitives.h"

http://git-wip-us.apache.org/repos/asf/lucy/blob/b03c47fc/core/Lucy/Test/TestUtils.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/TestUtils.c b/core/Lucy/Test/TestUtils.c
index 36f51f4..e345338 100644
--- a/core/Lucy/Test/TestUtils.c
+++ b/core/Lucy/Test/TestUtils.c
@@ -22,6 +22,7 @@
 #include "Lucy/Test/TestUtils.h"
 #include "Lucy/Test.h"
 #include "Clownfish/TestHarness/TestBatch.h"
+#include "Clownfish/TestHarness/TestUtils.h"
 #include "Lucy/Analysis/Analyzer.h"
 #include "Lucy/Analysis/Inversion.h"
 #include "Lucy/Analysis/Token.h"
@@ -37,88 +38,6 @@
 #include "Lucy/Store/RAMFile.h"
 #include "Lucy/Util/Freezer.h"
 
-uint64_t
-TestUtils_random_u64() {
-    uint64_t num = ((uint64_t)(rand()   & 0x7FFF) << 60)
-                   | ((uint64_t)(rand() & 0x7FFF) << 45)
-                   | ((uint64_t)(rand() & 0x7FFF) << 30)
-                   | ((uint64_t)(rand() & 0x7FFF) << 15)
-                   | ((uint64_t)(rand() & 0x7FFF) << 0);
-    return num;
-}
-
-int64_t*
-TestUtils_random_i64s(int64_t *buf, size_t count, int64_t min,
-                      int64_t limit) {
-    uint64_t  range = min < limit ? limit - min : 0;
-    int64_t *ints = buf ? buf : (int64_t*)CALLOCATE(count, sizeof(int64_t));
-    for (size_t i = 0; i < count; i++) {
-        ints[i] = min + TestUtils_random_u64() % range;
-    }
-    return ints;
-}
-
-uint64_t*
-TestUtils_random_u64s(uint64_t *buf, size_t count, uint64_t min,
-                      uint64_t limit) {
-    uint64_t  range = min < limit ? limit - min : 0;
-    uint64_t *ints = buf ? buf : (uint64_t*)CALLOCATE(count, sizeof(uint64_t));
-    for (size_t i = 0; i < count; i++) {
-        ints[i] = min + TestUtils_random_u64() % range;
-    }
-    return ints;
-}
-
-double*
-TestUtils_random_f64s(double *buf, size_t count) {
-    double *f64s = buf ? buf : (double*)CALLOCATE(count, sizeof(double));
-    for (size_t i = 0; i < count; i++) {
-        uint64_t num = TestUtils_random_u64();
-        f64s[i] = U64_TO_DOUBLE(num) / UINT64_MAX;
-    }
-    return f64s;
-}
-
-static uint32_t
-S_random_code_point(void) {
-    uint32_t code_point = 0;
-    while (1) {
-        uint8_t chance = (rand() % 9) + 1;
-        switch (chance) {
-            case 1: case 2: case 3:
-                code_point = rand() % 0x80;
-                break;
-            case 4: case 5: case 6:
-                code_point = (rand() % (0x0800  - 0x0080)) + 0x0080;
-                break;
-            case 7: case 8:
-                code_point = (rand() % (0x10000 - 0x0800)) + 0x0800;
-                break;
-            case 9: {
-                    uint64_t num = TestUtils_random_u64();
-                    code_point = (num % (0x10FFFF - 0x10000)) + 0x10000;
-                }
-        }
-        if (code_point > 0x10FFFF) {
-            continue; // Too high.
-        }
-        if (code_point > 0xD7FF && code_point < 0xE000) {
-            continue; // UTF-16 surrogate.
-        }
-        break;
-    }
-    return code_point;
-}
-
-CharBuf*
-TestUtils_random_string(size_t length) {
-    CharBuf *string = CB_new(length);
-    while (length--) {
-        CB_Cat_Char(string, S_random_code_point());
-    }
-    return string;
-}
-
 VArray*
 TestUtils_doc_set() {
     VArray *docs = VA_new(10);
@@ -134,11 +53,6 @@ TestUtils_doc_set() {
     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;
@@ -212,26 +126,6 @@ TestUtils_make_range_query(const char *field, const char *lower_term,
                           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) {

http://git-wip-us.apache.org/repos/asf/lucy/blob/b03c47fc/core/Lucy/Test/TestUtils.cfh
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/TestUtils.cfh b/core/Lucy/Test/TestUtils.cfh
index 23c55c5..189ad0a 100644
--- a/core/Lucy/Test/TestUtils.cfh
+++ b/core/Lucy/Test/TestUtils.cfh
@@ -18,49 +18,6 @@ parcel TestLucy;
 
 inert class Lucy::Test::TestUtils  {
 
-    /** Testing-only CharBuf factory which uses strlen().
-     */
-    inert incremented CharBuf*
-    get_cb(const char *utf8);
-
-    /** Return a random unsigned 64-bit integer.
-     */
-    inert uint64_t
-    random_u64();
-
-    /** Return an array of <code>count</code> random 64-bit integers where
-     * <code>min <= n < limit</code>.
-     *
-     * If <code>buf</code> is NULL, it will be allocated, otherwise it will
-     * be used.
-     */
-    inert int64_t*
-    random_i64s(int64_t *buf, size_t count, int64_t min, int64_t limit);
-
-    /** Return an array of <code>count</code> random unsigned, 64-bit integers
-     * where <code>min <= n < limit</code>.
-     *
-     * If <code>buf</code> is NULL, it will be allocated, otherwise it will
-     * be used.
-     */
-    inert uint64_t*
-    random_u64s(uint64_t *buf, size_t count, uint64_t min, uint64_t limit);
-
-    /** Return an array of <code>count</code> random double-precision floating
-     * point numbers between 0 and 1.
-     *
-     * If <code>buf</code> is NULL, it will be allocated, otherwise it will
-     * be used.
-     */
-    inert double*
-    random_f64s(double *buf, size_t count);
-
-    /** Return a string with a random (legal) sequence of code points.
-     * @param length Length of the string in code points.
-     */
-    inert incremented CharBuf*
-    random_string(size_t length);
-
     /** Return a VArray of CharBufs, each representing the content for a
      * document in the shared collection.
      */
@@ -102,12 +59,6 @@ inert class Lucy::Test::TestUtils  {
     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