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/05/02 01:50:38 UTC
[lucy-commits] svn commit: r1098445 [17/23] - in /incubator/lucy/trunk: charmonizer/
charmonizer/src/Charmonizer/ charmonizer/src/Charmonizer/Core/
charmonizer/src/Charmonizer/Probe/ charmonizer/src/Charmonizer/Test/
clownfish/lib/ clownfish/lib/Clownfish/Binding/ cl...
Modified: incubator/lucy/trunk/core/Lucy/Test/Analysis/TestAnalyzer.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Test/Analysis/TestAnalyzer.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Test/Analysis/TestAnalyzer.c (original)
+++ incubator/lucy/trunk/core/Lucy/Test/Analysis/TestAnalyzer.c Sun May 1 23:50:24 2011
@@ -23,42 +23,37 @@
#include "Lucy/Analysis/Inversion.h"
DummyAnalyzer*
-DummyAnalyzer_new()
-{
+DummyAnalyzer_new() {
DummyAnalyzer *self = (DummyAnalyzer*)VTable_Make_Obj(DUMMYANALYZER);
return DummyAnalyzer_init(self);
}
DummyAnalyzer*
-DummyAnalyzer_init(DummyAnalyzer *self)
-{
+DummyAnalyzer_init(DummyAnalyzer *self) {
return (DummyAnalyzer*)Analyzer_init((Analyzer*)self);
}
Inversion*
-DummyAnalyzer_transform(DummyAnalyzer *self, Inversion *inversion)
-{
+DummyAnalyzer_transform(DummyAnalyzer *self, Inversion *inversion) {
UNUSED_VAR(self);
return (Inversion*)INCREF(inversion);
}
static void
-test_analysis(TestBatch *batch)
-{
+test_analysis(TestBatch *batch) {
DummyAnalyzer *analyzer = DummyAnalyzer_new();
CharBuf *source = CB_newf("foo bar baz");
VArray *wanted = VA_new(1);
VA_Push(wanted, (Obj*)CB_newf("foo bar baz"));
- TestUtils_test_analyzer(batch, (Analyzer*)analyzer, source, wanted,
- "test basic analysis");
+ TestUtils_test_analyzer(batch, (Analyzer*)analyzer, source, wanted,
+ "test basic analysis");
DECREF(wanted);
DECREF(source);
DECREF(analyzer);
}
void
-TestAnalyzer_run_tests()
-{
+TestAnalyzer_run_tests() {
TestBatch *batch = TestBatch_new(3);
TestBatch_Plan(batch);
Modified: incubator/lucy/trunk/core/Lucy/Test/Analysis/TestCaseFolder.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Test/Analysis/TestCaseFolder.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Test/Analysis/TestCaseFolder.c (original)
+++ incubator/lucy/trunk/core/Lucy/Test/Analysis/TestCaseFolder.c Sun May 1 23:50:24 2011
@@ -23,8 +23,7 @@
#include "Lucy/Analysis/CaseFolder.h"
static void
-test_Dump_Load_and_Equals(TestBatch *batch)
-{
+test_Dump_Load_and_Equals(TestBatch *batch) {
CaseFolder *case_folder = CaseFolder_new();
CaseFolder *other = CaseFolder_new();
Obj *dump = (Obj*)CaseFolder_Dump(case_folder);
@@ -32,8 +31,8 @@ test_Dump_Load_and_Equals(TestBatch *bat
TEST_TRUE(batch, CaseFolder_Equals(case_folder, (Obj*)other), "Equals");
TEST_FALSE(batch, CaseFolder_Equals(case_folder, (Obj*)&EMPTY), "Not Equals");
- TEST_TRUE(batch, CaseFolder_Equals(case_folder, (Obj*)clone),
- "Dump => Load round trip");
+ TEST_TRUE(batch, CaseFolder_Equals(case_folder, (Obj*)clone),
+ "Dump => Load round trip");
DECREF(case_folder);
DECREF(other);
@@ -42,22 +41,20 @@ test_Dump_Load_and_Equals(TestBatch *bat
}
static void
-test_analysis(TestBatch *batch)
-{
+test_analysis(TestBatch *batch) {
CaseFolder *case_folder = CaseFolder_new();
CharBuf *source = CB_newf("caPiTal ofFensE");
VArray *wanted = VA_new(1);
VA_Push(wanted, (Obj*)CB_newf("capital offense"));
- TestUtils_test_analyzer(batch, (Analyzer*)case_folder, source, wanted,
- "lowercase plain text");
+ TestUtils_test_analyzer(batch, (Analyzer*)case_folder, source, wanted,
+ "lowercase plain text");
DECREF(wanted);
DECREF(source);
DECREF(case_folder);
}
void
-TestCaseFolder_run_tests()
-{
+TestCaseFolder_run_tests() {
TestBatch *batch = TestBatch_new(6);
TestBatch_Plan(batch);
Modified: incubator/lucy/trunk/core/Lucy/Test/Analysis/TestPolyAnalyzer.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Test/Analysis/TestPolyAnalyzer.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Test/Analysis/TestPolyAnalyzer.c (original)
+++ incubator/lucy/trunk/core/Lucy/Test/Analysis/TestPolyAnalyzer.c Sun May 1 23:50:24 2011
@@ -27,8 +27,7 @@
#include "Lucy/Analysis/RegexTokenizer.h"
static void
-test_Dump_Load_and_Equals(TestBatch *batch)
-{
+test_Dump_Load_and_Equals(TestBatch *batch) {
CharBuf *EN = (CharBuf*)ZCB_WRAP_STR("en", 2);
CharBuf *ES = (CharBuf*)ZCB_WRAP_STR("es", 2);
PolyAnalyzer *analyzer = PolyAnalyzer_new(EN, NULL);
@@ -36,15 +35,15 @@ test_Dump_Load_and_Equals(TestBatch *bat
Obj *dump = (Obj*)PolyAnalyzer_Dump(analyzer);
Obj *other_dump = (Obj*)PolyAnalyzer_Dump(other);
PolyAnalyzer *clone = (PolyAnalyzer*)PolyAnalyzer_Load(other, dump);
- PolyAnalyzer *other_clone
+ PolyAnalyzer *other_clone
= (PolyAnalyzer*)PolyAnalyzer_Load(other, other_dump);
- TEST_FALSE(batch, PolyAnalyzer_Equals(analyzer,
- (Obj*)other), "Equals() false with different language");
- TEST_TRUE(batch, PolyAnalyzer_Equals(analyzer,
- (Obj*)clone), "Dump => Load round trip");
- TEST_TRUE(batch, PolyAnalyzer_Equals(other,
- (Obj*)other_clone), "Dump => Load round trip");
+ TEST_FALSE(batch, PolyAnalyzer_Equals(analyzer, (Obj*)other),
+ "Equals() false with different language");
+ TEST_TRUE(batch, PolyAnalyzer_Equals(analyzer, (Obj*)clone),
+ "Dump => Load round trip");
+ TEST_TRUE(batch, PolyAnalyzer_Equals(other, (Obj*)other_clone),
+ "Dump => Load round trip");
DECREF(analyzer);
DECREF(dump);
@@ -55,8 +54,7 @@ test_Dump_Load_and_Equals(TestBatch *bat
}
static void
-test_analysis(TestBatch *batch)
-{
+test_analysis(TestBatch *batch) {
CharBuf *EN = (CharBuf*)ZCB_WRAP_STR("en", 2);
CharBuf *source_text = CB_newf("Eats, shoots and leaves.");
CaseFolder *case_folder = CaseFolder_new();
@@ -70,7 +68,7 @@ test_analysis(TestBatch *batch)
VArray *expected = VA_new(1);
VA_Push(expected, INCREF(source_text));
TestUtils_test_analyzer(batch, (Analyzer*)polyanalyzer, source_text,
- expected, "No sub analyzers");
+ expected, "No sub analyzers");
DECREF(expected);
DECREF(polyanalyzer);
DECREF(analyzers);
@@ -78,12 +76,12 @@ test_analysis(TestBatch *batch)
{
VArray *analyzers = VA_new(0);
- VA_Push(analyzers, INCREF(case_folder));
+ VA_Push(analyzers, INCREF(case_folder));
PolyAnalyzer *polyanalyzer = PolyAnalyzer_new(NULL, analyzers);
VArray *expected = VA_new(1);
VA_Push(expected, (Obj*)CB_newf("eats, shoots and leaves."));
TestUtils_test_analyzer(batch, (Analyzer*)polyanalyzer, source_text,
- expected, "With CaseFolder");
+ expected, "With CaseFolder");
DECREF(expected);
DECREF(polyanalyzer);
DECREF(analyzers);
@@ -91,8 +89,8 @@ test_analysis(TestBatch *batch)
{
VArray *analyzers = VA_new(0);
- VA_Push(analyzers, INCREF(case_folder));
- VA_Push(analyzers, INCREF(tokenizer));
+ VA_Push(analyzers, INCREF(case_folder));
+ VA_Push(analyzers, INCREF(tokenizer));
PolyAnalyzer *polyanalyzer = PolyAnalyzer_new(NULL, analyzers);
VArray *expected = VA_new(1);
VA_Push(expected, (Obj*)CB_newf("eats"));
@@ -100,7 +98,7 @@ test_analysis(TestBatch *batch)
VA_Push(expected, (Obj*)CB_newf("and"));
VA_Push(expected, (Obj*)CB_newf("leaves"));
TestUtils_test_analyzer(batch, (Analyzer*)polyanalyzer, source_text,
- expected, "With RegexTokenizer");
+ expected, "With RegexTokenizer");
DECREF(expected);
DECREF(polyanalyzer);
DECREF(analyzers);
@@ -108,16 +106,16 @@ test_analysis(TestBatch *batch)
{
VArray *analyzers = VA_new(0);
- VA_Push(analyzers, INCREF(case_folder));
- VA_Push(analyzers, INCREF(tokenizer));
- VA_Push(analyzers, INCREF(stopfilter));
+ VA_Push(analyzers, INCREF(case_folder));
+ VA_Push(analyzers, INCREF(tokenizer));
+ VA_Push(analyzers, INCREF(stopfilter));
PolyAnalyzer *polyanalyzer = PolyAnalyzer_new(NULL, analyzers);
VArray *expected = VA_new(1);
VA_Push(expected, (Obj*)CB_newf("eats"));
VA_Push(expected, (Obj*)CB_newf("shoots"));
VA_Push(expected, (Obj*)CB_newf("leaves"));
TestUtils_test_analyzer(batch, (Analyzer*)polyanalyzer, source_text,
- expected, "With SnowballStopFilter");
+ expected, "With SnowballStopFilter");
DECREF(expected);
DECREF(polyanalyzer);
DECREF(analyzers);
@@ -125,17 +123,17 @@ test_analysis(TestBatch *batch)
{
VArray *analyzers = VA_new(0);
- VA_Push(analyzers, INCREF(case_folder));
- VA_Push(analyzers, INCREF(tokenizer));
- VA_Push(analyzers, INCREF(stopfilter));
- VA_Push(analyzers, INCREF(stemmer));
+ VA_Push(analyzers, INCREF(case_folder));
+ VA_Push(analyzers, INCREF(tokenizer));
+ VA_Push(analyzers, INCREF(stopfilter));
+ VA_Push(analyzers, INCREF(stemmer));
PolyAnalyzer *polyanalyzer = PolyAnalyzer_new(NULL, analyzers);
VArray *expected = VA_new(1);
VA_Push(expected, (Obj*)CB_newf("eat"));
VA_Push(expected, (Obj*)CB_newf("shoot"));
VA_Push(expected, (Obj*)CB_newf("leav"));
TestUtils_test_analyzer(batch, (Analyzer*)polyanalyzer, source_text,
- expected, "With SnowballStemmer");
+ expected, "With SnowballStemmer");
DECREF(expected);
DECREF(polyanalyzer);
DECREF(analyzers);
@@ -149,19 +147,17 @@ test_analysis(TestBatch *batch)
}
static void
-test_Get_Analyzers(TestBatch *batch)
-{
+test_Get_Analyzers(TestBatch *batch) {
VArray *analyzers = VA_new(0);
PolyAnalyzer *analyzer = PolyAnalyzer_new(NULL, analyzers);
TEST_TRUE(batch, PolyAnalyzer_Get_Analyzers(analyzer) == analyzers,
- "Get_Analyzers()");
+ "Get_Analyzers()");
DECREF(analyzer);
DECREF(analyzers);
}
void
-TestPolyAnalyzer_run_tests()
-{
+TestPolyAnalyzer_run_tests() {
TestBatch *batch = TestBatch_new(19);
TestBatch_Plan(batch);
Modified: incubator/lucy/trunk/core/Lucy/Test/Analysis/TestRegexTokenizer.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Test/Analysis/TestRegexTokenizer.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Test/Analysis/TestRegexTokenizer.c (original)
+++ incubator/lucy/trunk/core/Lucy/Test/Analysis/TestRegexTokenizer.c Sun May 1 23:50:24 2011
@@ -23,27 +23,29 @@
static void
-test_Dump_Load_and_Equals(TestBatch *batch)
-{
- ZombieCharBuf *word_char_pattern = ZCB_WRAP_STR("\\w+", 3);
+test_Dump_Load_and_Equals(TestBatch *batch) {
+ ZombieCharBuf *word_char_pattern = ZCB_WRAP_STR("\\w+", 3);
ZombieCharBuf *whitespace_pattern = ZCB_WRAP_STR("\\S+", 3);
- RegexTokenizer *word_char_tokenizer =
- RegexTokenizer_new((CharBuf*)word_char_pattern);
- RegexTokenizer *whitespace_tokenizer =
- RegexTokenizer_new((CharBuf*)whitespace_pattern);
+ RegexTokenizer *word_char_tokenizer
+ = RegexTokenizer_new((CharBuf*)word_char_pattern);
+ RegexTokenizer *whitespace_tokenizer
+ = RegexTokenizer_new((CharBuf*)whitespace_pattern);
Obj *word_char_dump = RegexTokenizer_Dump(word_char_tokenizer);
Obj *whitespace_dump = RegexTokenizer_Dump(whitespace_tokenizer);
- RegexTokenizer *word_char_clone
+ RegexTokenizer *word_char_clone
= RegexTokenizer_Load(whitespace_tokenizer, word_char_dump);
- RegexTokenizer *whitespace_clone
+ RegexTokenizer *whitespace_clone
= RegexTokenizer_Load(whitespace_tokenizer, whitespace_dump);
- TEST_FALSE(batch, RegexTokenizer_Equals(word_char_tokenizer,
- (Obj*)whitespace_tokenizer), "Equals() false with different pattern");
- TEST_TRUE(batch, RegexTokenizer_Equals(word_char_tokenizer,
- (Obj*)word_char_clone), "Dump => Load round trip");
- TEST_TRUE(batch, RegexTokenizer_Equals(whitespace_tokenizer,
- (Obj*)whitespace_clone), "Dump => Load round trip");
+ TEST_FALSE(batch,
+ RegexTokenizer_Equals(word_char_tokenizer, (Obj*)whitespace_tokenizer),
+ "Equals() false with different pattern");
+ TEST_TRUE(batch,
+ RegexTokenizer_Equals(word_char_tokenizer, (Obj*)word_char_clone),
+ "Dump => Load round trip");
+ TEST_TRUE(batch,
+ RegexTokenizer_Equals(whitespace_tokenizer, (Obj*)whitespace_clone),
+ "Dump => Load round trip");
DECREF(word_char_tokenizer);
DECREF(word_char_dump);
@@ -54,8 +56,7 @@ test_Dump_Load_and_Equals(TestBatch *bat
}
void
-TestRegexTokenizer_run_tests()
-{
+TestRegexTokenizer_run_tests() {
TestBatch *batch = TestBatch_new(3);
TestBatch_Plan(batch);
Modified: incubator/lucy/trunk/core/Lucy/Test/Analysis/TestSnowballStemmer.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Test/Analysis/TestSnowballStemmer.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Test/Analysis/TestSnowballStemmer.c (original)
+++ incubator/lucy/trunk/core/Lucy/Test/Analysis/TestSnowballStemmer.c Sun May 1 23:50:24 2011
@@ -24,10 +24,9 @@
#include "Lucy/Util/Json.h"
static void
-test_Dump_Load_and_Equals(TestBatch *batch)
-{
- CharBuf *EN = (CharBuf*)ZCB_WRAP_STR("en", 2);
- CharBuf *ES = (CharBuf*)ZCB_WRAP_STR("es", 2);
+test_Dump_Load_and_Equals(TestBatch *batch) {
+ CharBuf *EN = (CharBuf*)ZCB_WRAP_STR("en", 2);
+ CharBuf *ES = (CharBuf*)ZCB_WRAP_STR("es", 2);
SnowballStemmer *stemmer = SnowStemmer_new(EN);
SnowballStemmer *other = SnowStemmer_new(ES);
Obj *dump = (Obj*)SnowStemmer_Dump(stemmer);
@@ -35,12 +34,15 @@ test_Dump_Load_and_Equals(TestBatch *bat
SnowballStemmer *clone = (SnowballStemmer*)SnowStemmer_Load(other, dump);
SnowballStemmer *other_clone = (SnowballStemmer*)SnowStemmer_Load(other, other_dump);
- TEST_FALSE(batch, SnowStemmer_Equals(stemmer,
- (Obj*)other), "Equals() false with different language");
- TEST_TRUE(batch, SnowStemmer_Equals(stemmer,
- (Obj*)clone), "Dump => Load round trip");
- TEST_TRUE(batch, SnowStemmer_Equals(other,
- (Obj*)other_clone), "Dump => Load round trip");
+ TEST_FALSE(batch,
+ SnowStemmer_Equals(stemmer, (Obj*)other),
+ "Equals() false with different language");
+ TEST_TRUE(batch,
+ SnowStemmer_Equals(stemmer, (Obj*)clone),
+ "Dump => Load round trip");
+ TEST_TRUE(batch,
+ SnowStemmer_Equals(other, (Obj*)other_clone),
+ "Dump => Load round trip");
DECREF(stemmer);
DECREF(dump);
@@ -51,13 +53,12 @@ test_Dump_Load_and_Equals(TestBatch *bat
}
static void
-test_stemming(TestBatch *batch)
-{
+test_stemming(TestBatch *batch) {
CharBuf *path = CB_newf("modules");
FSFolder *modules_folder = FSFolder_new(path);
if (!FSFolder_Check(modules_folder)) {
DECREF(modules_folder);
- CB_setf(path, "../modules");
+ CB_setf(path, "../modules");
modules_folder = FSFolder_new(path);
if (!FSFolder_Check(modules_folder)) {
THROW(ERR, "Can't open modules folder");
@@ -71,19 +72,19 @@ test_stemming(TestBatch *batch)
Hash *lang_data;
Hash_Iterate(tests);
while (Hash_Next(tests, (Obj**)&iso, (Obj**)&lang_data)) {
- VArray *words = (VArray*)Hash_Fetch_Str(lang_data, "words", 5);
- VArray *stems = (VArray*)Hash_Fetch_Str(lang_data, "stems", 5);
+ VArray *words = (VArray*)Hash_Fetch_Str(lang_data, "words", 5);
+ VArray *stems = (VArray*)Hash_Fetch_Str(lang_data, "stems", 5);
SnowballStemmer *stemmer = SnowStemmer_new(iso);
for (uint32_t i = 0, max = VA_Get_Size(words); i < max; i++) {
CharBuf *word = (CharBuf*)VA_Fetch(words, i);
VArray *got = SnowStemmer_Split(stemmer, word);
CharBuf *stem = (CharBuf*)VA_Fetch(got, 0);
TEST_TRUE(batch,
- stem
- && CB_Is_A(stem, CHARBUF)
- && CB_Equals(stem, VA_Fetch(stems, i)),
- "Stem %s: %s", CB_Get_Ptr8(iso), CB_Get_Ptr8(word)
- );
+ stem
+ && CB_Is_A(stem, CHARBUF)
+ && CB_Equals(stem, VA_Fetch(stems, i)),
+ "Stem %s: %s", CB_Get_Ptr8(iso), CB_Get_Ptr8(word)
+ );
DECREF(got);
}
DECREF(stemmer);
@@ -95,8 +96,7 @@ test_stemming(TestBatch *batch)
}
void
-TestSnowStemmer_run_tests()
-{
+TestSnowStemmer_run_tests() {
TestBatch *batch = TestBatch_new(153);
TestBatch_Plan(batch);
Modified: incubator/lucy/trunk/core/Lucy/Test/Analysis/TestSnowballStopFilter.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Test/Analysis/TestSnowballStopFilter.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Test/Analysis/TestSnowballStopFilter.c (original)
+++ incubator/lucy/trunk/core/Lucy/Test/Analysis/TestSnowballStopFilter.c Sun May 1 23:50:24 2011
@@ -22,9 +22,8 @@
#include "Lucy/Test/Analysis/TestSnowballStopFilter.h"
#include "Lucy/Analysis/SnowballStopFilter.h"
-static SnowballStopFilter*
-S_make_stopfilter(void *unused, ...)
-{
+static SnowballStopFilter*
+S_make_stopfilter(void *unused, ...) {
va_list args;
SnowballStopFilter *self = (SnowballStopFilter*)VTable_Make_Obj(SNOWBALLSTOPFILTER);
Hash *stoplist = Hash_new(0);
@@ -42,22 +41,25 @@ S_make_stopfilter(void *unused, ...)
}
static void
-test_Dump_Load_and_Equals(TestBatch *batch)
-{
- SnowballStopFilter *stopfilter = S_make_stopfilter(NULL, "foo", "bar",
- "baz", NULL);
- SnowballStopFilter *other = S_make_stopfilter(NULL, "foo", "bar", NULL);
+test_Dump_Load_and_Equals(TestBatch *batch) {
+ SnowballStopFilter *stopfilter =
+ S_make_stopfilter(NULL, "foo", "bar", "baz", NULL);
+ SnowballStopFilter *other =
+ S_make_stopfilter(NULL, "foo", "bar", NULL);
Obj *dump = SnowStop_Dump(stopfilter);
Obj *other_dump = SnowStop_Dump(other);
SnowballStopFilter *clone = (SnowballStopFilter*)SnowStop_Load(other, dump);
SnowballStopFilter *other_clone = (SnowballStopFilter*)SnowStop_Load(other, other_dump);
- TEST_FALSE(batch, SnowStop_Equals(stopfilter,
- (Obj*)other), "Equals() false with different stoplist");
- TEST_TRUE(batch, SnowStop_Equals(stopfilter,
- (Obj*)clone), "Dump => Load round trip");
- TEST_TRUE(batch, SnowStop_Equals(other,
- (Obj*)other_clone), "Dump => Load round trip");
+ TEST_FALSE(batch,
+ SnowStop_Equals(stopfilter, (Obj*)other),
+ "Equals() false with different stoplist");
+ TEST_TRUE(batch,
+ SnowStop_Equals(stopfilter, (Obj*)clone),
+ "Dump => Load round trip");
+ TEST_TRUE(batch,
+ SnowStop_Equals(other, (Obj*)other_clone),
+ "Dump => Load round trip");
DECREF(stopfilter);
DECREF(dump);
@@ -68,8 +70,7 @@ test_Dump_Load_and_Equals(TestBatch *bat
}
void
-TestSnowStop_run_tests()
-{
+TestSnowStop_run_tests() {
TestBatch *batch = TestBatch_new(3);
TestBatch_Plan(batch);
Modified: incubator/lucy/trunk/core/Lucy/Test/Index/TestDocWriter.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Test/Index/TestDocWriter.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Test/Index/TestDocWriter.c (original)
+++ incubator/lucy/trunk/core/Lucy/Test/Index/TestDocWriter.c Sun May 1 23:50:24 2011
@@ -22,8 +22,7 @@
#include "Lucy/Index/DocWriter.h"
void
-TestDocWriter_run_tests()
-{
+TestDocWriter_run_tests() {
TestBatch *batch = TestBatch_new(1);
TestBatch_Plan(batch);
PASS(batch, "placeholder");
Modified: incubator/lucy/trunk/core/Lucy/Test/Index/TestHighlightWriter.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Test/Index/TestHighlightWriter.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Test/Index/TestHighlightWriter.c (original)
+++ incubator/lucy/trunk/core/Lucy/Test/Index/TestHighlightWriter.c Sun May 1 23:50:24 2011
@@ -22,8 +22,7 @@
#include "Lucy/Index/HighlightWriter.h"
void
-TestHLWriter_run_tests()
-{
+TestHLWriter_run_tests() {
TestBatch *batch = TestBatch_new(1);
TestBatch_Plan(batch);
PASS(batch, "Placeholder");
Modified: incubator/lucy/trunk/core/Lucy/Test/Index/TestHighlightWriter.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Test/Index/TestHighlightWriter.cfh?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Test/Index/TestHighlightWriter.cfh (original)
+++ incubator/lucy/trunk/core/Lucy/Test/Index/TestHighlightWriter.cfh Sun May 1 23:50:24 2011
@@ -16,7 +16,7 @@
parcel Lucy;
-inert class Lucy::Test::Index::TestHighlightWriter
+inert class Lucy::Test::Index::TestHighlightWriter
cnick TestHLWriter {
inert void
Modified: incubator/lucy/trunk/core/Lucy/Test/Index/TestIndexManager.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Test/Index/TestIndexManager.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Test/Index/TestIndexManager.c (original)
+++ incubator/lucy/trunk/core/Lucy/Test/Index/TestIndexManager.c Sun May 1 23:50:24 2011
@@ -21,26 +21,25 @@
#include "Lucy/Index/IndexManager.h"
static void
-test_Choose_Sparse(TestBatch *batch)
-{
+test_Choose_Sparse(TestBatch *batch) {
IndexManager *manager = IxManager_new(NULL, NULL);
for (uint32_t num_segs = 2; num_segs < 20; num_segs++) {
I32Array *doc_counts = I32Arr_new_blank(num_segs);
- for (uint32_t j = 0; j < num_segs; j++) {
- I32Arr_Set(doc_counts, j, 1000);
+ for (uint32_t j = 0; j < num_segs; j++) {
+ I32Arr_Set(doc_counts, j, 1000);
}
uint32_t threshold = IxManager_Choose_Sparse(manager, doc_counts);
- TEST_TRUE(batch, threshold != 1,
- "Either don't merge, or merge two segments: %u segs, thresh %u",
- (unsigned)num_segs, (unsigned)threshold);
+ TEST_TRUE(batch, threshold != 1,
+ "Either don't merge, or merge two segments: %u segs, thresh %u",
+ (unsigned)num_segs, (unsigned)threshold);
if (num_segs != 12 && num_segs != 13) { // when 2 is correct
I32Arr_Set(doc_counts, 0, 1);
threshold = IxManager_Choose_Sparse(manager, doc_counts);
- TEST_TRUE(batch, threshold != 2,
- "Don't include big next seg: %u segs, thresh %u",
- (unsigned)num_segs, (unsigned)threshold);
+ TEST_TRUE(batch, threshold != 2,
+ "Don't include big next seg: %u segs, thresh %u",
+ (unsigned)num_segs, (unsigned)threshold);
}
DECREF(doc_counts);
@@ -50,8 +49,7 @@ test_Choose_Sparse(TestBatch *batch)
}
void
-TestIxManager_run_tests()
-{
+TestIxManager_run_tests() {
TestBatch *batch = TestBatch_new(34);
TestBatch_Plan(batch);
test_Choose_Sparse(batch);
Modified: incubator/lucy/trunk/core/Lucy/Test/Index/TestPolyReader.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Test/Index/TestPolyReader.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Test/Index/TestPolyReader.c (original)
+++ incubator/lucy/trunk/core/Lucy/Test/Index/TestPolyReader.c Sun May 1 23:50:24 2011
@@ -22,26 +22,24 @@
#include "Lucy/Index/PolyReader.h"
static void
-test_sub_tick(TestBatch *batch)
-{
- size_t num_segs = 255;
- int32_t *ints = (int32_t*)MALLOCATE(num_segs * sizeof(int32_t));
- size_t i;
- for (i = 0; i < num_segs; i++) {
- ints[i] = i;
- }
- I32Array *offsets = I32Arr_new(ints, num_segs);
- for (i = 1; i < num_segs; i++) {
- if (PolyReader_sub_tick(offsets, i) != i - 1) { break; }
- }
- TEST_INT_EQ(batch, i, num_segs, "got all sub_tick() calls right");
- DECREF(offsets);
- FREEMEM(ints);
+test_sub_tick(TestBatch *batch) {
+ size_t num_segs = 255;
+ int32_t *ints = (int32_t*)MALLOCATE(num_segs * sizeof(int32_t));
+ size_t i;
+ for (i = 0; i < num_segs; i++) {
+ ints[i] = i;
+ }
+ I32Array *offsets = I32Arr_new(ints, num_segs);
+ for (i = 1; i < num_segs; i++) {
+ if (PolyReader_sub_tick(offsets, i) != i - 1) { break; }
+ }
+ TEST_INT_EQ(batch, i, num_segs, "got all sub_tick() calls right");
+ DECREF(offsets);
+ FREEMEM(ints);
}
void
-TestPolyReader_run_tests()
-{
+TestPolyReader_run_tests() {
TestBatch *batch = TestBatch_new(1);
TestBatch_Plan(batch);
Modified: incubator/lucy/trunk/core/Lucy/Test/Index/TestPostingListWriter.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Test/Index/TestPostingListWriter.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Test/Index/TestPostingListWriter.c (original)
+++ incubator/lucy/trunk/core/Lucy/Test/Index/TestPostingListWriter.c Sun May 1 23:50:24 2011
@@ -21,8 +21,7 @@
#include "Lucy/Test/Index/TestPostingListWriter.h"
void
-TestPListWriter_run_tests()
-{
+TestPListWriter_run_tests() {
TestBatch *batch = TestBatch_new(1);
TestBatch_Plan(batch);
PASS(batch, "Placeholder");
Modified: incubator/lucy/trunk/core/Lucy/Test/Index/TestPostingListWriter.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Test/Index/TestPostingListWriter.cfh?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Test/Index/TestPostingListWriter.cfh (original)
+++ incubator/lucy/trunk/core/Lucy/Test/Index/TestPostingListWriter.cfh Sun May 1 23:50:24 2011
@@ -16,7 +16,7 @@
parcel Lucy;
-inert class Lucy::Test::Index::TestPostingListWriter
+inert class Lucy::Test::Index::TestPostingListWriter
cnick TestPListWriter {
inert void
Modified: incubator/lucy/trunk/core/Lucy/Test/Index/TestSegWriter.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Test/Index/TestSegWriter.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Test/Index/TestSegWriter.c (original)
+++ incubator/lucy/trunk/core/Lucy/Test/Index/TestSegWriter.c Sun May 1 23:50:24 2011
@@ -22,8 +22,7 @@
#include "Lucy/Index/SegWriter.h"
void
-TestSegWriter_run_tests()
-{
+TestSegWriter_run_tests() {
TestBatch *batch = TestBatch_new(1);
TestBatch_Plan(batch);
PASS(batch, "placeholder");
Modified: incubator/lucy/trunk/core/Lucy/Test/Index/TestSegment.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Test/Index/TestSegment.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Test/Index/TestSegment.c (original)
+++ incubator/lucy/trunk/core/Lucy/Test/Index/TestSegment.c Sun May 1 23:50:24 2011
@@ -23,94 +23,90 @@
#include "Lucy/Store/RAMFolder.h"
static void
-test_fields(TestBatch *batch)
-{
+test_fields(TestBatch *batch) {
Segment *segment = Seg_new(1);
- ZombieCharBuf *foo = ZCB_WRAP_STR("foo",3 );
+ ZombieCharBuf *foo = ZCB_WRAP_STR("foo", 3);
ZombieCharBuf *bar = ZCB_WRAP_STR("bar", 3);
ZombieCharBuf *baz = ZCB_WRAP_STR("baz", 3);
- int32_t field_num;
-
+ int32_t field_num;
+
field_num = Seg_Add_Field(segment, (CharBuf*)foo);
- TEST_TRUE(batch, field_num == 1,
- "Add_Field returns field number, and field numbers start at 1");
+ TEST_TRUE(batch, field_num == 1,
+ "Add_Field returns field number, and field numbers start at 1");
field_num = Seg_Add_Field(segment, (CharBuf*)bar);
TEST_TRUE(batch, field_num == 2, "add a second field");
field_num = Seg_Add_Field(segment, (CharBuf*)foo);
TEST_TRUE(batch, field_num == 1,
- "Add_Field returns existing field number if field is already known");
+ "Add_Field returns existing field number if field is already known");
TEST_TRUE(batch, ZCB_Equals(bar, (Obj*)Seg_Field_Name(segment, 2)),
- "Field_Name");
- TEST_TRUE(batch, Seg_Field_Name(segment, 3) == NULL,
- "Field_Name returns NULL for unknown field number");
+ "Field_Name");
+ TEST_TRUE(batch, Seg_Field_Name(segment, 3) == NULL,
+ "Field_Name returns NULL for unknown field number");
TEST_TRUE(batch, Seg_Field_Num(segment, (CharBuf*)bar) == 2,
- "Field_Num");
- TEST_TRUE(batch, Seg_Field_Num(segment, (CharBuf*)baz) == 0,
- "Field_Num returns 0 for unknown field name");
+ "Field_Num");
+ TEST_TRUE(batch, Seg_Field_Num(segment, (CharBuf*)baz) == 0,
+ "Field_Num returns 0 for unknown field name");
DECREF(segment);
}
static void
-test_metadata_storage(TestBatch *batch)
-{
+test_metadata_storage(TestBatch *batch) {
Segment *segment = Seg_new(1);
CharBuf *got;
Seg_Store_Metadata_Str(segment, "foo", 3, (Obj*)CB_newf("bar"));
got = (CharBuf*)Seg_Fetch_Metadata_Str(segment, "foo", 3);
- TEST_TRUE(batch,
- got
- && CB_Is_A(got, CHARBUF)
- && CB_Equals_Str(got, "bar", 3),
- "metadata round trip");
+ TEST_TRUE(batch,
+ got
+ && CB_Is_A(got, CHARBUF)
+ && CB_Equals_Str(got, "bar", 3),
+ "metadata round trip"
+ );
DECREF(segment);
}
static void
-test_seg_name_and_num(TestBatch *batch)
-{
+test_seg_name_and_num(TestBatch *batch) {
Segment *segment_z = Seg_new(35);
CharBuf *seg_z_name = Seg_num_to_name(35);
TEST_TRUE(batch, Seg_Get_Number(segment_z) == I64_C(35), "Get_Number");
- TEST_TRUE(batch, CB_Equals_Str(Seg_Get_Name(segment_z), "seg_z", 5),
- "Get_Name");
- TEST_TRUE(batch, CB_Equals_Str(seg_z_name, "seg_z", 5),
- "num_to_name");
+ TEST_TRUE(batch, CB_Equals_Str(Seg_Get_Name(segment_z), "seg_z", 5),
+ "Get_Name");
+ TEST_TRUE(batch, CB_Equals_Str(seg_z_name, "seg_z", 5),
+ "num_to_name");
DECREF(seg_z_name);
DECREF(segment_z);
}
static void
-test_count(TestBatch *batch)
-{
+test_count(TestBatch *batch) {
Segment *segment = Seg_new(100);
-
+
TEST_TRUE(batch, Seg_Get_Count(segment) == 0, "count starts off at 0");
Seg_Set_Count(segment, 120);
TEST_TRUE(batch, Seg_Get_Count(segment) == 120, "Set_Count");
TEST_TRUE(batch, Seg_Increment_Count(segment, 10) == 130,
- "Increment_Count");
+ "Increment_Count");
DECREF(segment);
}
static void
-test_Compare_To(TestBatch *batch)
-{
+test_Compare_To(TestBatch *batch) {
Segment *segment_1 = Seg_new(1);
Segment *segment_2 = Seg_new(2);
Segment *also_segment_2 = Seg_new(2);
- TEST_TRUE(batch, Seg_Compare_To(segment_1, (Obj*)segment_2) < 0,
- "Compare_To 1 < 2");
- TEST_TRUE(batch, Seg_Compare_To(segment_2, (Obj*)segment_1) > 0,
- "Compare_To 1 < 2");
- TEST_TRUE(batch, Seg_Compare_To(segment_1, (Obj*)segment_1) == 0,
- "Compare_To identity");
- TEST_TRUE(batch, Seg_Compare_To(segment_2, (Obj*)also_segment_2) == 0,
- "Compare_To 2 == 2");
+ TEST_TRUE(batch, Seg_Compare_To(segment_1, (Obj*)segment_2) < 0,
+ "Compare_To 1 < 2");
+ TEST_TRUE(batch, Seg_Compare_To(segment_2, (Obj*)segment_1) > 0,
+ "Compare_To 1 < 2");
+ TEST_TRUE(batch, Seg_Compare_To(segment_1, (Obj*)segment_1) == 0,
+ "Compare_To identity");
+ TEST_TRUE(batch, Seg_Compare_To(segment_2, (Obj*)also_segment_2) == 0,
+ "Compare_To 2 == 2");
DECREF(segment_1);
DECREF(segment_2);
@@ -118,8 +114,7 @@ test_Compare_To(TestBatch *batch)
}
static void
-test_Write_File_and_Read_File(TestBatch *batch)
-{
+test_Write_File_and_Read_File(TestBatch *batch) {
RAMFolder *folder = RAMFolder_new(NULL);
Segment *segment = Seg_new(100);
Segment *got = Seg_new(100);
@@ -131,19 +126,22 @@ test_Write_File_and_Read_File(TestBatch
Seg_Store_Metadata_Str(segment, "foo", 3, (Obj*)CB_newf("bar"));
Seg_Add_Field(segment, flotsam);
Seg_Add_Field(segment, jetsam);
-
+
RAMFolder_MkDir(folder, Seg_Get_Name(segment));
Seg_Write_File(segment, (Folder*)folder);
Seg_Read_File(got, (Folder*)folder);
- TEST_TRUE(batch, Seg_Get_Count(got) == Seg_Get_Count(segment),
- "Round-trip count through file");
- TEST_TRUE(batch,
- Seg_Field_Num(got, jetsam) == Seg_Field_Num(segment, jetsam),
- "Round trip field names through file");
+ TEST_TRUE(batch, Seg_Get_Count(got) == Seg_Get_Count(segment),
+ "Round-trip count through file");
+ TEST_TRUE(batch,
+ Seg_Field_Num(got, jetsam) == Seg_Field_Num(segment, jetsam),
+ "Round trip field names through file");
meta = (CharBuf*)Seg_Fetch_Metadata_Str(got, "foo", 3);
- TEST_TRUE(batch, meta && CB_Is_A(meta, CHARBUF)
- && CB_Equals_Str(meta, "bar", 3), "Round trip metadata through file");
+ TEST_TRUE(batch,
+ meta
+ && CB_Is_A(meta, CHARBUF)
+ && CB_Equals_Str(meta, "bar", 3),
+ "Round trip metadata through file");
DECREF(got);
DECREF(segment);
@@ -151,8 +149,7 @@ test_Write_File_and_Read_File(TestBatch
}
void
-TestSeg_run_tests()
-{
+TestSeg_run_tests() {
TestBatch *batch = TestBatch_new(21);
TestBatch_Plan(batch);
Modified: incubator/lucy/trunk/core/Lucy/Test/Index/TestSnapshot.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Test/Index/TestSnapshot.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Test/Index/TestSnapshot.c (original)
+++ incubator/lucy/trunk/core/Lucy/Test/Index/TestSnapshot.c Sun May 1 23:50:24 2011
@@ -22,8 +22,7 @@
#include "Lucy/Store/RAMFolder.h"
static void
-test_Add_and_Delete(TestBatch *batch)
-{
+test_Add_and_Delete(TestBatch *batch) {
Snapshot *snapshot = Snapshot_new();
CharBuf *foo = (CharBuf*)ZCB_WRAP_STR("foo", 3);
CharBuf *bar = (CharBuf*)ZCB_WRAP_STR("bar", 3);
@@ -31,14 +30,14 @@ test_Add_and_Delete(TestBatch *batch)
Snapshot_Add_Entry(snapshot, foo);
Snapshot_Add_Entry(snapshot, foo); // redundant
VArray *entries = Snapshot_List(snapshot);
- TEST_INT_EQ(batch, Snapshot_Num_Entries(snapshot), 1,
- "One entry added");
+ TEST_INT_EQ(batch, Snapshot_Num_Entries(snapshot), 1,
+ "One entry added");
TEST_TRUE(batch, CB_Equals(foo, VA_Fetch(entries, 0)), "correct entry");
DECREF(entries);
Snapshot_Add_Entry(snapshot, bar);
- TEST_INT_EQ(batch, Snapshot_Num_Entries(snapshot), 2,
- "second entry added");
+ TEST_INT_EQ(batch, Snapshot_Num_Entries(snapshot), 2,
+ "second entry added");
Snapshot_Delete_Entry(snapshot, foo);
TEST_INT_EQ(batch, Snapshot_Num_Entries(snapshot), 1, "Delete_Entry");
@@ -46,8 +45,7 @@ test_Add_and_Delete(TestBatch *batch)
}
static void
-test_path_handling(TestBatch *batch)
-{
+test_path_handling(TestBatch *batch) {
Snapshot *snapshot = Snapshot_new();
Folder *folder = (Folder*)RAMFolder_new(NULL);
CharBuf *snap = (CharBuf*)ZCB_WRAP_STR("snap", 4);
@@ -55,24 +53,23 @@ test_path_handling(TestBatch *batch)
Snapshot_Write_File(snapshot, folder, snap);
TEST_TRUE(batch, CB_Equals(snap, (Obj*)Snapshot_Get_Path(snapshot)),
- "Write_File() sets path as a side effect");
+ "Write_File() sets path as a side effect");
Folder_Rename(folder, snap, crackle);
Snapshot_Read_File(snapshot, folder, crackle);
TEST_TRUE(batch, CB_Equals(crackle, (Obj*)Snapshot_Get_Path(snapshot)),
- "Read_File() sets path as a side effect");
+ "Read_File() sets path as a side effect");
Snapshot_Set_Path(snapshot, snap);
TEST_TRUE(batch, CB_Equals(snap, (Obj*)Snapshot_Get_Path(snapshot)),
- "Set_Path()");
+ "Set_Path()");
DECREF(folder);
DECREF(snapshot);
}
static void
-test_Read_File_and_Write_File(TestBatch *batch)
-{
+test_Read_File_and_Write_File(TestBatch *batch) {
Snapshot *snapshot = Snapshot_new();
Folder *folder = (Folder*)RAMFolder_new(NULL);
CharBuf *snap = (CharBuf*)ZCB_WRAP_STR("snap", 4);
@@ -87,8 +84,8 @@ test_Read_File_and_Write_File(TestBatch
VArray *orig_list = Snapshot_List(snapshot);
VArray *dupe_list = Snapshot_List(dupe);
- TEST_TRUE(batch, VA_Equals(orig_list, (Obj*)dupe_list),
- "Round trip through Write_File() and Read_File()");
+ TEST_TRUE(batch, VA_Equals(orig_list, (Obj*)dupe_list),
+ "Round trip through Write_File() and Read_File()");
DECREF(orig_list);
DECREF(dupe_list);
@@ -98,8 +95,7 @@ test_Read_File_and_Write_File(TestBatch
}
void
-TestSnapshot_run_tests()
-{
+TestSnapshot_run_tests() {
TestBatch *batch = TestBatch_new(9);
TestBatch_Plan(batch);
test_Add_and_Delete(batch);
Modified: incubator/lucy/trunk/core/Lucy/Test/Object/TestBitVector.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Test/Object/TestBitVector.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Test/Object/TestBitVector.c (original)
+++ incubator/lucy/trunk/core/Lucy/Test/Object/TestBitVector.c Sun May 1 23:50:24 2011
@@ -22,26 +22,25 @@
#include "Lucy/Test/Object/TestBitVector.h"
static void
-test_Set_and_Get(TestBatch *batch)
-{
+test_Set_and_Get(TestBatch *batch) {
unsigned i, max;
const uint32_t three = 3;
const uint32_t seventeen = 17;
BitVector *bit_vec = BitVec_new(8);
BitVec_Set(bit_vec, three);
- TEST_TRUE(batch, BitVec_Get_Capacity(bit_vec) < seventeen,
- "set below cap");
+ TEST_TRUE(batch, BitVec_Get_Capacity(bit_vec) < seventeen,
+ "set below cap");
BitVec_Set(bit_vec, seventeen);
- TEST_TRUE(batch, BitVec_Get_Capacity(bit_vec) > seventeen,
- "set above cap causes BitVector to grow");
+ TEST_TRUE(batch, BitVec_Get_Capacity(bit_vec) > seventeen,
+ "set above cap causes BitVector to grow");
for (i = 0, max = BitVec_Get_Capacity(bit_vec); i < max; i++) {
- if (i == three || i == seventeen) {
- TEST_TRUE(batch, BitVec_Get(bit_vec, i), "set/get %d", i);
+ if (i == three || i == seventeen) {
+ TEST_TRUE(batch, BitVec_Get(bit_vec, i), "set/get %d", i);
}
else {
- TEST_FALSE(batch, BitVec_Get(bit_vec, i), "get %d", i);
+ TEST_FALSE(batch, BitVec_Get(bit_vec, i), "get %d", i);
}
}
TEST_FALSE(batch, BitVec_Get(bit_vec, i), "out of range get");
@@ -50,8 +49,7 @@ test_Set_and_Get(TestBatch *batch)
}
static void
-test_Flip(TestBatch *batch)
-{
+test_Flip(TestBatch *batch) {
BitVector *bit_vec = BitVec_new(0);
int i;
@@ -70,8 +68,7 @@ test_Flip(TestBatch *batch)
}
static void
-test_Flip_Block_ascending(TestBatch *batch)
-{
+test_Flip_Block_ascending(TestBatch *batch) {
BitVector *bit_vec = BitVec_new(0);
int i;
@@ -80,13 +77,13 @@ test_Flip_Block_ascending(TestBatch *bat
}
for (i = 0; i <= 20; i++) {
- if (i % 2 == 0) {
- TEST_TRUE(batch, BitVec_Get(bit_vec, i),
- "Flip_Block ascending %d", i);
+ if (i % 2 == 0) {
+ TEST_TRUE(batch, BitVec_Get(bit_vec, i),
+ "Flip_Block ascending %d", i);
}
else {
- TEST_FALSE(batch, BitVec_Get(bit_vec, i),
- "Flip_Block ascending %d", i);
+ TEST_FALSE(batch, BitVec_Get(bit_vec, i),
+ "Flip_Block ascending %d", i);
}
}
@@ -94,8 +91,7 @@ test_Flip_Block_ascending(TestBatch *bat
}
static void
-test_Flip_Block_descending(TestBatch *batch)
-{
+test_Flip_Block_descending(TestBatch *batch) {
BitVector *bit_vec = BitVec_new(0);
int i;
@@ -104,13 +100,13 @@ test_Flip_Block_descending(TestBatch *ba
}
for (i = 0; i <= 20; i++) {
- if (i % 2) {
- TEST_TRUE(batch, BitVec_Get(bit_vec, i),
- "Flip_Block descending %d", i);
+ if (i % 2) {
+ TEST_TRUE(batch, BitVec_Get(bit_vec, i),
+ "Flip_Block descending %d", i);
}
else {
- TEST_FALSE(batch, BitVec_Get(bit_vec, i),
- "Flip_Block descending %d", i);
+ TEST_FALSE(batch, BitVec_Get(bit_vec, i),
+ "Flip_Block descending %d", i);
}
}
@@ -118,8 +114,7 @@ test_Flip_Block_descending(TestBatch *ba
}
static void
-test_Flip_Block_bulk(TestBatch *batch)
-{
+test_Flip_Block_bulk(TestBatch *batch) {
int32_t offset;
for (offset = 0; offset <= 17; offset++) {
@@ -146,8 +141,7 @@ test_Flip_Block_bulk(TestBatch *batch)
}
static void
-test_Mimic(TestBatch *batch)
-{
+test_Mimic(TestBatch *batch) {
int foo;
for (foo = 0; foo <= 17; foo++) {
@@ -173,12 +167,12 @@ test_Mimic(TestBatch *batch)
}
static BitVector*
-S_create_set(int set_num)
-{
+S_create_set(int set_num) {
int i;
int nums_1[] = { 1, 2, 3, 10, 20, 30, 0 };
- int nums_2[] = { 2, 3, 4, 5, 6, 7, 8, 9, 10,
- 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 0 };
+ int nums_2[] = { 2, 3, 4, 5, 6, 7, 8, 9, 10,
+ 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 0
+ };
int *nums = set_num == 1 ? nums_1 : nums_2;
BitVector *bit_vec = BitVec_new(31);
for (i = 0; nums[i] != 0; i++) {
@@ -192,16 +186,15 @@ S_create_set(int set_num)
#define OP_AND 3
#define OP_AND_NOT 4
static int
-S_verify_logical_op(BitVector *bit_vec, BitVector *set_1, BitVector *set_2,
- int op)
-{
+S_verify_logical_op(BitVector *bit_vec, BitVector *set_1, BitVector *set_2,
+ int op) {
int i;
for (i = 0; i < 50; i++) {
bool_t wanted;
-
- switch(op) {
- case OP_OR:
+
+ switch (op) {
+ case OP_OR:
wanted = BitVec_Get(set_1, i) || BitVec_Get(set_2, i);
break;
case OP_XOR:
@@ -217,7 +210,7 @@ S_verify_logical_op(BitVector *bit_vec,
wanted = false;
THROW(ERR, "unknown op: %d", op);
}
-
+
if (BitVec_Get(bit_vec, i) != wanted) { break; }
}
@@ -225,8 +218,7 @@ S_verify_logical_op(BitVector *bit_vec,
}
static void
-test_Or(TestBatch *batch)
-{
+test_Or(TestBatch *batch) {
BitVector *smaller = S_create_set(1);
BitVector *larger = S_create_set(2);
BitVector *set_1 = S_create_set(1);
@@ -234,10 +226,10 @@ test_Or(TestBatch *batch)
BitVec_Or(smaller, set_2);
TEST_INT_EQ(batch, S_verify_logical_op(smaller, set_1, set_2, OP_OR),
- 50, "OR with self smaller than other");
+ 50, "OR with self smaller than other");
BitVec_Or(larger, set_1);
TEST_INT_EQ(batch, S_verify_logical_op(larger, set_1, set_2, OP_OR),
- 50, "OR with other smaller than self");
+ 50, "OR with other smaller than self");
DECREF(smaller);
DECREF(larger);
@@ -246,19 +238,18 @@ test_Or(TestBatch *batch)
}
static void
-test_Xor(TestBatch *batch)
-{
+test_Xor(TestBatch *batch) {
BitVector *smaller = S_create_set(1);
BitVector *larger = S_create_set(2);
BitVector *set_1 = S_create_set(1);
BitVector *set_2 = S_create_set(2);
BitVec_Xor(smaller, set_2);
- TEST_INT_EQ(batch, S_verify_logical_op(smaller, set_1, set_2, OP_XOR),
- 50, "XOR with self smaller than other");
+ TEST_INT_EQ(batch, S_verify_logical_op(smaller, set_1, set_2, OP_XOR),
+ 50, "XOR with self smaller than other");
BitVec_Xor(larger, set_1);
- TEST_INT_EQ(batch, S_verify_logical_op(larger, set_1, set_2, OP_XOR),
- 50, "XOR with other smaller than self");
+ TEST_INT_EQ(batch, S_verify_logical_op(larger, set_1, set_2, OP_XOR),
+ 50, "XOR with other smaller than self");
DECREF(smaller);
DECREF(larger);
@@ -267,19 +258,18 @@ test_Xor(TestBatch *batch)
}
static void
-test_And(TestBatch *batch)
-{
+test_And(TestBatch *batch) {
BitVector *smaller = S_create_set(1);
BitVector *larger = S_create_set(2);
BitVector *set_1 = S_create_set(1);
BitVector *set_2 = S_create_set(2);
BitVec_And(smaller, set_2);
- TEST_INT_EQ(batch, S_verify_logical_op(smaller, set_1, set_2, OP_AND),
- 50, "AND with self smaller than other");
+ TEST_INT_EQ(batch, S_verify_logical_op(smaller, set_1, set_2, OP_AND),
+ 50, "AND with self smaller than other");
BitVec_And(larger, set_1);
- TEST_INT_EQ(batch, S_verify_logical_op(larger, set_1, set_2, OP_AND),
- 50, "AND with other smaller than self");
+ TEST_INT_EQ(batch, S_verify_logical_op(larger, set_1, set_2, OP_AND),
+ 50, "AND with other smaller than self");
DECREF(smaller);
DECREF(larger);
@@ -288,21 +278,20 @@ test_And(TestBatch *batch)
}
static void
-test_And_Not(TestBatch *batch)
-{
+test_And_Not(TestBatch *batch) {
BitVector *smaller = S_create_set(1);
BitVector *larger = S_create_set(2);
BitVector *set_1 = S_create_set(1);
BitVector *set_2 = S_create_set(2);
BitVec_And_Not(smaller, set_2);
- TEST_INT_EQ(batch,
- S_verify_logical_op(smaller, set_1, set_2, OP_AND_NOT),
- 50, "AND_NOT with self smaller than other");
+ TEST_INT_EQ(batch,
+ S_verify_logical_op(smaller, set_1, set_2, OP_AND_NOT),
+ 50, "AND_NOT with self smaller than other");
BitVec_And_Not(larger, set_1);
- TEST_INT_EQ(batch,
- S_verify_logical_op(larger, set_2, set_1, OP_AND_NOT),
- 50, "AND_NOT with other smaller than self");
+ TEST_INT_EQ(batch,
+ S_verify_logical_op(larger, set_2, set_1, OP_AND_NOT),
+ 50, "AND_NOT with other smaller than self");
DECREF(smaller);
DECREF(larger);
@@ -311,20 +300,19 @@ test_And_Not(TestBatch *batch)
}
static void
-test_Count(TestBatch *batch)
-{
+test_Count(TestBatch *batch) {
int i;
int shuffled[64];
BitVector *bit_vec = BitVec_new(64);
for (i = 0; i < 64; i++) { shuffled[i] = i; }
- for (i = 0; i < 64; i++) {
+ for (i = 0; i < 64; i++) {
int shuffle_pos = rand() % 64;
int temp = shuffled[shuffle_pos];
shuffled[shuffle_pos] = shuffled[i];
- shuffled[i] = temp;
+ shuffled[i] = temp;
}
- for (i = 0; i < 64; i++) {
+ for (i = 0; i < 64; i++) {
BitVec_Set(bit_vec, shuffled[i]);
if (BitVec_Count(bit_vec) != (uint32_t)(i + 1)) { break; }
}
@@ -334,33 +322,31 @@ test_Count(TestBatch *batch)
}
static void
-test_Next_Hit(TestBatch *batch)
-{
+test_Next_Hit(TestBatch *batch) {
int i;
for (i = 24; i <= 33; i++) {
int probe;
BitVector *bit_vec = BitVec_new(64);
BitVec_Set(bit_vec, i);
- TEST_INT_EQ(batch, BitVec_Next_Hit(bit_vec, 0), i,
- "Next_Hit for 0 is %d", i);
- TEST_INT_EQ(batch, BitVec_Next_Hit(bit_vec, 0), i,
- "Next_Hit for 1 is %d", i);
+ TEST_INT_EQ(batch, BitVec_Next_Hit(bit_vec, 0), i,
+ "Next_Hit for 0 is %d", i);
+ TEST_INT_EQ(batch, BitVec_Next_Hit(bit_vec, 0), i,
+ "Next_Hit for 1 is %d", i);
for (probe = 15; probe <= i; probe++) {
- TEST_INT_EQ(batch, BitVec_Next_Hit(bit_vec, probe), i,
- "Next_Hit for %d is %d", probe, i);
+ TEST_INT_EQ(batch, BitVec_Next_Hit(bit_vec, probe), i,
+ "Next_Hit for %d is %d", probe, i);
}
for (probe = i + 1; probe <= i + 9; probe++) {
TEST_INT_EQ(batch, BitVec_Next_Hit(bit_vec, probe), -1,
- "no Next_Hit for %d when max is %d", probe, i );
+ "no Next_Hit for %d when max is %d", probe, i);
}
DECREF(bit_vec);
}
}
static void
-test_Clear_All(TestBatch *batch)
-{
+test_Clear_All(TestBatch *batch) {
BitVector *bit_vec = BitVec_new(64);
BitVec_Flip_Block(bit_vec, 0, 63);
BitVec_Clear_All(bit_vec);
@@ -369,8 +355,7 @@ test_Clear_All(TestBatch *batch)
}
static void
-test_Clone(TestBatch *batch)
-{
+test_Clone(TestBatch *batch) {
int i;
BitVector *self = BitVec_new(30);
BitVector *twin;
@@ -392,8 +377,7 @@ test_Clone(TestBatch *batch)
}
static int
-S_compare_u64s(void *context, const void *va, const void *vb)
-{
+S_compare_u64s(void *context, const void *va, const void *vb) {
uint64_t a = *(uint64_t*)va;
uint64_t b = *(uint64_t*)vb;
UNUSED_VAR(context);
@@ -401,8 +385,7 @@ S_compare_u64s(void *context, const void
}
static void
-test_To_Array(TestBatch *batch)
-{
+test_To_Array(TestBatch *batch) {
uint64_t *source_ints = TestUtils_random_u64s(NULL, 20, 0, 200);
BitVector *bit_vec = BitVec_new(0);
I32Array *array;
@@ -410,8 +393,8 @@ test_To_Array(TestBatch *batch)
long i;
// Unique the random ints.
- Sort_quicksort(source_ints, 20, sizeof(uint64_t),
- S_compare_u64s, NULL);
+ Sort_quicksort(source_ints, 20, sizeof(uint64_t),
+ S_compare_u64s, NULL);
for (i = 0; i < 19; i++) {
if (source_ints[i] != source_ints[i + 1]) {
source_ints[num_unique] = source_ints[i];
@@ -429,8 +412,8 @@ test_To_Array(TestBatch *batch)
for (i = 0; i < num_unique; i++) {
if (I32Arr_Get(array, i) != (int32_t)source_ints[i]) { break; }
}
- TEST_INT_EQ(batch, i, num_unique, "To_Array (%ld == %ld)", i,
- num_unique);
+ TEST_INT_EQ(batch, i, num_unique, "To_Array (%ld == %ld)", i,
+ num_unique);
DECREF(array);
DECREF(bit_vec);
@@ -440,8 +423,7 @@ test_To_Array(TestBatch *batch)
// Valgrind only - detect off-by-one error.
static void
-test_off_by_one_error()
-{
+test_off_by_one_error() {
int cap;
for (cap = 5; cap <= 24; cap++) {
BitVector *bit_vec = BitVec_new(cap);
@@ -451,8 +433,7 @@ test_off_by_one_error()
}
void
-TestBitVector_run_tests()
-{
+TestBitVector_run_tests() {
TestBatch *batch = TestBatch_new(1029);
TestBatch_Plan(batch);
Modified: incubator/lucy/trunk/core/Lucy/Test/Object/TestByteBuf.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Test/Object/TestByteBuf.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Test/Object/TestByteBuf.c (original)
+++ incubator/lucy/trunk/core/Lucy/Test/Object/TestByteBuf.c Sun May 1 23:50:24 2011
@@ -22,51 +22,48 @@
#include "Lucy/Test/Object/TestByteBuf.h"
static void
-test_Equals(TestBatch *batch)
-{
- ByteBuf *wanted = BB_new_bytes("foo", 4); // Include terminating NULL.
- ByteBuf *got = BB_new_bytes("foo", 4);
+test_Equals(TestBatch *batch) {
+ ByteBuf *wanted = BB_new_bytes("foo", 4); // Include terminating NULL.
+ ByteBuf *got = BB_new_bytes("foo", 4);
TEST_TRUE(batch, BB_Equals(wanted, (Obj*)got), "Equals");
TEST_INT_EQ(batch, BB_Hash_Sum(got), BB_Hash_Sum(wanted), "Hash_Sum");
TEST_TRUE(batch, BB_Equals_Bytes(got, "foo", 4), "Equals_Bytes");
- TEST_FALSE(batch, BB_Equals_Bytes(got, "foo", 3),
- "Equals_Bytes spoiled by different size");
- TEST_FALSE(batch, BB_Equals_Bytes(got, "bar", 4),
- "Equals_Bytes spoiled by different content");
+ TEST_FALSE(batch, BB_Equals_Bytes(got, "foo", 3),
+ "Equals_Bytes spoiled by different size");
+ TEST_FALSE(batch, BB_Equals_Bytes(got, "bar", 4),
+ "Equals_Bytes spoiled by different content");
BB_Set_Size(got, 3);
- TEST_FALSE(batch, BB_Equals(wanted, (Obj*)got),
- "Different size spoils Equals");
- TEST_FALSE(batch, BB_Hash_Sum(got) == BB_Hash_Sum(wanted),
- "Different size spoils Hash_Sum (probably -- at least this one)");
+ TEST_FALSE(batch, BB_Equals(wanted, (Obj*)got),
+ "Different size spoils Equals");
+ TEST_FALSE(batch, BB_Hash_Sum(got) == BB_Hash_Sum(wanted),
+ "Different size spoils Hash_Sum (probably -- at least this one)");
BB_Mimic_Bytes(got, "bar", 4);
- TEST_INT_EQ(batch, BB_Get_Size(wanted), BB_Get_Size(got),
- "same length");
- TEST_FALSE(batch, BB_Equals(wanted, (Obj*)got),
- "Different content spoils Equals");
+ TEST_INT_EQ(batch, BB_Get_Size(wanted), BB_Get_Size(got),
+ "same length");
+ TEST_FALSE(batch, BB_Equals(wanted, (Obj*)got),
+ "Different content spoils Equals");
DECREF(got);
DECREF(wanted);
}
static void
-test_Grow(TestBatch *batch)
-{
+test_Grow(TestBatch *batch) {
ByteBuf *bb = BB_new(1);
TEST_INT_EQ(batch, BB_Get_Capacity(bb), 8,
- "Allocate in 8-byte increments");
+ "Allocate in 8-byte increments");
BB_Grow(bb, 9);
- TEST_INT_EQ(batch, BB_Get_Capacity(bb), 16,
- "Grow in 8-byte increments");
+ TEST_INT_EQ(batch, BB_Get_Capacity(bb), 16,
+ "Grow in 8-byte increments");
DECREF(bb);
}
static void
-test_Clone(TestBatch *batch)
-{
+test_Clone(TestBatch *batch) {
ByteBuf *bb = BB_new_bytes("foo", 3);
ByteBuf *twin = BB_Clone(bb);
TEST_TRUE(batch, BB_Equals(bb, (Obj*)twin), "Clone");
@@ -75,40 +72,38 @@ test_Clone(TestBatch *batch)
}
static void
-test_compare(TestBatch *batch)
-{
- ByteBuf *a = BB_new_bytes("foo\0a", 5);
+test_compare(TestBatch *batch) {
+ ByteBuf *a = BB_new_bytes("foo\0a", 5);
ByteBuf *b = BB_new_bytes("foo\0b", 5);
BB_Set_Size(a, 4);
BB_Set_Size(b, 4);
TEST_INT_EQ(batch, BB_compare(&a, &b), 0,
- "BB_compare returns 0 for equal ByteBufs");
+ "BB_compare returns 0 for equal ByteBufs");
BB_Set_Size(a, 3);
TEST_TRUE(batch, BB_compare(&a, &b) < 0, "shorter ByteBuf sorts first");
BB_Set_Size(a, 5);
BB_Set_Size(b, 5);
- TEST_TRUE(batch, BB_compare(&a, &b) < 0,
- "NULL doesn't interfere with BB_compare");
+ TEST_TRUE(batch, BB_compare(&a, &b) < 0,
+ "NULL doesn't interfere with BB_compare");
DECREF(a);
DECREF(b);
}
static void
-test_Mimic(TestBatch *batch)
-{
- ByteBuf *a = BB_new_bytes("foo", 3);
+test_Mimic(TestBatch *batch) {
+ ByteBuf *a = BB_new_bytes("foo", 3);
ByteBuf *b = BB_new(0);
BB_Mimic(b, (Obj*)a);
TEST_TRUE(batch, BB_Equals(a, (Obj*)b), "Mimic");
BB_Mimic_Bytes(a, "bar", 4);
- TEST_TRUE(batch, strcmp(BB_Get_Buf(a), "bar") == 0,
- "Mimic_Bytes content");
+ TEST_TRUE(batch, strcmp(BB_Get_Buf(a), "bar") == 0,
+ "Mimic_Bytes content");
TEST_INT_EQ(batch, BB_Get_Size(a), 4, "Mimic_Bytes size");
BB_Mimic(b, (Obj*)a);
@@ -119,16 +114,15 @@ test_Mimic(TestBatch *batch)
}
static void
-test_Cat(TestBatch *batch)
-{
+test_Cat(TestBatch *batch) {
ByteBuf *wanted = BB_new_bytes("foobar", 6);
- ByteBuf *got = BB_new_bytes("foo", 3);
+ ByteBuf *got = BB_new_bytes("foo", 3);
ByteBuf *scratch = BB_new_bytes("bar", 3);
BB_Cat(got, scratch);
TEST_TRUE(batch, BB_Equals(wanted, (Obj*)got), "Cat");
- BB_Mimic_Bytes(wanted,"foobarbaz", 9);
+ BB_Mimic_Bytes(wanted, "foobarbaz", 9);
BB_Cat_Bytes(got, "baz", 3);
TEST_TRUE(batch, BB_Equals(wanted, (Obj*)got), "Cat_Bytes");
@@ -138,19 +132,17 @@ test_Cat(TestBatch *batch)
}
static void
-test_serialization(TestBatch *batch)
-{
+test_serialization(TestBatch *batch) {
ByteBuf *wanted = BB_new_bytes("foobar", 6);
ByteBuf *got = (ByteBuf*)TestUtils_freeze_thaw((Obj*)wanted);
- TEST_TRUE(batch, got && BB_Equals(wanted, (Obj*)got),
- "Serialization round trip");
+ TEST_TRUE(batch, got && BB_Equals(wanted, (Obj*)got),
+ "Serialization round trip");
DECREF(wanted);
DECREF(got);
}
void
-TestBB_run_tests()
-{
+TestBB_run_tests() {
TestBatch *batch = TestBatch_new(22);
TestBatch_Plan(batch);
Modified: incubator/lucy/trunk/core/Lucy/Test/Object/TestCharBuf.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Test/Object/TestCharBuf.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Test/Object/TestCharBuf.c (original)
+++ incubator/lucy/trunk/core/Lucy/Test/Object/TestCharBuf.c Sun May 1 23:50:24 2011
@@ -28,17 +28,15 @@ static char smiley[] = { (char)0xE2, (ch
static uint32_t smiley_len = 3;
static CharBuf*
-S_get_cb(char *string)
-{
+S_get_cb(char *string) {
return CB_new_from_utf8(string, strlen(string));
}
static void
-test_Cat(TestBatch *batch)
-{
- CharBuf *wanted = CB_newf("a%s", smiley);
- CharBuf *got = S_get_cb("");
-
+test_Cat(TestBatch *batch) {
+ CharBuf *wanted = CB_newf("a%s", smiley);
+ CharBuf *got = S_get_cb("");
+
CB_Cat(got, wanted);
TEST_TRUE(batch, CB_Equals(wanted, (Obj*)got), "Cat");
DECREF(got);
@@ -62,8 +60,7 @@ test_Cat(TestBatch *batch)
}
static void
-test_Mimic_and_Clone(TestBatch *batch)
-{
+test_Mimic_and_Clone(TestBatch *batch) {
CharBuf *wanted = S_get_cb("foo");
CharBuf *got = S_get_cb("bar");
@@ -84,8 +81,7 @@ test_Mimic_and_Clone(TestBatch *batch)
}
static void
-test_Find(TestBatch *batch)
-{
+test_Find(TestBatch *batch) {
CharBuf *string = CB_new(10);
CharBuf *substring = S_get_cb("foo");
@@ -104,9 +100,8 @@ test_Find(TestBatch *batch)
}
static void
-test_Code_Point_At_and_From(TestBatch *batch)
-{
- uint32_t code_points[] = { 'a', 0x263A, 0x263A, 'b', 0x263A, 'c' };
+test_Code_Point_At_and_From(TestBatch *batch) {
+ uint32_t code_points[] = { 'a', 0x263A, 0x263A, 'b', 0x263A, 'c' };
uint32_t num_code_points = sizeof(code_points) / sizeof(uint32_t);
CharBuf *string = CB_newf("a%s%sb%sc", smiley, smiley, smiley);
uint32_t i;
@@ -114,17 +109,16 @@ test_Code_Point_At_and_From(TestBatch *b
for (i = 0; i < num_code_points; i++) {
uint32_t from = num_code_points - i - 1;
TEST_INT_EQ(batch, CB_Code_Point_At(string, i), code_points[i],
- "Code_Point_At %ld", (long)i);
- TEST_INT_EQ(batch, CB_Code_Point_At(string, from),
- code_points[from], "Code_Point_From %ld", (long)from);
+ "Code_Point_At %ld", (long)i);
+ TEST_INT_EQ(batch, CB_Code_Point_At(string, from),
+ code_points[from], "Code_Point_From %ld", (long)from);
}
DECREF(string);
}
static void
-test_SubString(TestBatch *batch)
-{
+test_SubString(TestBatch *batch) {
CharBuf *string = CB_newf("a%s%sb%sc", smiley, smiley, smiley);
CharBuf *wanted = CB_newf("%sb%s", smiley, smiley);
CharBuf *got = CB_SubString(string, 2, 3);
@@ -135,8 +129,7 @@ test_SubString(TestBatch *batch)
}
static void
-test_Nip_and_Chop(TestBatch *batch)
-{
+test_Nip_and_Chop(TestBatch *batch) {
CharBuf *wanted;
CharBuf *got;
@@ -157,8 +150,7 @@ test_Nip_and_Chop(TestBatch *batch)
static void
-test_Truncate(TestBatch *batch)
-{
+test_Truncate(TestBatch *batch) {
CharBuf *wanted = CB_newf("a%s", smiley, smiley);
CharBuf *got = CB_newf("a%s%sb%sc", smiley, smiley, smiley);
CB_Truncate(got, 2);
@@ -168,12 +160,11 @@ test_Truncate(TestBatch *batch)
}
static void
-test_Trim(TestBatch *batch)
-{
- uint32_t spaces[] = {
+test_Trim(TestBatch *batch) {
+ uint32_t spaces[] = {
' ', '\t', '\r', '\n', 0x000B, 0x000C, 0x000D, 0x0085,
- 0x00A0, 0x1680, 0x180E, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004,
- 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200A, 0x2028, 0x2029,
+ 0x00A0, 0x1680, 0x180E, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004,
+ 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200A, 0x2028, 0x2029,
0x202F, 0x205F, 0x3000
};
uint32_t num_spaces = sizeof(spaces) / sizeof(uint32_t);
@@ -186,13 +177,13 @@ test_Trim(TestBatch *batch)
for (i = 0; i < num_spaces; i++) { CB_Cat_Char(got, spaces[i]); }
TEST_TRUE(batch, CB_Trim_Top(got), "Trim_Top returns true on success");
- TEST_FALSE(batch, CB_Trim_Top(got),
- "Trim_Top returns false on failure");
+ TEST_FALSE(batch, CB_Trim_Top(got),
+ "Trim_Top returns false on failure");
TEST_TRUE(batch, CB_Trim_Tail(got), "Trim_Tail returns true on success");
- TEST_FALSE(batch, CB_Trim_Tail(got),
- "Trim_Tail returns false on failure");
- TEST_TRUE(batch, CB_Equals_Str(got, smiley, smiley_len),
- "Trim_Top and Trim_Tail worked");
+ TEST_FALSE(batch, CB_Trim_Tail(got),
+ "Trim_Tail returns false on failure");
+ TEST_TRUE(batch, CB_Equals_Str(got, smiley, smiley_len),
+ "Trim_Top and Trim_Tail worked");
// Build the spacey smiley again.
CB_Truncate(got, 0);
@@ -202,15 +193,14 @@ test_Trim(TestBatch *batch)
TEST_TRUE(batch, CB_Trim(got), "Trim returns true on success");
TEST_FALSE(batch, CB_Trim(got), "Trim returns false on failure");
- TEST_TRUE(batch, CB_Equals_Str(got, smiley, smiley_len),
- "Trim worked");
+ TEST_TRUE(batch, CB_Equals_Str(got, smiley, smiley_len),
+ "Trim worked");
DECREF(got);
}
static void
-test_To_F64(TestBatch *batch)
-{
+test_To_F64(TestBatch *batch) {
CharBuf *charbuf = S_get_cb("1.5");
double difference = 1.5 - CB_To_F64(charbuf);
if (difference < 0) { difference = 0 - difference; }
@@ -225,15 +215,14 @@ test_To_F64(TestBatch *batch)
double value_full = CB_To_F64(charbuf);
CB_Set_Size(charbuf, 3);
double value_short = CB_To_F64(charbuf);
- TEST_TRUE(batch, value_short < value_full,
- "TO_F64 doesn't run past end of string");
+ TEST_TRUE(batch, value_short < value_full,
+ "TO_F64 doesn't run past end of string");
DECREF(charbuf);
}
static void
-test_To_I64(TestBatch *batch)
-{
+test_To_I64(TestBatch *batch) {
CharBuf *charbuf = S_get_cb("10");
TEST_TRUE(batch, CB_To_I64(charbuf) == 10, "To_I64");
CB_setf(charbuf, "-10");
@@ -243,8 +232,7 @@ test_To_I64(TestBatch *batch)
static void
-test_vcatf_s(TestBatch *batch)
-{
+test_vcatf_s(TestBatch *batch) {
CharBuf *wanted = S_get_cb("foo bar bizzle baz");
CharBuf *got = S_get_cb("foo ");
CB_catf(got, "bar %s baz", "bizzle");
@@ -254,8 +242,7 @@ test_vcatf_s(TestBatch *batch)
}
static void
-test_vcatf_null_string(TestBatch *batch)
-{
+test_vcatf_null_string(TestBatch *batch) {
CharBuf *wanted = S_get_cb("foo bar [NULL] baz");
CharBuf *got = S_get_cb("foo ");
CB_catf(got, "bar %s baz", NULL);
@@ -265,8 +252,7 @@ test_vcatf_null_string(TestBatch *batch)
}
static void
-test_vcatf_cb(TestBatch *batch)
-{
+test_vcatf_cb(TestBatch *batch) {
CharBuf *wanted = S_get_cb("foo bar ZEKE baz");
CharBuf *catworthy = S_get_cb("ZEKE");
CharBuf *got = S_get_cb("foo ");
@@ -278,8 +264,7 @@ test_vcatf_cb(TestBatch *batch)
}
static void
-test_vcatf_obj(TestBatch *batch)
-{
+test_vcatf_obj(TestBatch *batch) {
CharBuf *wanted = S_get_cb("ooga 20 booga");
Integer32 *i32 = Int32_new(20);
CharBuf *got = S_get_cb("ooga");
@@ -291,8 +276,7 @@ test_vcatf_obj(TestBatch *batch)
}
static void
-test_vcatf_null_obj(TestBatch *batch)
-{
+test_vcatf_null_obj(TestBatch *batch) {
CharBuf *wanted = S_get_cb("foo bar [NULL] baz");
CharBuf *got = S_get_cb("foo ");
CB_catf(got, "bar %o baz", NULL);
@@ -302,8 +286,7 @@ test_vcatf_null_obj(TestBatch *batch)
}
static void
-test_vcatf_i8(TestBatch *batch)
-{
+test_vcatf_i8(TestBatch *batch) {
CharBuf *wanted = S_get_cb("foo bar -3 baz");
int8_t num = -3;
CharBuf *got = S_get_cb("foo ");
@@ -314,8 +297,7 @@ test_vcatf_i8(TestBatch *batch)
}
static void
-test_vcatf_i32(TestBatch *batch)
-{
+test_vcatf_i32(TestBatch *batch) {
CharBuf *wanted = S_get_cb("foo bar -100000 baz");
int32_t num = -100000;
CharBuf *got = S_get_cb("foo ");
@@ -326,8 +308,7 @@ test_vcatf_i32(TestBatch *batch)
}
static void
-test_vcatf_i64(TestBatch *batch)
-{
+test_vcatf_i64(TestBatch *batch) {
CharBuf *wanted = S_get_cb("foo bar -5000000000 baz");
int64_t num = I64_C(-5000000000);
CharBuf *got = S_get_cb("foo ");
@@ -338,8 +319,7 @@ test_vcatf_i64(TestBatch *batch)
}
static void
-test_vcatf_u8(TestBatch *batch)
-{
+test_vcatf_u8(TestBatch *batch) {
CharBuf *wanted = S_get_cb("foo bar 3 baz");
uint8_t num = 3;
CharBuf *got = S_get_cb("foo ");
@@ -350,8 +330,7 @@ test_vcatf_u8(TestBatch *batch)
}
static void
-test_vcatf_u32(TestBatch *batch)
-{
+test_vcatf_u32(TestBatch *batch) {
CharBuf *wanted = S_get_cb("foo bar 100000 baz");
uint32_t num = 100000;
CharBuf *got = S_get_cb("foo ");
@@ -362,8 +341,7 @@ test_vcatf_u32(TestBatch *batch)
}
static void
-test_vcatf_u64(TestBatch *batch)
-{
+test_vcatf_u64(TestBatch *batch) {
CharBuf *wanted = S_get_cb("foo bar 5000000000 baz");
uint64_t num = U64_C(5000000000);
CharBuf *got = S_get_cb("foo ");
@@ -374,8 +352,7 @@ test_vcatf_u64(TestBatch *batch)
}
static void
-test_vcatf_f64(TestBatch *batch)
-{
+test_vcatf_f64(TestBatch *batch) {
CharBuf *wanted;
char buf[64];
float num = 1.3f;
@@ -389,8 +366,7 @@ test_vcatf_f64(TestBatch *batch)
}
static void
-test_vcatf_x32(TestBatch *batch)
-{
+test_vcatf_x32(TestBatch *batch) {
CharBuf *wanted;
char buf[64];
unsigned long num = I32_MAX;
@@ -408,19 +384,17 @@ test_vcatf_x32(TestBatch *batch)
}
static void
-test_serialization(TestBatch *batch)
-{
+test_serialization(TestBatch *batch) {
CharBuf *wanted = S_get_cb("foo");
CharBuf *got = (CharBuf*)TestUtils_freeze_thaw((Obj*)wanted);
- TEST_TRUE(batch, got && CB_Equals(wanted, (Obj*)got),
- "Round trip through FREEZE/THAW");
+ TEST_TRUE(batch, got && CB_Equals(wanted, (Obj*)got),
+ "Round trip through FREEZE/THAW");
DECREF(got);
DECREF(wanted);
}
void
-TestCB_run_tests()
-{
+TestCB_run_tests() {
TestBatch *batch = TestBatch_new(55);
TestBatch_Plan(batch);
Modified: incubator/lucy/trunk/core/Lucy/Test/Object/TestHash.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Test/Object/TestHash.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Test/Object/TestHash.c (original)
+++ incubator/lucy/trunk/core/Lucy/Test/Object/TestHash.c Sun May 1 23:50:24 2011
@@ -24,8 +24,7 @@
#include "Lucy/Object/Hash.h"
static CharBuf*
-S_random_string()
-{
+S_random_string() {
uint32_t len = rand() % 1200;
CharBuf *string = CB_new(len * 3);
@@ -50,34 +49,32 @@ S_random_string()
}
static void
-test_Equals(TestBatch *batch)
-{
+test_Equals(TestBatch *batch) {
Hash *hash = Hash_new(0);
Hash *other = Hash_new(0);
ZombieCharBuf *stuff = ZCB_WRAP_STR("stuff", 5);
- TEST_TRUE(batch, Hash_Equals(hash, (Obj*)other),
- "Empty hashes are equal");
+ TEST_TRUE(batch, Hash_Equals(hash, (Obj*)other),
+ "Empty hashes are equal");
Hash_Store_Str(hash, "foo", 3, INCREF(&EMPTY));
- TEST_FALSE(batch, Hash_Equals(hash, (Obj*)other),
- "Add one pair and Equals returns false");
+ TEST_FALSE(batch, Hash_Equals(hash, (Obj*)other),
+ "Add one pair and Equals returns false");
Hash_Store_Str(other, "foo", 3, INCREF(&EMPTY));
- TEST_TRUE(batch, Hash_Equals(hash, (Obj*)other),
- "Add a matching pair and Equals returns true");
+ TEST_TRUE(batch, Hash_Equals(hash, (Obj*)other),
+ "Add a matching pair and Equals returns true");
Hash_Store_Str(other, "foo", 3, INCREF(stuff));
- TEST_FALSE(batch, Hash_Equals(hash, (Obj*)other),
- "Non-matching value spoils Equals");
+ TEST_FALSE(batch, Hash_Equals(hash, (Obj*)other),
+ "Non-matching value spoils Equals");
DECREF(hash);
DECREF(other);
}
static void
-test_Store_and_Fetch(TestBatch *batch)
-{
+test_Store_and_Fetch(TestBatch *batch) {
Hash *hash = Hash_new(100);
Hash *dupe = Hash_new(100);
const uint32_t starting_cap = Hash_Get_Capacity(hash);
@@ -96,8 +93,8 @@ test_Store_and_Fetch(TestBatch *batch)
}
TEST_TRUE(batch, Hash_Equals(hash, (Obj*)dupe), "Equals");
- TEST_INT_EQ(batch, Hash_Get_Capacity(hash), starting_cap,
- "Initial capacity sufficient (no rebuilds)");
+ TEST_INT_EQ(batch, Hash_Get_Capacity(hash), starting_cap,
+ "Initial capacity sufficient (no rebuilds)");
for (i = 0; i < 100; i++) {
Obj *key = VA_Fetch(expected, i);
@@ -105,31 +102,31 @@ test_Store_and_Fetch(TestBatch *batch)
VA_Push(got, (Obj*)INCREF(elem));
}
- TEST_TRUE(batch, VA_Equals(got, (Obj*)expected),
- "basic Store and Fetch");
- TEST_INT_EQ(batch, Hash_Get_Size(hash), 100,
- "size incremented properly by Hash_Store");
+ TEST_TRUE(batch, VA_Equals(got, (Obj*)expected),
+ "basic Store and Fetch");
+ TEST_INT_EQ(batch, Hash_Get_Size(hash), 100,
+ "size incremented properly by Hash_Store");
- TEST_TRUE(batch, Hash_Fetch(hash, (Obj*)foo) == NULL,
- "Fetch against non-existent key returns NULL");
+ TEST_TRUE(batch, Hash_Fetch(hash, (Obj*)foo) == NULL,
+ "Fetch against non-existent key returns NULL");
Hash_Store(hash, (Obj*)forty, INCREF(foo));
TEST_TRUE(batch, ZCB_Equals(foo, Hash_Fetch(hash, (Obj*)forty)),
- "Hash_Store replaces existing value");
- TEST_FALSE(batch, Hash_Equals(hash, (Obj*)dupe),
- "replacement value spoils equals");
- TEST_INT_EQ(batch, Hash_Get_Size(hash), 100,
- "size unaffected after value replaced");
+ "Hash_Store replaces existing value");
+ TEST_FALSE(batch, Hash_Equals(hash, (Obj*)dupe),
+ "replacement value spoils equals");
+ TEST_INT_EQ(batch, Hash_Get_Size(hash), 100,
+ "size unaffected after value replaced");
- TEST_TRUE(batch, Hash_Delete(hash, (Obj*)forty) == (Obj*)foo,
- "Delete returns value");
+ TEST_TRUE(batch, Hash_Delete(hash, (Obj*)forty) == (Obj*)foo,
+ "Delete returns value");
DECREF(foo);
- TEST_INT_EQ(batch, Hash_Get_Size(hash), 99,
- "size decremented by successful Delete");
- TEST_TRUE(batch, Hash_Delete(hash, (Obj*)forty) == NULL,
- "Delete returns NULL when key not found");
- TEST_INT_EQ(batch, Hash_Get_Size(hash), 99,
- "size not decremented by unsuccessful Delete");
+ TEST_INT_EQ(batch, Hash_Get_Size(hash), 99,
+ "size decremented by successful Delete");
+ TEST_TRUE(batch, Hash_Delete(hash, (Obj*)forty) == NULL,
+ "Delete returns NULL when key not found");
+ TEST_INT_EQ(batch, Hash_Get_Size(hash), 99,
+ "size not decremented by unsuccessful Delete");
DECREF(Hash_Delete(dupe, (Obj*)forty));
TEST_TRUE(batch, VA_Equals(got, (Obj*)expected), "Equals after Delete");
@@ -144,11 +141,10 @@ test_Store_and_Fetch(TestBatch *batch)
}
static void
-test_Keys_Values_Iter(TestBatch *batch)
-{
+test_Keys_Values_Iter(TestBatch *batch) {
uint32_t i;
- Hash *hash = Hash_new(0); // trigger multiple rebuilds.
- VArray *expected = VA_new(100);
+ Hash *hash = Hash_new(0); // trigger multiple rebuilds.
+ VArray *expected = VA_new(100);
VArray *keys;
VArray *values;
@@ -168,7 +164,7 @@ test_Keys_Values_Iter(TestBatch *batch)
TEST_TRUE(batch, VA_Equals(values, (Obj*)expected), "Values");
VA_Clear(keys);
VA_Clear(values);
-
+
{
Obj *key;
Obj *value;
@@ -190,8 +186,8 @@ test_Keys_Values_Iter(TestBatch *batch)
Obj *key = Hash_Find_Key(hash, (Obj*)forty, ZCB_Hash_Sum(forty));
TEST_TRUE(batch, Obj_Equals(key, (Obj*)forty), "Find_Key");
key = Hash_Find_Key(hash, (Obj*)nope, ZCB_Hash_Sum(nope)),
- TEST_TRUE(batch, key == NULL,
- "Find_Key returns NULL for non-existent key");
+ TEST_TRUE(batch, key == NULL,
+ "Find_Key returns NULL for non-existent key");
}
DECREF(hash);
@@ -201,18 +197,17 @@ test_Keys_Values_Iter(TestBatch *batch)
}
static void
-test_Dump_and_Load(TestBatch *batch)
-{
+test_Dump_and_Load(TestBatch *batch) {
Hash *hash = Hash_new(0);
Obj *dump;
Hash *loaded;
Hash_Store_Str(hash, "foo", 3,
- (Obj*)CB_new_from_trusted_utf8("foo", 3));
+ (Obj*)CB_new_from_trusted_utf8("foo", 3));
dump = (Obj*)Hash_Dump(hash);
loaded = (Hash*)Obj_Load(dump, dump);
- TEST_TRUE(batch, Hash_Equals(hash, (Obj*)loaded),
- "Dump => Load round trip");
+ TEST_TRUE(batch, Hash_Equals(hash, (Obj*)loaded),
+ "Dump => Load round trip");
DECREF(dump);
DECREF(loaded);
@@ -223,8 +218,8 @@ test_Dump_and_Load(TestBatch *batch)
dump = (Obj*)Hash_Dump(hash);
loaded = (Hash*)Obj_Load(dump, dump);
- TEST_TRUE(batch, Hash_Equals(hash, (Obj*)loaded),
- "Load still works with _class if it's not a real class");
+ TEST_TRUE(batch, Hash_Equals(hash, (Obj*)loaded),
+ "Load still works with _class if it's not a real class");
DECREF(dump);
DECREF(loaded);
@@ -234,9 +229,8 @@ test_Dump_and_Load(TestBatch *batch)
}
static void
-test_serialization(TestBatch *batch)
-{
- Hash *wanted = Hash_new(0);
+test_serialization(TestBatch *batch) {
+ Hash *wanted = Hash_new(0);
Hash *got;
uint32_t i;
@@ -248,19 +242,18 @@ test_serialization(TestBatch *batch)
}
got = (Hash*)TestUtils_freeze_thaw((Obj*)wanted);
- TEST_TRUE(batch, got && Hash_Equals(wanted, (Obj*)got),
- "Round trip through serialization.");
+ TEST_TRUE(batch, got && Hash_Equals(wanted, (Obj*)got),
+ "Round trip through serialization.");
DECREF(got);
DECREF(wanted);
}
static void
-test_stress(TestBatch *batch)
-{
+test_stress(TestBatch *batch) {
uint32_t i;
- Hash *hash = Hash_new(0); // trigger multiple rebuilds.
- VArray *expected = VA_new(1000);
+ Hash *hash = Hash_new(0); // trigger multiple rebuilds.
+ VArray *expected = VA_new(1000);
VArray *keys;
VArray *values;
@@ -296,8 +289,7 @@ test_stress(TestBatch *batch)
}
void
-TestHash_run_tests()
-{
+TestHash_run_tests() {
TestBatch *batch = TestBatch_new(29);
srand((unsigned int)time((time_t*)NULL));
Modified: incubator/lucy/trunk/core/Lucy/Test/Object/TestI32Array.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Test/Object/TestI32Array.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Test/Object/TestI32Array.c (original)
+++ incubator/lucy/trunk/core/Lucy/Test/Object/TestI32Array.c Sun May 1 23:50:24 2011
@@ -24,8 +24,7 @@ static int32_t source_ints[] = { -1, 0,
static size_t num_ints = sizeof(source_ints) / sizeof(int32_t);
static void
-test_all(TestBatch *batch)
-{
+test_all(TestBatch *batch) {
I32Array *i32_array = I32Arr_new(source_ints, num_ints);
int32_t *ints_copy = (int32_t*)malloc(num_ints * sizeof(int32_t));
I32Array *stolen = I32Arr_new_steal(ints_copy, num_ints);
@@ -34,33 +33,32 @@ test_all(TestBatch *batch)
memcpy(ints_copy, source_ints, num_ints * sizeof(int32_t));
TEST_TRUE(batch, I32Arr_Get_Size(i32_array) == num_ints,
- "Get_Size");
+ "Get_Size");
TEST_TRUE(batch, I32Arr_Get_Size(stolen) == num_ints,
- "Get_Size for stolen");
+ "Get_Size for stolen");
for (num_matched = 0; num_matched < num_ints; num_matched++) {
if (source_ints[num_matched] != I32Arr_Get(i32_array, num_matched)) {
- break;
+ break;
}
}
- TEST_INT_EQ(batch, num_matched, num_ints,
- "Matched all source ints with Get()");
+ TEST_INT_EQ(batch, num_matched, num_ints,
+ "Matched all source ints with Get()");
for (num_matched = 0; num_matched < num_ints; num_matched++) {
- if (source_ints[num_matched] != I32Arr_Get(stolen, num_matched)) {
- break;
+ if (source_ints[num_matched] != I32Arr_Get(stolen, num_matched)) {
+ break;
}
}
- TEST_INT_EQ(batch, num_matched, num_ints,
- "Matched all source ints in stolen I32Array with Get()");
+ TEST_INT_EQ(batch, num_matched, num_ints,
+ "Matched all source ints in stolen I32Array with Get()");
DECREF(i32_array);
DECREF(stolen);
}
void
-TestI32Arr_run_tests()
-{
+TestI32Arr_run_tests() {
TestBatch *batch = TestBatch_new(4);
TestBatch_Plan(batch);
Modified: incubator/lucy/trunk/core/Lucy/Test/Object/TestLockFreeRegistry.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Test/Object/TestLockFreeRegistry.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Test/Object/TestLockFreeRegistry.c (original)
+++ incubator/lucy/trunk/core/Lucy/Test/Object/TestLockFreeRegistry.c Sun May 1 23:50:24 2011
@@ -24,42 +24,39 @@
#include "Lucy/Object/LockFreeRegistry.h"
StupidHashCharBuf*
-StupidHashCharBuf_new(char *text)
-{
+StupidHashCharBuf_new(char *text) {
return (StupidHashCharBuf*)CB_new_from_utf8(text, strlen(text));
}
int32_t
-StupidHashCharBuf_hash_sum(StupidHashCharBuf *self)
-{
+StupidHashCharBuf_hash_sum(StupidHashCharBuf *self) {
UNUSED_VAR(self);
return 1;
}
static void
-test_all(TestBatch *batch)
-{
+test_all(TestBatch *batch) {
LockFreeRegistry *registry = LFReg_new(10);
StupidHashCharBuf *foo = StupidHashCharBuf_new("foo");
StupidHashCharBuf *bar = StupidHashCharBuf_new("bar");
StupidHashCharBuf *baz = StupidHashCharBuf_new("baz");
StupidHashCharBuf *foo_dupe = StupidHashCharBuf_new("foo");
- TEST_TRUE(batch, LFReg_Register(registry, (Obj*)foo, (Obj*)foo),
- "Register() returns true on success");
- TEST_FALSE(batch,
- LFReg_Register(registry, (Obj*)foo_dupe, (Obj*)foo_dupe),
- "Can't Register() keys that test equal");
-
- TEST_TRUE(batch, LFReg_Register(registry, (Obj*)bar, (Obj*)bar),
- "Register() key with the same Hash_Sum but that isn't Equal");
-
- TEST_TRUE(batch, LFReg_Fetch(registry, (Obj*)foo_dupe) == (Obj*)foo,
- "Fetch()");
- TEST_TRUE(batch, LFReg_Fetch(registry, (Obj*)bar) == (Obj*)bar,
- "Fetch() again");
+ TEST_TRUE(batch, LFReg_Register(registry, (Obj*)foo, (Obj*)foo),
+ "Register() returns true on success");
+ TEST_FALSE(batch,
+ LFReg_Register(registry, (Obj*)foo_dupe, (Obj*)foo_dupe),
+ "Can't Register() keys that test equal");
+
+ TEST_TRUE(batch, LFReg_Register(registry, (Obj*)bar, (Obj*)bar),
+ "Register() key with the same Hash_Sum but that isn't Equal");
+
+ TEST_TRUE(batch, LFReg_Fetch(registry, (Obj*)foo_dupe) == (Obj*)foo,
+ "Fetch()");
+ TEST_TRUE(batch, LFReg_Fetch(registry, (Obj*)bar) == (Obj*)bar,
+ "Fetch() again");
TEST_TRUE(batch, LFReg_Fetch(registry, (Obj*)baz) == NULL,
- "Fetch() non-existent key returns NULL");
+ "Fetch() non-existent key returns NULL");
DECREF(foo_dupe);
DECREF(baz);
@@ -69,8 +66,7 @@ test_all(TestBatch *batch)
}
void
-TestLFReg_run_tests()
-{
+TestLFReg_run_tests() {
TestBatch *batch = TestBatch_new(6);
TestBatch_Plan(batch);