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 2011/12/10 23:35:48 UTC
[lucy-commits] svn commit: r1212907 - in /incubator/lucy/trunk: c/t/
charmonizer/src/Charmonizer/ charmonizer/src/Charmonizer/Test/
Author: marvin
Date: Sat Dec 10 22:35:48 2011
New Revision: 1212907
URL: http://svn.apache.org/viewvc?rev=1212907&view=rev
Log:
Replace TEST_INT_EQ with LONG_EQ.
LONG_EQ has a shorter name, uses the implicit TestBatch, and unlike
TEST_INT_EQ, properly communicates the arg type (both take longs).
Modified:
incubator/lucy/trunk/c/t/000-sanity-check.t.c
incubator/lucy/trunk/charmonizer/src/Charmonizer/Test.c
incubator/lucy/trunk/charmonizer/src/Charmonizer/Test.h
incubator/lucy/trunk/charmonizer/src/Charmonizer/Test/TestDirManip.c
incubator/lucy/trunk/charmonizer/src/Charmonizer/Test/TestIntegers.c
incubator/lucy/trunk/charmonizer/src/Charmonizer/Test/TestLargeFiles.c
Modified: incubator/lucy/trunk/c/t/000-sanity-check.t.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/c/t/000-sanity-check.t.c?rev=1212907&r1=1212906&r2=1212907&view=diff
==============================================================================
--- incubator/lucy/trunk/c/t/000-sanity-check.t.c (original)
+++ incubator/lucy/trunk/c/t/000-sanity-check.t.c Sat Dec 10 22:35:48 2011
@@ -8,13 +8,13 @@
#include "Charmonizer/Test.c";
static void
-S_run_tests(TestBatch *batch) {
- TEST_INT_EQ(batch, 0, 0, "sanity check");
+S_run_tests(void) {
+ LONG_EQ(0, 0, "sanity check");
}
int main(int argc, char **argv) {
- TestBatch *batch = Test_start(1);
- S_run_tests(batch);
+ Test_start(1);
+ S_run_tests();
return !Test_finish();
}
Modified: incubator/lucy/trunk/charmonizer/src/Charmonizer/Test.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/charmonizer/src/Charmonizer/Test.c?rev=1212907&r1=1212906&r2=1212907&view=diff
==============================================================================
--- incubator/lucy/trunk/charmonizer/src/Charmonizer/Test.c (original)
+++ incubator/lucy/trunk/charmonizer/src/Charmonizer/Test.c Sat Dec 10 22:35:48 2011
@@ -173,8 +173,8 @@ chaz_Test_fail(chaz_TestBatch *batch, co
}
void
-chaz_Test_test_int_eq(chaz_TestBatch *batch, long got, long expected,
- const char *message) {
+chaz_Test_long_eq(chaz_TestBatch *batch, long got, long expected,
+ const char *message) {
va_list args;
/* Increment test number. */
Modified: incubator/lucy/trunk/charmonizer/src/Charmonizer/Test.h
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/charmonizer/src/Charmonizer/Test.h?rev=1212907&r1=1212906&r2=1212907&view=diff
==============================================================================
--- incubator/lucy/trunk/charmonizer/src/Charmonizer/Test.h (original)
+++ incubator/lucy/trunk/charmonizer/src/Charmonizer/Test.h Sat Dec 10 22:35:48 2011
@@ -82,7 +82,6 @@ chaz_Test_new_batch(const char *batch_na
*/
#define CHAZ_TEST_PLAN chaz_Test_plan
#define CHAZ_TEST_TEST_STR_EQ chaz_Test_test_str_eq
-#define CHAZ_TEST_TEST_INT_EQ chaz_Test_test_int_eq
#define CHAZ_TEST_TEST_FLOAT_EQ chaz_Test_test_float_eq
/* Print a message indicating that a test was skipped and update batch.
@@ -123,9 +122,11 @@ chaz_Test_pass(chaz_TestBatch *batch, co
void
chaz_Test_fail(chaz_TestBatch *batch, const char *message);
+#define CHAZ_TEST_LONG_EQ(_got, _expected, _message) \
+ chaz_Test_long_eq(chaz_Test_current, (_got), (_expected), (_message))
void
-chaz_Test_test_int_eq(chaz_TestBatch *batch, long got, long expected,
- const char *message);
+chaz_Test_long_eq(chaz_TestBatch *batch, long got, long expected,
+ const char *message);
void
chaz_Test_test_float_eq(chaz_TestBatch *batch, double got,
@@ -146,6 +147,7 @@ extern chaz_TestBatch *chaz_Test_current
#define Test_finish chaz_Test_finish
#define OK CHAZ_TEST_OK
#define STR_EQ CHAZ_TEST_STR_EQ
+ #define LONG_EQ CHAZ_TEST_LONG_EQ
#define PASS CHAZ_TEST_PASS
#define FAIL CHAZ_TEST_FAIL
#define TestBatch_destroy_t chaz_TestBatch_destroy_t
@@ -157,10 +159,9 @@ extern chaz_TestBatch *chaz_Test_current
#define Test_plan chaz_Test_plan
#define PLAN CHAZ_TEST_PLAN
#define Test_str_eq chaz_Test_str_eq
+ #define Test_long_eq chaz_Test_long_eq
#define Test_pass chaz_Test_pass
#define Test_fail chaz_Test_fail
- #define Test_test_int_eq chaz_Test_test_int_eq
- #define TEST_INT_EQ CHAZ_TEST_TEST_INT_EQ
#define Test_test_float_eq chaz_Test_test_float_eq
#define TEST_FLOAT_EQ CHAZ_TEST_TEST_FLOAT_EQ
#define Test_skip chaz_Test_skip
Modified: incubator/lucy/trunk/charmonizer/src/Charmonizer/Test/TestDirManip.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/charmonizer/src/Charmonizer/Test/TestDirManip.c?rev=1212907&r1=1212906&r2=1212907&view=diff
==============================================================================
--- incubator/lucy/trunk/charmonizer/src/Charmonizer/Test/TestDirManip.c (original)
+++ incubator/lucy/trunk/charmonizer/src/Charmonizer/Test/TestDirManip.c Sat Dec 10 22:35:48 2011
@@ -38,17 +38,16 @@
static void
S_run_tests(TestBatch *batch) {
- TEST_INT_EQ(batch, 0, makedir("_chaz_test_dir", 0777), "makedir");
- TEST_INT_EQ(batch, 0, makedir("_chaz_test_dir" DIR_SEP "deep", 0777),
- "makedir with DIR_SEP");
- TEST_INT_EQ(batch, 0, rmdir("_chaz_test_dir" DIR_SEP "deep"),
- "rmdir with DIR_SEP");
- TEST_INT_EQ(batch, 0, rmdir("_chaz_test_dir"), "rmdir");
+ LONG_EQ(0, makedir("_chaz_test_dir", 0777), "makedir");
+ LONG_EQ(0, makedir("_chaz_test_dir" DIR_SEP "deep", 0777),
+ "makedir with DIR_SEP");
+ LONG_EQ(0, rmdir("_chaz_test_dir" DIR_SEP "deep"), "rmdir with DIR_SEP");
+ LONG_EQ(0, rmdir("_chaz_test_dir"), "rmdir");
#ifdef CHY_HAS_DIRENT_D_NAMLEN
{
struct dirent entry;
entry.d_namlen = 5;
- TEST_INT_EQ(batch, 5, entry.d_namlen, "d_namlen");
+ LONG_EQ(5, entry.d_namlen, "d_namlen");
}
#else
SKIP(batch, "no d_namlen member on this platform");
@@ -57,7 +56,7 @@ S_run_tests(TestBatch *batch) {
{
struct dirent entry;
entry.d_type = 5;
- TEST_INT_EQ(batch, 5, entry.d_type, "d_type");
+ LONG_EQ(5, entry.d_type, "d_type");
}
#else
SKIP(batch, "no d_type member on this platform");
Modified: incubator/lucy/trunk/charmonizer/src/Charmonizer/Test/TestIntegers.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/charmonizer/src/Charmonizer/Test/TestIntegers.c?rev=1212907&r1=1212906&r2=1212907&view=diff
==============================================================================
--- incubator/lucy/trunk/charmonizer/src/Charmonizer/Test/TestIntegers.c (original)
+++ incubator/lucy/trunk/charmonizer/src/Charmonizer/Test/TestIntegers.c Sat Dec 10 22:35:48 2011
@@ -40,19 +40,19 @@ S_run_tests(TestBatch *batch) {
#endif
}
- TEST_INT_EQ(batch, SIZEOF_CHAR, sizeof(char), "SIZEOF_CHAR");
- TEST_INT_EQ(batch, SIZEOF_SHORT, sizeof(short), "SIZEOF_SHORT");
- TEST_INT_EQ(batch, SIZEOF_INT, sizeof(int), "SIZEOF_INT");
- TEST_INT_EQ(batch, SIZEOF_LONG, sizeof(long), "SIZEOF_LONG");
- TEST_INT_EQ(batch, SIZEOF_PTR, sizeof(void*), "SIZEOF_PTR");
+ LONG_EQ(SIZEOF_CHAR, sizeof(char), "SIZEOF_CHAR");
+ LONG_EQ(SIZEOF_SHORT, sizeof(short), "SIZEOF_SHORT");
+ LONG_EQ(SIZEOF_INT, sizeof(int), "SIZEOF_INT");
+ LONG_EQ(SIZEOF_LONG, sizeof(long), "SIZEOF_LONG");
+ LONG_EQ(SIZEOF_PTR, sizeof(void*), "SIZEOF_PTR");
#ifdef HAS_LONG_LONG
- TEST_INT_EQ(batch, SIZEOF_LONG_LONG, sizeof(long long),
- "HAS_LONG_LONG and SIZEOF_LONG_LONG");
+ LONG_EQ(SIZEOF_LONG_LONG, sizeof(long long),
+ "HAS_LONG_LONG and SIZEOF_LONG_LONG");
#endif
#ifdef HAS_INTTYPES_H
- TEST_INT_EQ(batch, sizeof(int8_t), 1, "HAS_INTTYPES_H");
+ LONG_EQ(sizeof(int8_t), 1, "HAS_INTTYPES_H");
#else
SKIP(batch, "No inttypes.h");
#endif
@@ -66,26 +66,26 @@ S_run_tests(TestBatch *batch) {
{
int8_t foo = -100;
uint8_t bar = 200;
- TEST_INT_EQ(batch, foo, -100, "int8_t is signed");
- TEST_INT_EQ(batch, bar, 200, "uint8_t is unsigned");
- TEST_INT_EQ(batch, sizeof(int8_t), 1, "i8_t is 1 byte");
- TEST_INT_EQ(batch, sizeof(uint8_t), 1, "u8_t is 1 byte");
- TEST_INT_EQ(batch, I8_MAX, 127, "I8_MAX");
- TEST_INT_EQ(batch, I8_MIN, -128, "I8_MIN");
- TEST_INT_EQ(batch, U8_MAX, 255, "U8_MAX");
+ LONG_EQ(foo, -100, "int8_t is signed");
+ LONG_EQ(bar, 200, "uint8_t is unsigned");
+ LONG_EQ(sizeof(int8_t), 1, "i8_t is 1 byte");
+ LONG_EQ(sizeof(uint8_t), 1, "u8_t is 1 byte");
+ LONG_EQ(I8_MAX, 127, "I8_MAX");
+ LONG_EQ(I8_MIN, -128, "I8_MIN");
+ LONG_EQ(U8_MAX, 255, "U8_MAX");
}
#endif
#ifdef HAS_I16_T
{
int16_t foo = -100;
uint16_t bar = 30000;
- TEST_INT_EQ(batch, foo, -100, "int16_t is signed");
- TEST_INT_EQ(batch, bar, 30000, "uint16_t is unsigned");
- TEST_INT_EQ(batch, sizeof(int16_t), 2, "int16_t is 2 bytes");
- TEST_INT_EQ(batch, sizeof(uint16_t), 2, "uint16_t is 2 bytes");
- TEST_INT_EQ(batch, I16_MAX, 32767, "I16_MAX");
- TEST_INT_EQ(batch, I16_MIN, -32768, "I16_MIN");
- TEST_INT_EQ(batch, U16_MAX, 65535, "U16_MAX");
+ LONG_EQ(foo, -100, "int16_t is signed");
+ LONG_EQ(bar, 30000, "uint16_t is unsigned");
+ LONG_EQ(sizeof(int16_t), 2, "int16_t is 2 bytes");
+ LONG_EQ(sizeof(uint16_t), 2, "uint16_t is 2 bytes");
+ LONG_EQ(I16_MAX, 32767, "I16_MAX");
+ LONG_EQ(I16_MIN, -32768, "I16_MIN");
+ LONG_EQ(U16_MAX, 65535, "U16_MAX");
}
#endif
#ifdef HAS_I32_T
Modified: incubator/lucy/trunk/charmonizer/src/Charmonizer/Test/TestLargeFiles.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/charmonizer/src/Charmonizer/Test/TestLargeFiles.c?rev=1212907&r1=1212906&r2=1212907&view=diff
==============================================================================
--- incubator/lucy/trunk/charmonizer/src/Charmonizer/Test/TestLargeFiles.c (original)
+++ incubator/lucy/trunk/charmonizer/src/Charmonizer/Test/TestLargeFiles.c Sat Dec 10 22:35:48 2011
@@ -79,7 +79,7 @@ S_run_tests(TestBatch *batch) {
off64_t gb4_plus = ((off64_t)0x7FFFFFFF << 1) + 100;
off64_t gb2_plus = (off64_t)0x7FFFFFFF + 200;
- TEST_INT_EQ(batch, sizeof(off64_t), 8, "off64_t type has 8 bytes");
+ LONG_EQ(sizeof(off64_t), 8, "off64_t type has 8 bytes");
#ifndef HAS_64BIT_STDIO
SKIP_REMAINING(batch, "No stdio large file support");
@@ -105,28 +105,28 @@ S_run_tests(TestBatch *batch) {
}
check_val = fseeko64(fh, gb4_plus, SEEK_SET);
- TEST_INT_EQ(batch, check_val, 0, "fseeko64 above 4 GB");
+ LONG_EQ(check_val, 0, "fseeko64 above 4 GB");
offset = ftello64(fh);
OK((offset == gb4_plus), "ftello64 above 4 GB");
check_val = fprintf(fh, "X");
- TEST_INT_EQ(batch, check_val, 1, "print above 4 GB");
+ LONG_EQ(check_val, 1, "print above 4 GB");
check_val = fseeko64(fh, gb2_plus, SEEK_SET);
- TEST_INT_EQ(batch, check_val, 0, "fseeko64 above 2 GB");
+ LONG_EQ(check_val, 0, "fseeko64 above 2 GB");
offset = ftello64(fh);
OK((offset == gb2_plus), "ftello64 above 2 GB");
check_val = fseeko64(fh, -1, SEEK_END);
- TEST_INT_EQ(batch, check_val, 0, "seek to near end");
+ LONG_EQ(check_val, 0, "seek to near end");
check_char = fgetc(fh);
- TEST_INT_EQ(batch, check_char, 'X', "read value after multiple seeks");
+ LONG_EQ(check_char, 'X', "read value after multiple seeks");
check_val = fclose(fh);
- TEST_INT_EQ(batch, check_val, 0, "fclose succeeds after all that");
+ LONG_EQ(check_val, 0, "fclose succeeds after all that");
/* Truncate, just in case the call to remove fails. */
fh = fopen64("_charm_large_file_test", "w+");
@@ -152,7 +152,7 @@ S_run_tests(TestBatch *batch) {
OK(offset == gb4_plus, "lseek64 in place above 4 GB");
check_val = write(fd, "X", 1);
- TEST_INT_EQ(batch, check_val, 1, "write() above 4 GB");
+ LONG_EQ(check_val, 1, "write() above 4 GB");
offset = lseek64(fd, gb2_plus, SEEK_SET);
OK(offset == gb2_plus, "lseek64 above 2 GB");
@@ -164,21 +164,21 @@ S_run_tests(TestBatch *batch) {
OK(offset == gb4_plus, "seek to near end");
check_val = read(fd, &check_char, 1);
- TEST_INT_EQ(batch, check_val, 1, "read() after multiple lseek64 calls");
- TEST_INT_EQ(batch, check_char, 'X',
+ LONG_EQ(check_val, 1, "read() after multiple lseek64 calls");
+ LONG_EQ(check_char, 'X',
"read() correct data after multiple lseek64 calls");
#ifdef HAS_64BIT_PREAD
check_char = 0;
check_val = pread64(fd, &check_char, 1, gb4_plus);
- TEST_INT_EQ(batch, check_val, 1, "pread64");
- TEST_INT_EQ(batch, check_char, 'X', "pread64() correct data");
+ LONG_EQ(check_val, 1, "pread64");
+ LONG_EQ(check_char, 'X', "pread64() correct data");
#else
SKIP(batch, "no pread64");
SKIP(batch, "no pread64");
#endif
check_val = close(fd);
- TEST_INT_EQ(batch, check_val, 0, "close succeeds after all that");
+ LONG_EQ(check_val, 0, "close succeeds after all that");
#endif
/* Truncate, just in case the call to remove fails. */