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 2010/04/03 05:54:18 UTC
svn commit: r930467 - in /lucene/lucy/trunk/core/Lucy/Test: ./ Index/ Store/
Util/
Author: marvin
Date: Sat Apr 3 03:54:17 2010
New Revision: 930467
URL: http://svn.apache.org/viewvc?rev=930467&view=rev
Log:
Switch to stdint.h integer types within core/Lucy/Test.
Modified:
lucene/lucy/trunk/core/Lucy/Test/Index/TestSegment.c
lucene/lucy/trunk/core/Lucy/Test/Store/TestIOChunks.c
lucene/lucy/trunk/core/Lucy/Test/Store/TestIOPrimitives.c
lucene/lucy/trunk/core/Lucy/Test/Store/TestInStream.c
lucene/lucy/trunk/core/Lucy/Test/Store/TestRAMDirHandle.c
lucene/lucy/trunk/core/Lucy/Test/Store/TestRAMFileHandle.c
lucene/lucy/trunk/core/Lucy/Test/TestUtils.bp
lucene/lucy/trunk/core/Lucy/Test/TestUtils.c
lucene/lucy/trunk/core/Lucy/Test/Util/TestNumberUtils.c
lucene/lucy/trunk/core/Lucy/Test/Util/TestPriorityQueue.bp
lucene/lucy/trunk/core/Lucy/Test/Util/TestPriorityQueue.c
lucene/lucy/trunk/core/Lucy/Test/Util/TestStringHelper.c
Modified: lucene/lucy/trunk/core/Lucy/Test/Index/TestSegment.c
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/core/Lucy/Test/Index/TestSegment.c?rev=930467&r1=930466&r2=930467&view=diff
==============================================================================
--- lucene/lucy/trunk/core/Lucy/Test/Index/TestSegment.c (original)
+++ lucene/lucy/trunk/core/Lucy/Test/Index/TestSegment.c Sat Apr 3 03:54:17 2010
@@ -13,7 +13,7 @@ test_fields(TestBatch *batch)
ZombieCharBuf *foo = ZCB_WRAP_STR("foo",3 );
ZombieCharBuf *bar = ZCB_WRAP_STR("bar", 3);
ZombieCharBuf *baz = ZCB_WRAP_STR("baz", 3);
- i32_t field_num;
+ int32_t field_num;
field_num = Seg_Add_Field(segment, (CharBuf*)foo);
ASSERT_TRUE(batch, field_num == 1,
Modified: lucene/lucy/trunk/core/Lucy/Test/Store/TestIOChunks.c
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/core/Lucy/Test/Store/TestIOChunks.c?rev=930467&r1=930466&r2=930467&view=diff
==============================================================================
--- lucene/lucy/trunk/core/Lucy/Test/Store/TestIOChunks.c (original)
+++ lucene/lucy/trunk/core/Lucy/Test/Store/TestIOChunks.c Sat Apr 3 03:54:17 2010
@@ -57,7 +57,7 @@ test_Buf(TestBatch *batch)
OutStream *outstream = OutStream_open((Obj*)file);
InStream *instream;
size_t size = IO_STREAM_BUF_SIZE * 2 + 5;
- u32_t i;
+ uint32_t i;
char *buf;
for (i = 0; i < size; i++) {
@@ -82,9 +82,9 @@ test_Buf(TestBatch *batch)
"Requesting over limit triggers refill");
{
- i64_t expected = InStream_Length(instream) - InStream_Tell(instream);
- char *buff = InStream_Buf(instream, 100000);
- i64_t got = PTR2I64(instream->limit) - PTR2I64(buff);
+ int64_t expected = InStream_Length(instream) - InStream_Tell(instream);
+ char *buff = InStream_Buf(instream, 100000);
+ int64_t got = PTR2I64(instream->limit) - PTR2I64(buff);
ASSERT_TRUE(batch, got == expected,
"Requests greater than file size get pared down");
}
Modified: lucene/lucy/trunk/core/Lucy/Test/Store/TestIOPrimitives.c
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/core/Lucy/Test/Store/TestIOPrimitives.c?rev=930467&r1=930466&r2=930467&view=diff
==============================================================================
--- lucene/lucy/trunk/core/Lucy/Test/Store/TestIOPrimitives.c (original)
+++ lucene/lucy/trunk/core/Lucy/Test/Store/TestIOPrimitives.c Sat Apr 3 03:54:17 2010
@@ -71,7 +71,7 @@ test_i32(TestBatch *batch)
RAMFile *file = RAMFile_new(NULL, false);
OutStream *outstream = OutStream_open((Obj*)file);
InStream *instream;
- u32_t i;
+ uint32_t i;
/* Test boundaries. */
ints[0] = I32_MIN;
@@ -80,13 +80,13 @@ test_i32(TestBatch *batch)
ints[3] = I32_MAX - 1;
for (i = 0; i < 1000; i++) {
- OutStream_Write_I32(outstream, (i32_t)ints[i]);
+ OutStream_Write_I32(outstream, (int32_t)ints[i]);
}
OutStream_Close(outstream);
instream = InStream_open((Obj*)file);
for (i = 0; i < 1000; i++) {
- i32_t got = InStream_Read_I32(instream);
+ int32_t got = InStream_Read_I32(instream);
if (got != ints[i]) {
FAIL(batch, "i32 round trip failed: %ld, %ld", (long)got,
(long)ints[i]);
@@ -110,7 +110,7 @@ test_u32(TestBatch *batch)
RAMFile *file = RAMFile_new(NULL, false);
OutStream *outstream = OutStream_open((Obj*)file);
InStream *instream;
- u32_t i;
+ uint32_t i;
/* Test boundaries. */
ints[0] = 0;
@@ -119,13 +119,13 @@ test_u32(TestBatch *batch)
ints[3] = U32_MAX - 1;
for (i = 0; i < 1000; i++) {
- OutStream_Write_U32(outstream, (u32_t)ints[i]);
+ OutStream_Write_U32(outstream, (uint32_t)ints[i]);
}
OutStream_Close(outstream);
instream = InStream_open((Obj*)file);
for (i = 0; i < 1000; i++) {
- u32_t got = InStream_Read_U32(instream);
+ uint32_t got = InStream_Read_U32(instream);
if (got != ints[i]) {
FAIL(batch, "u32 round trip failed: %lu, %lu", (unsigned long)got,
(unsigned long)ints[i]);
@@ -149,7 +149,7 @@ test_i64(TestBatch *batch)
RAMFile *file = RAMFile_new(NULL, false);
OutStream *outstream = OutStream_open((Obj*)file);
InStream *instream;
- u32_t i;
+ uint32_t i;
/* Test boundaries. */
ints[0] = I64_MIN;
@@ -164,7 +164,7 @@ test_i64(TestBatch *batch)
instream = InStream_open((Obj*)file);
for (i = 0; i < 1000; i++) {
- i64_t got = InStream_Read_I64(instream);
+ int64_t got = InStream_Read_I64(instream);
if (got != ints[i]) {
FAIL(batch, "i64 round trip failed: %" I64P ", %" I64P,
got, ints[i]);
@@ -189,7 +189,7 @@ test_u64(TestBatch *batch)
RAMFile *file = RAMFile_new(NULL, false);
OutStream *outstream = OutStream_open((Obj*)file);
InStream *instream;
- u32_t i;
+ uint32_t i;
/* Test boundaries. */
ints[0] = 0;
@@ -204,7 +204,7 @@ test_u64(TestBatch *batch)
instream = InStream_open((Obj*)file);
for (i = 0; i < 1000; i++) {
- u64_t got = InStream_Read_U64(instream);
+ uint64_t got = InStream_Read_U64(instream);
if (got != ints[i]) {
FAIL(batch, "u64 round trip failed: %" U64P ", %" U64P,
got, ints[i]);
@@ -228,7 +228,7 @@ test_c32(TestBatch *batch)
RAMFile *file = RAMFile_new(NULL, false);
OutStream *outstream = OutStream_open((Obj*)file);
InStream *instream;
- u32_t i;
+ uint32_t i;
/* Test boundaries. */
ints[0] = 0;
@@ -237,13 +237,13 @@ test_c32(TestBatch *batch)
ints[3] = U32_MAX - 1;
for (i = 0; i < 1000; i++) {
- OutStream_Write_C32(outstream, (u32_t)ints[i]);
+ OutStream_Write_C32(outstream, (uint32_t)ints[i]);
}
OutStream_Close(outstream);
instream = InStream_open((Obj*)file);
for (i = 0; i < 1000; i++) {
- u32_t got = InStream_Read_C32(instream);
+ uint32_t got = InStream_Read_C32(instream);
if (got != ints[i]) {
FAIL(batch, "c32 round trip failed: %lu, %lu", (unsigned long)got,
(unsigned long)ints[i]);
@@ -270,7 +270,7 @@ test_c64(TestBatch *batch)
OutStream *raw_outstream = OutStream_open((Obj*)raw_file);
InStream *instream;
InStream *raw_instream;
- u32_t i;
+ uint32_t i;
/* Test boundaries. */
ints[0] = 0;
@@ -287,7 +287,7 @@ test_c64(TestBatch *batch)
instream = InStream_open((Obj*)file);
for (i = 0; i < 1000; i++) {
- u64_t got = InStream_Read_C64(instream);
+ uint64_t got = InStream_Read_C64(instream);
if (got != ints[i]) {
FAIL(batch, "c64 round trip failed: %" U64P ", %" U64P,
got, ints[i]);
@@ -303,7 +303,7 @@ test_c64(TestBatch *batch)
char buffer[10];
char *buf = buffer;
size_t size = InStream_Read_Raw_C64(raw_instream, buffer);
- u64_t got = NumUtil_decode_c64(&buf);
+ uint64_t got = NumUtil_decode_c64(&buf);
UNUSED_VAR(size);
if (got != ints[i]) {
FAIL(batch, "Read_Raw_C64 failed: %" U64P ", %" U64P,
@@ -332,7 +332,7 @@ test_f32(TestBatch *batch)
RAMFile *file = RAMFile_new(NULL, false);
OutStream *outstream = OutStream_open((Obj*)file);
InStream *instream;
- u32_t i;
+ uint32_t i;
/* Truncate. */
for (i = 0; i < 1000; i++) {
@@ -374,7 +374,7 @@ test_f64(TestBatch *batch)
RAMFile *file = RAMFile_new(NULL, false);
OutStream *outstream = OutStream_open((Obj*)file);
InStream *instream;
- u32_t i;
+ uint32_t i;
/* Test boundaries. */
values[0] = 0.0;
Modified: lucene/lucy/trunk/core/Lucy/Test/Store/TestInStream.c
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/core/Lucy/Test/Store/TestInStream.c?rev=930467&r1=930466&r2=930467&view=diff
==============================================================================
--- lucene/lucy/trunk/core/Lucy/Test/Store/TestInStream.c (original)
+++ lucene/lucy/trunk/core/Lucy/Test/Store/TestInStream.c Sat Apr 3 03:54:17 2010
@@ -21,7 +21,7 @@ test_refill(TestBatch *batch)
OutStream *outstream = OutStream_open((Obj*)file);
InStream *instream;
char scratch[5];
- i32_t i;
+ int32_t i;
for (i = 0; i < 1023; i++) {
OutStream_Write_U8(outstream, 'x');
@@ -78,7 +78,7 @@ test_Clone_and_Reopen(TestBatch *batch)
InStream *instream;
InStream *clone;
InStream *reopened;
- u32_t i;
+ uint32_t i;
for (i = 0; i < 26; i++) {
OutStream_Write_U8(outstream, 'a' + i);
Modified: lucene/lucy/trunk/core/Lucy/Test/Store/TestRAMDirHandle.c
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/core/Lucy/Test/Store/TestRAMDirHandle.c?rev=930467&r1=930466&r2=930467&view=diff
==============================================================================
--- lucene/lucy/trunk/core/Lucy/Test/Store/TestRAMDirHandle.c (original)
+++ lucene/lucy/trunk/core/Lucy/Test/Store/TestRAMDirHandle.c Sat Apr 3 03:54:17 2010
@@ -51,7 +51,7 @@ test_all(TestBatch *batch)
"File correctly identified by Entry_Is_Dir");
{
- u32_t refcount = RAMFolder_Get_RefCount(folder);
+ uint32_t refcount = RAMFolder_Get_RefCount(folder);
RAMDH_Close(dh);
ASSERT_INT_EQ(batch, RAMFolder_Get_RefCount(folder), refcount - 1,
"Folder reference released by Close()");
Modified: lucene/lucy/trunk/core/Lucy/Test/Store/TestRAMFileHandle.c
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/core/Lucy/Test/Store/TestRAMFileHandle.c?rev=930467&r1=930466&r2=930467&view=diff
==============================================================================
--- lucene/lucy/trunk/core/Lucy/Test/Store/TestRAMFileHandle.c (original)
+++ lucene/lucy/trunk/core/Lucy/Test/Store/TestRAMFileHandle.c Sat Apr 3 03:54:17 2010
@@ -108,7 +108,7 @@ test_Window(TestBatch *batch)
RAMFile *file = RAMFile_new(NULL, false);
RAMFileHandle *fh = RAMFH_open(NULL, FH_WRITE_ONLY, file);
FileWindow *window = FileWindow_new();
- u32_t i;
+ uint32_t i;
for (i = 0; i < 1024; i++) {
RAMFH_Write(fh, "foo ", 4);
Modified: lucene/lucy/trunk/core/Lucy/Test/TestUtils.bp
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/core/Lucy/Test/TestUtils.bp?rev=930467&r1=930466&r2=930467&view=diff
==============================================================================
--- lucene/lucy/trunk/core/Lucy/Test/TestUtils.bp (original)
+++ lucene/lucy/trunk/core/Lucy/Test/TestUtils.bp Sat Apr 3 03:54:17 2010
@@ -9,7 +9,7 @@ inert class Lucy::Test::TestUtils {
/** Return a random unsigned 64-bit integer.
*/
- inert u64_t
+ inert uint64_t
random_u64();
/** Return an array of <code>count</code> random 64-bit integers where
@@ -18,8 +18,8 @@ inert class Lucy::Test::TestUtils {
* If <code>buf</code> is NULL, it will be allocated, otherwise it will
* be used.
*/
- inert i64_t*
- random_i64s(i64_t *buf, size_t count, i64_t min, i64_t limit);
+ 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>.
@@ -27,8 +27,8 @@ inert class Lucy::Test::TestUtils {
* If <code>buf</code> is NULL, it will be allocated, otherwise it will
* be used.
*/
- inert u64_t*
- random_u64s(u64_t *buf, size_t count, u64_t min, u64_t limit);
+ 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.
Modified: lucene/lucy/trunk/core/Lucy/Test/TestUtils.c
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/core/Lucy/Test/TestUtils.c?rev=930467&r1=930466&r2=930467&view=diff
==============================================================================
--- lucene/lucy/trunk/core/Lucy/Test/TestUtils.c (original)
+++ lucene/lucy/trunk/core/Lucy/Test/TestUtils.c Sat Apr 3 03:54:17 2010
@@ -9,22 +9,22 @@
#include "Lucy/Store/RAMFile.h"
#include "Lucy/Util/Freezer.h"
-u64_t
+uint64_t
TestUtils_random_u64()
{
- u64_t num = ((u64_t)rand() << 60)
- | ((u64_t)rand() << 45)
- | ((u64_t)rand() << 30)
- | ((u64_t)rand() << 15)
- | ((u64_t)rand() << 0);
+ uint64_t num = ((uint64_t)rand() << 60)
+ | ((uint64_t)rand() << 45)
+ | ((uint64_t)rand() << 30)
+ | ((uint64_t)rand() << 15)
+ | ((uint64_t)rand() << 0);
return num;
}
-i64_t*
-TestUtils_random_i64s(i64_t *buf, size_t count, i64_t min, i64_t limit)
+int64_t*
+TestUtils_random_i64s(int64_t *buf, size_t count, int64_t min, int64_t limit)
{
- u64_t range = min < limit ? limit - min : 0;
- i64_t *ints = buf ? buf : (i64_t*)CALLOCATE(count, sizeof(i64_t));
+ uint64_t range = min < limit ? limit - min : 0;
+ int64_t *ints = buf ? buf : (int64_t*)CALLOCATE(count, sizeof(int64_t));
size_t i;
for (i = 0; i < count; i++) {
ints[i] = min + TestUtils_random_u64() % range;
@@ -32,11 +32,11 @@ TestUtils_random_i64s(i64_t *buf, size_t
return ints;
}
-u64_t*
-TestUtils_random_u64s(u64_t *buf, size_t count, u64_t min, u64_t limit)
+uint64_t*
+TestUtils_random_u64s(uint64_t *buf, size_t count, uint64_t min, uint64_t limit)
{
- u64_t range = min < limit ? limit - min : 0;
- u64_t *ints = buf ? buf : (u64_t*)CALLOCATE(count, sizeof(u64_t));
+ uint64_t range = min < limit ? limit - min : 0;
+ uint64_t *ints = buf ? buf : (uint64_t*)CALLOCATE(count, sizeof(uint64_t));
size_t i;
for (i = 0; i < count; i++) {
ints[i] = min + TestUtils_random_u64() % range;
@@ -50,7 +50,7 @@ TestUtils_random_f64s(double *buf, size_
double *f64s = buf ? buf : (double*)CALLOCATE(count, sizeof(double));
size_t i;
for (i = 0; i < count; i++) {
- u64_t num = TestUtils_random_u64();
+ uint64_t num = TestUtils_random_u64();
f64s[i] = (double)num / U64_MAX;
}
return f64s;
Modified: lucene/lucy/trunk/core/Lucy/Test/Util/TestNumberUtils.c
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/core/Lucy/Test/Util/TestNumberUtils.c?rev=930467&r1=930466&r2=930467&view=diff
==============================================================================
--- lucene/lucy/trunk/core/Lucy/Test/Util/TestNumberUtils.c (original)
+++ lucene/lucy/trunk/core/Lucy/Test/Util/TestNumberUtils.c Sat Apr 3 03:54:17 2010
@@ -11,24 +11,23 @@
static void
test_u1(TestBatch *batch)
{
- size_t count = 64;
- u64_t *ints = TestUtils_random_u64s(NULL, count, 0, 2);
- size_t amount = count / 8;
- u8_t *bits = (u8_t*)CALLOCATE(amount, sizeof(u8_t));
- size_t i;
+ size_t count = 64;
+ uint64_t *ints = TestUtils_random_u64s(NULL, count, 0, 2);
+ size_t amount = count / 8;
+ uint8_t *bits = (uint8_t*)CALLOCATE(amount, sizeof(uint8_t));
- for (i = 0; i < count; i++) {
+ for (size_t i = 0; i < count; i++) {
if (ints[i]) { NumUtil_u1set(bits, i); }
}
- for (i = 0; i < count; i++) {
+ for (size_t i = 0; i < count; i++) {
ASSERT_INT_EQ(batch, NumUtil_u1get(bits, i), (long)ints[i],
"u1 set/get");
}
- for (i = 0; i < count; i++) {
+ for (size_t i = 0; i < count; i++) {
NumUtil_u1flip(bits, i);
}
- for (i = 0; i < count; i++) {
+ for (size_t i = 0; i < count; i++) {
ASSERT_INT_EQ(batch, NumUtil_u1get(bits, i), !ints[i], "u1 flip");
}
@@ -39,15 +38,14 @@ test_u1(TestBatch *batch)
static void
test_u2(TestBatch *batch)
{
- size_t count = 32;
- u64_t *ints = TestUtils_random_u64s(NULL, count, 0, 4);
- u8_t *bits = (u8_t*)CALLOCATE((count/4), sizeof(u8_t));
- size_t i;
+ size_t count = 32;
+ uint64_t *ints = TestUtils_random_u64s(NULL, count, 0, 4);
+ uint8_t *bits = (uint8_t*)CALLOCATE((count/4), sizeof(uint8_t));
- for (i = 0; i < count; i++) {
- NumUtil_u2set(bits, i, (u8_t)ints[i]);
+ for (size_t i = 0; i < count; i++) {
+ NumUtil_u2set(bits, i, (uint8_t)ints[i]);
}
- for (i = 0; i < count; i++) {
+ for (size_t i = 0; i < count; i++) {
ASSERT_INT_EQ(batch, NumUtil_u2get(bits, i), (long)ints[i], "u2");
}
@@ -58,15 +56,14 @@ test_u2(TestBatch *batch)
static void
test_u4(TestBatch *batch)
{
- size_t count = 128;
- u64_t *ints = TestUtils_random_u64s(NULL, count, 0, 16);
- u8_t *bits = (u8_t*)CALLOCATE((count/2), sizeof(u8_t));
- size_t i;
+ size_t count = 128;
+ uint64_t *ints = TestUtils_random_u64s(NULL, count, 0, 16);
+ uint8_t *bits = (uint8_t*)CALLOCATE((count/2), sizeof(uint8_t));
- for (i = 0; i < count; i++) {
- NumUtil_u4set(bits, i, (u8_t)ints[i]);
+ for (size_t i = 0; i < count; i++) {
+ NumUtil_u4set(bits, i, (uint8_t)ints[i]);
}
- for (i = 0; i < count; i++) {
+ for (size_t i = 0; i < count; i++) {
ASSERT_INT_EQ(batch, NumUtil_u4get(bits, i), (long)ints[i], "u4");
}
@@ -77,29 +74,28 @@ test_u4(TestBatch *batch)
static void
test_c32(TestBatch *batch)
{
- u64_t mins[] = { 0, 0x4000 - 100, (u32_t)I32_MAX - 100, U32_MAX - 10 };
- u64_t limits[] = { 500, 0x4000 + 100, (u32_t)I32_MAX + 100, U32_MAX };
- u32_t set_num;
- u32_t num_sets = sizeof(mins) / sizeof(u64_t);
- size_t count = 64;
- u64_t *ints = NULL;
- size_t amount = count * C32_MAX_BYTES;
- char *encoded = (char*)CALLOCATE(amount, sizeof(char));
- char *target = encoded;
- char *limit = target + amount;
- size_t i;
+ uint64_t mins[] = { 0, 0x4000 - 100, (uint32_t)I32_MAX - 100, U32_MAX - 10 };
+ uint64_t limits[] = { 500, 0x4000 + 100, (uint32_t)I32_MAX + 100, U32_MAX };
+ uint32_t set_num;
+ uint32_t num_sets = sizeof(mins) / sizeof(uint64_t);
+ size_t count = 64;
+ uint64_t *ints = NULL;
+ size_t amount = count * C32_MAX_BYTES;
+ char *encoded = (char*)CALLOCATE(amount, sizeof(char));
+ char *target = encoded;
+ char *limit = target + amount;
for (set_num = 0; set_num < num_sets; set_num++) {
char *skip;
ints = TestUtils_random_u64s(ints, count,
mins[set_num], limits[set_num]);
target = encoded;
- for (i = 0; i < count; i++) {
- NumUtil_encode_c32((u32_t)ints[i], &target);
+ for (size_t i = 0; i < count; i++) {
+ NumUtil_encode_c32((uint32_t)ints[i], &target);
}
target = encoded;
skip = encoded;
- for (i = 0; i < count; i++) {
+ for (size_t i = 0; i < count; i++) {
ASSERT_INT_EQ(batch, NumUtil_decode_c32(&target), (long)ints[i],
"c32 %lu", (long)ints[i]);
NumUtil_skip_cint(&skip);
@@ -109,15 +105,15 @@ test_c32(TestBatch *batch)
(unsigned long)skip, (unsigned long)target);
target = encoded;
- for (i = 0; i < count; i++) {
- NumUtil_encode_padded_c32((u32_t)ints[i], &target);
+ for (size_t i = 0; i < count; i++) {
+ NumUtil_encode_padded_c32((uint32_t)ints[i], &target);
}
ASSERT_TRUE(batch, target == limit,
"padded c32 uses 5 bytes (%lu == %lu)", (unsigned long)target,
(unsigned long)limit);
target = encoded;
skip = encoded;
- for (i = 0; i < count; i++) {
+ for (size_t i = 0; i < count; i++) {
ASSERT_INT_EQ(batch, NumUtil_decode_c32(&target), (long)ints[i],
"padded c32 %lu", (long)ints[i]);
NumUtil_skip_cint(&skip);
@@ -139,30 +135,29 @@ test_c32(TestBatch *batch)
static void
test_c64(TestBatch *batch)
{
- u64_t mins[] = { 0, 0x4000 - 100, (u64_t)U32_MAX - 100, U64_MAX - 10 };
- u64_t limits[] = { 500, 0x4000 + 100, (u64_t)U32_MAX + 1000, U64_MAX };
- u32_t set_num;
- u32_t num_sets = sizeof(mins) / sizeof(u64_t);
- size_t count = 64;
- u64_t *ints = NULL;
- size_t amount = count * C64_MAX_BYTES;
- char *encoded = (char*)CALLOCATE(amount, sizeof(char));
- char *target = encoded;
- char *limit = target + amount;
- size_t i;
+ uint64_t mins[] = { 0, 0x4000 - 100, (uint64_t)U32_MAX - 100, U64_MAX - 10 };
+ uint64_t limits[] = { 500, 0x4000 + 100, (uint64_t)U32_MAX + 1000, U64_MAX };
+ uint32_t set_num;
+ uint32_t num_sets = sizeof(mins) / sizeof(uint64_t);
+ size_t count = 64;
+ uint64_t *ints = NULL;
+ size_t amount = count * C64_MAX_BYTES;
+ char *encoded = (char*)CALLOCATE(amount, sizeof(char));
+ char *target = encoded;
+ char *limit = target + amount;
for (set_num = 0; set_num < num_sets; set_num++) {
char *skip;
ints = TestUtils_random_u64s(ints, count,
mins[set_num], limits[set_num]);
target = encoded;
- for (i = 0; i < count; i++) {
+ for (size_t i = 0; i < count; i++) {
NumUtil_encode_c64(ints[i], &target);
}
target = encoded;
skip = encoded;
- for (i = 0; i < count; i++) {
- u64_t got = NumUtil_decode_c64(&target);
+ for (size_t i = 0; i < count; i++) {
+ uint64_t got = NumUtil_decode_c64(&target);
ASSERT_TRUE(batch, got == ints[i],
"c64 %" U64P " == %" U64P, got, ints[i]);
if (target > limit) { THROW(ERR, "overrun"); }
@@ -176,7 +171,7 @@ test_c64(TestBatch *batch)
NumUtil_encode_c64(U64_MAX, &target);
target = encoded;
{
- u64_t got = NumUtil_decode_c64(&target);
+ uint64_t got = NumUtil_decode_c64(&target);
ASSERT_TRUE(batch, got == U64_MAX, "c64 U64_MAX");
}
@@ -187,23 +182,22 @@ test_c64(TestBatch *batch)
static void
test_bigend_u16(TestBatch *batch)
{
- size_t count = 32;
- u64_t *ints = TestUtils_random_u64s(NULL, count, 0, U16_MAX + 1);
- size_t amount = (count + 1) * sizeof(u16_t);
- char *allocated = (char*)CALLOCATE(amount, sizeof(char));
- char *encoded = allocated + 1; /* Intentionally misaligned. */
- char *target = encoded;
- size_t i;
-
- for (i = 0; i < count; i++) {
- NumUtil_encode_bigend_u16((u16_t)ints[i], &target);
- target += sizeof(u16_t);
+ size_t count = 32;
+ uint64_t *ints = TestUtils_random_u64s(NULL, count, 0, U16_MAX + 1);
+ size_t amount = (count + 1) * sizeof(uint16_t);
+ char *allocated = (char*)CALLOCATE(amount, sizeof(char));
+ char *encoded = allocated + 1; /* Intentionally misaligned. */
+ char *target = encoded;
+
+ for (size_t i = 0; i < count; i++) {
+ NumUtil_encode_bigend_u16((uint16_t)ints[i], &target);
+ target += sizeof(uint16_t);
}
target = encoded;
- for (i = 0; i < count; i++) {
- u16_t got = NumUtil_decode_bigend_u16(target);
+ for (size_t i = 0; i < count; i++) {
+ uint16_t got = NumUtil_decode_bigend_u16(target);
ASSERT_INT_EQ(batch, got, (long)ints[i], "bigend u16");
- target += sizeof(u16_t);
+ target += sizeof(uint16_t);
}
target = encoded;
@@ -218,23 +212,22 @@ test_bigend_u16(TestBatch *batch)
static void
test_bigend_u32(TestBatch *batch)
{
- size_t count = 32;
- u64_t *ints = TestUtils_random_u64s(NULL, count, 0, U64_C(1) + U32_MAX);
- size_t amount = (count + 1) * sizeof(u32_t);
- char *allocated = (char*)CALLOCATE(amount, sizeof(char));
- char *encoded = allocated + 1; /* Intentionally misaligned. */
- char *target = encoded;
- size_t i;
-
- for (i = 0; i < count; i++) {
- NumUtil_encode_bigend_u32((u32_t)ints[i], &target);
- target += sizeof(u32_t);
+ size_t count = 32;
+ uint64_t *ints = TestUtils_random_u64s(NULL, count, 0, U64_C(1) + U32_MAX);
+ size_t amount = (count + 1) * sizeof(uint32_t);
+ char *allocated = (char*)CALLOCATE(amount, sizeof(char));
+ char *encoded = allocated + 1; /* Intentionally misaligned. */
+ char *target = encoded;
+
+ for (size_t i = 0; i < count; i++) {
+ NumUtil_encode_bigend_u32((uint32_t)ints[i], &target);
+ target += sizeof(uint32_t);
}
target = encoded;
- for (i = 0; i < count; i++) {
- u32_t got = NumUtil_decode_bigend_u32(target);
+ for (size_t i = 0; i < count; i++) {
+ uint32_t got = NumUtil_decode_bigend_u32(target);
ASSERT_INT_EQ(batch, got, (long)ints[i], "bigend u32");
- target += sizeof(u32_t);
+ target += sizeof(uint32_t);
}
target = encoded;
@@ -249,23 +242,22 @@ test_bigend_u32(TestBatch *batch)
static void
test_bigend_u64(TestBatch *batch)
{
- size_t count = 32;
- u64_t *ints = TestUtils_random_u64s(NULL, count, 0, U64_MAX);
- size_t amount = (count + 1) * sizeof(u64_t);
- char *allocated = (char*)CALLOCATE(amount, sizeof(char));
- char *encoded = allocated + 1; /* Intentionally misaligned. */
- char *target = encoded;
- size_t i;
+ size_t count = 32;
+ uint64_t *ints = TestUtils_random_u64s(NULL, count, 0, U64_MAX);
+ size_t amount = (count + 1) * sizeof(uint64_t);
+ char *allocated = (char*)CALLOCATE(amount, sizeof(char));
+ char *encoded = allocated + 1; /* Intentionally misaligned. */
+ char *target = encoded;
- for (i = 0; i < count; i++) {
+ for (size_t i = 0; i < count; i++) {
NumUtil_encode_bigend_u64(ints[i], &target);
- target += sizeof(u64_t);
+ target += sizeof(uint64_t);
}
target = encoded;
- for (i = 0; i < count; i++) {
- u64_t got = NumUtil_decode_bigend_u64(target);
+ for (size_t i = 0; i < count; i++) {
+ uint64_t got = NumUtil_decode_bigend_u64(target);
ASSERT_TRUE(batch, got == ints[i], "bigend u64");
- target += sizeof(u64_t);
+ target += sizeof(uint64_t);
}
target = encoded;
@@ -280,20 +272,19 @@ test_bigend_u64(TestBatch *batch)
static void
test_bigend_f32(TestBatch *batch)
{
- float source[] = { -1.3f, 0.0f, 100.2f };
- size_t count = 3;
- size_t amount = (count + 1) * sizeof(float);
- u8_t *allocated = (u8_t*)CALLOCATE(amount, sizeof(u8_t));
- u8_t *encoded = allocated + 1; /* Intentionally misaligned. */
- u8_t *target = encoded;
- size_t i;
+ float source[] = { -1.3f, 0.0f, 100.2f };
+ size_t count = 3;
+ size_t amount = (count + 1) * sizeof(float);
+ uint8_t *allocated = (uint8_t*)CALLOCATE(amount, sizeof(uint8_t));
+ uint8_t *encoded = allocated + 1; /* Intentionally misaligned. */
+ uint8_t *target = encoded;
- for (i = 0; i < count; i++) {
+ for (size_t i = 0; i < count; i++) {
NumUtil_encode_bigend_f32(source[i], &target);
target += sizeof(float);
}
target = encoded;
- for (i = 0; i < count; i++) {
+ for (size_t i = 0; i < count; i++) {
float got = NumUtil_decode_bigend_f32(target);
ASSERT_TRUE(batch, got == source[i], "bigend f32");
target += sizeof(float);
@@ -305,7 +296,7 @@ test_bigend_f32(TestBatch *batch)
"Truly big-endian (IEEE 754 sign bit set for negative number)");
ASSERT_INT_EQ(batch, encoded[0], 0xC0,
"IEEE 754 representation of -2.0f, byte 0");
- for (i = 1; i < sizeof(float); i++) {
+ for (size_t i = 1; i < sizeof(float); i++) {
ASSERT_INT_EQ(batch, encoded[i], 0,
"IEEE 754 representation of -2.0f, byte %d", (int)i);
}
@@ -316,20 +307,19 @@ test_bigend_f32(TestBatch *batch)
static void
test_bigend_f64(TestBatch *batch)
{
- double source[] = { -1.3, 0.0, 100.2 };
- size_t count = 3;
- size_t amount = (count + 1) * sizeof(double);
- u8_t *allocated = (u8_t*)CALLOCATE(amount, sizeof(u8_t));
- u8_t *encoded = allocated + 1; /* Intentionally misaligned. */
- u8_t *target = encoded;
- size_t i;
+ double source[] = { -1.3, 0.0, 100.2 };
+ size_t count = 3;
+ size_t amount = (count + 1) * sizeof(double);
+ uint8_t *allocated = (uint8_t*)CALLOCATE(amount, sizeof(uint8_t));
+ uint8_t *encoded = allocated + 1; /* Intentionally misaligned. */
+ uint8_t *target = encoded;
- for (i = 0; i < count; i++) {
+ for (size_t i = 0; i < count; i++) {
NumUtil_encode_bigend_f64(source[i], &target);
target += sizeof(double);
}
target = encoded;
- for (i = 0; i < count; i++) {
+ for (size_t i = 0; i < count; i++) {
double got = NumUtil_decode_bigend_f64(target);
ASSERT_TRUE(batch, got == source[i], "bigend f64");
target += sizeof(double);
@@ -341,7 +331,7 @@ test_bigend_f64(TestBatch *batch)
"Truly big-endian (IEEE 754 sign bit set for negative number)");
ASSERT_INT_EQ(batch, encoded[0], 0xC0,
"IEEE 754 representation of -2.0, byte 0");
- for (i = 1; i < sizeof(double); i++) {
+ for (size_t i = 1; i < sizeof(double); i++) {
ASSERT_INT_EQ(batch, encoded[i], 0,
"IEEE 754 representation of -2.0, byte %d", (int)i);
}
Modified: lucene/lucy/trunk/core/Lucy/Test/Util/TestPriorityQueue.bp
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/core/Lucy/Test/Util/TestPriorityQueue.bp?rev=930467&r1=930466&r2=930467&view=diff
==============================================================================
--- lucene/lucy/trunk/core/Lucy/Test/Util/TestPriorityQueue.bp (original)
+++ lucene/lucy/trunk/core/Lucy/Test/Util/TestPriorityQueue.bp Sat Apr 3 03:54:17 2010
@@ -4,7 +4,7 @@ class Lucy::Test::Util::NumPriorityQueue
extends Lucy::Util::PriorityQueue {
inert incremented NumPriorityQueue*
- new(u32_t max_size);
+ new(uint32_t max_size);
bool_t
Less_Than(NumPriorityQueue *self, Obj *a, Obj *b);
Modified: lucene/lucy/trunk/core/Lucy/Test/Util/TestPriorityQueue.c
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/core/Lucy/Test/Util/TestPriorityQueue.c?rev=930467&r1=930466&r2=930467&view=diff
==============================================================================
--- lucene/lucy/trunk/core/Lucy/Test/Util/TestPriorityQueue.c (original)
+++ lucene/lucy/trunk/core/Lucy/Test/Util/TestPriorityQueue.c Sat Apr 3 03:54:17 2010
@@ -6,7 +6,7 @@
#include "Lucy/Util/PriorityQueue.h"
NumPriorityQueue*
-NumPriQ_new(u32_t max_size)
+NumPriQ_new(uint32_t max_size)
{
NumPriorityQueue *self
= (NumPriorityQueue*)VTable_Make_Obj(NUMPRIORITYQUEUE);
@@ -23,18 +23,18 @@ NumPriQ_less_than(NumPriorityQueue *self
}
static void
-S_insert_num(NumPriorityQueue *pq, i32_t value)
+S_insert_num(NumPriorityQueue *pq, int32_t value)
{
NumPriQ_Insert(pq, (Obj*)Float64_new((double)value));
}
-static i32_t
+static int32_t
S_pop_num(NumPriorityQueue *pq)
{
Float64 *num = (Float64*)NumPriQ_Pop(pq);
- i32_t retval;
+ int32_t retval;
if (!num) { THROW(ERR, "Queue is empty"); }
- retval = (i32_t)Float64_Get_Value(num);
+ retval = (int32_t)Float64_Get_Value(num);
DECREF(num);
return retval;
}
@@ -99,7 +99,7 @@ test_Insert_and_Pop(TestBatch *batch)
static void
test_discard(TestBatch *batch)
{
- i32_t i;
+ int32_t i;
NumPriorityQueue *pq = NumPriQ_new(5);
for (i = 1; i <= 10; i++) { S_insert_num(pq, i); }
Modified: lucene/lucy/trunk/core/Lucy/Test/Util/TestStringHelper.c
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/core/Lucy/Test/Util/TestStringHelper.c?rev=930467&r1=930466&r2=930467&view=diff
==============================================================================
--- lucene/lucy/trunk/core/Lucy/Test/Util/TestStringHelper.c (original)
+++ lucene/lucy/trunk/core/Lucy/Test/Util/TestStringHelper.c Sat Apr 3 03:54:17 2010
@@ -7,7 +7,7 @@
static void
test_SKIP_and_TRAILING(TestBatch *batch)
{
- u8_t i, max;
+ uint8_t i, max;
/* Some of the upper max boundaries are skipped (e.g. 127)
* because they may not appear as initial bytes in legal UTF-8.
@@ -53,7 +53,7 @@ test_SKIP_and_TRAILING(TestBatch *batch)
static void
test_overlap(TestBatch *batch)
{
- i32_t result;
+ int32_t result;
result = StrHelp_overlap("", "", 0, 0);
ASSERT_INT_EQ(batch, result, 0, "two empty strings");
result = StrHelp_overlap("", "foo", 0, 3);
@@ -81,10 +81,10 @@ test_to_base36(TestBatch *batch)
}
static void
-S_round_trip_utf8_code_point(TestBatch *batch, u32_t code_point)
+S_round_trip_utf8_code_point(TestBatch *batch, uint32_t code_point)
{
char buffer[4];
- u32_t len = StrHelp_encode_utf8_char(code_point, buffer);
+ uint32_t len = StrHelp_encode_utf8_char(code_point, buffer);
char *start = buffer;
char *end = start + len;
ASSERT_TRUE(batch, StrHelp_utf8_valid(buffer, len), "Valid UTF-8 for %lu",
@@ -100,7 +100,7 @@ S_round_trip_utf8_code_point(TestBatch *
static void
test_utf8_round_trip(TestBatch *batch)
{
- u32_t code_points[] = {
+ uint32_t code_points[] = {
0,
0xA, /* newline */
'a',
@@ -108,8 +108,8 @@ test_utf8_round_trip(TestBatch *batch)
0x263A, /* smiley (three-byte) */
0x10FFFF, /* Max legal code point (four-byte). */
};
- u32_t num_code_points = sizeof(code_points) / sizeof(u32_t);
- u32_t i;
+ uint32_t num_code_points = sizeof(code_points) / sizeof(uint32_t);
+ uint32_t i;
for (i = 0; i < num_code_points; i++) {
S_round_trip_utf8_code_point(batch, code_points[i]);
}
@@ -136,7 +136,7 @@ test_back_utf8_char(TestBatch *batch)
{
char buffer[4];
char *buf = buffer + 1;
- u32_t len = StrHelp_encode_utf8_char(0x263A, buffer);
+ uint32_t len = StrHelp_encode_utf8_char(0x263A, buffer);
char *end = buffer + len;
ASSERT_TRUE(batch, StrHelp_back_utf8_char(end, buffer) == buffer,
"back_utf8_char");
@@ -145,9 +145,9 @@ test_back_utf8_char(TestBatch *batch)
}
static void
-S_set_buf(char *buffer, u8_t a, u8_t b, u8_t c, u8_t d)
+S_set_buf(char *buffer, uint8_t a, uint8_t b, uint8_t c, uint8_t d)
{
- u8_t *buf = (u8_t*)buffer;
+ uint8_t *buf = (uint8_t*)buffer;
buf[0] = a;
buf[1] = b;
buf[2] = c;
@@ -199,9 +199,9 @@ test_invalid_utf8(TestBatch *batch)
"Illegal 5-byte sequence fails");
{
- u32_t i;
+ uint32_t i;
for (i = 0; i <= 0x10FFFF; i++) {
- u32_t len = StrHelp_encode_utf8_char(i, buffer);
+ uint32_t len = StrHelp_encode_utf8_char(i, buffer);
if (!StrHelp_utf8_valid(buffer, len)) {
FAIL(batch, "Encoding or validity failure for %lu",
(unsigned long)i);