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 [19/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/Search/TestRangeQuery.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Test/Search/TestRangeQuery.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Test/Search/TestRangeQuery.c (original)
+++ incubator/lucy/trunk/core/Lucy/Test/Search/TestRangeQuery.c Sun May 1 23:50:24 2011
@@ -24,31 +24,30 @@
#include "Lucy/Search/RangeQuery.h"
static void
-test_Dump_Load_and_Equals(TestBatch *batch)
-{
- RangeQuery *query = TestUtils_make_range_query("content", "foo", "phooey",
- true, true);
- RangeQuery *lo_term_differs = TestUtils_make_range_query("content",
- "goo", "phooey", true, true);
- RangeQuery *hi_term_differs = TestUtils_make_range_query("content",
- "foo", "gooey", true, true);
- RangeQuery *include_lower_differs = TestUtils_make_range_query("content",
- "foo", "phooey", false, true);
- RangeQuery *include_upper_differs = TestUtils_make_range_query("content",
- "foo", "phooey", true, false);
+test_Dump_Load_and_Equals(TestBatch *batch) {
+ RangeQuery *query
+ = TestUtils_make_range_query("content", "foo", "phooey", true, true);
+ RangeQuery *lo_term_differs
+ = TestUtils_make_range_query("content", "goo", "phooey", true, true);
+ RangeQuery *hi_term_differs
+ = TestUtils_make_range_query("content", "foo", "gooey", true, true);
+ RangeQuery *include_lower_differs
+ = TestUtils_make_range_query("content", "foo", "phooey", false, true);
+ RangeQuery *include_upper_differs
+ = TestUtils_make_range_query("content", "foo", "phooey", true, false);
Obj *dump = (Obj*)RangeQuery_Dump(query);
RangeQuery *clone = (RangeQuery*)RangeQuery_Load(lo_term_differs, dump);
TEST_FALSE(batch, RangeQuery_Equals(query, (Obj*)lo_term_differs),
- "Equals() false with different lower term");
+ "Equals() false with different lower term");
TEST_FALSE(batch, RangeQuery_Equals(query, (Obj*)hi_term_differs),
- "Equals() false with different upper term");
+ "Equals() false with different upper term");
TEST_FALSE(batch, RangeQuery_Equals(query, (Obj*)include_lower_differs),
- "Equals() false with different include_lower");
+ "Equals() false with different include_lower");
TEST_FALSE(batch, RangeQuery_Equals(query, (Obj*)include_upper_differs),
- "Equals() false with different include_upper");
- TEST_TRUE(batch, RangeQuery_Equals(query, (Obj*)clone),
- "Dump => Load round trip");
+ "Equals() false with different include_upper");
+ TEST_TRUE(batch, RangeQuery_Equals(query, (Obj*)clone),
+ "Dump => Load round trip");
DECREF(query);
DECREF(lo_term_differs);
@@ -61,8 +60,7 @@ test_Dump_Load_and_Equals(TestBatch *bat
void
-TestRangeQuery_run_tests()
-{
+TestRangeQuery_run_tests() {
TestBatch *batch = TestBatch_new(5);
TestBatch_Plan(batch);
test_Dump_Load_and_Equals(batch);
Modified: incubator/lucy/trunk/core/Lucy/Test/Search/TestReqOptQuery.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Test/Search/TestReqOptQuery.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Test/Search/TestReqOptQuery.c (original)
+++ incubator/lucy/trunk/core/Lucy/Test/Search/TestReqOptQuery.c Sun May 1 23:50:24 2011
@@ -25,8 +25,7 @@
#include "Lucy/Search/LeafQuery.h"
static void
-test_Dump_Load_and_Equals(TestBatch *batch)
-{
+test_Dump_Load_and_Equals(TestBatch *batch) {
Query *a_leaf = (Query*)TestUtils_make_leaf_query(NULL, "a");
Query *b_leaf = (Query*)TestUtils_make_leaf_query(NULL, "b");
Query *c_leaf = (Query*)TestUtils_make_leaf_query(NULL, "c");
@@ -34,18 +33,18 @@ test_Dump_Load_and_Equals(TestBatch *bat
RequiredOptionalQuery *kids_differ = ReqOptQuery_new(a_leaf, c_leaf);
RequiredOptionalQuery *boost_differs = ReqOptQuery_new(a_leaf, b_leaf);
Obj *dump = (Obj*)ReqOptQuery_Dump(query);
- RequiredOptionalQuery *clone
+ RequiredOptionalQuery *clone
= (RequiredOptionalQuery*)Obj_Load(dump, dump);
- TEST_FALSE(batch, ReqOptQuery_Equals(query, (Obj*)kids_differ),
- "Different kids spoil Equals");
- TEST_TRUE(batch, ReqOptQuery_Equals(query, (Obj*)boost_differs),
- "Equals with identical boosts");
+ TEST_FALSE(batch, ReqOptQuery_Equals(query, (Obj*)kids_differ),
+ "Different kids spoil Equals");
+ TEST_TRUE(batch, ReqOptQuery_Equals(query, (Obj*)boost_differs),
+ "Equals with identical boosts");
ReqOptQuery_Set_Boost(boost_differs, 1.5);
- TEST_FALSE(batch, ReqOptQuery_Equals(query, (Obj*)boost_differs),
- "Different boost spoils Equals");
- TEST_TRUE(batch, ReqOptQuery_Equals(query, (Obj*)clone),
- "Dump => Load round trip");
+ TEST_FALSE(batch, ReqOptQuery_Equals(query, (Obj*)boost_differs),
+ "Different boost spoils Equals");
+ TEST_TRUE(batch, ReqOptQuery_Equals(query, (Obj*)clone),
+ "Dump => Load round trip");
DECREF(a_leaf);
DECREF(b_leaf);
@@ -58,8 +57,7 @@ test_Dump_Load_and_Equals(TestBatch *bat
}
void
-TestReqOptQuery_run_tests()
-{
+TestReqOptQuery_run_tests() {
TestBatch *batch = TestBatch_new(4);
TestBatch_Plan(batch);
test_Dump_Load_and_Equals(batch);
Modified: incubator/lucy/trunk/core/Lucy/Test/Search/TestSeriesMatcher.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Test/Search/TestSeriesMatcher.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Test/Search/TestSeriesMatcher.c (original)
+++ incubator/lucy/trunk/core/Lucy/Test/Search/TestSeriesMatcher.c Sun May 1 23:50:24 2011
@@ -24,8 +24,7 @@
#include "Lucy/Search/SeriesMatcher.h"
static SeriesMatcher*
-S_make_series_matcher(I32Array *doc_ids, I32Array *offsets, int32_t doc_max)
-{
+S_make_series_matcher(I32Array *doc_ids, I32Array *offsets, int32_t doc_max) {
int32_t num_doc_ids = I32Arr_Get_Size(doc_ids);
int32_t num_matchers = I32Arr_Get_Size(offsets);
VArray *matchers = VA_new(num_matchers);
@@ -36,8 +35,8 @@ S_make_series_matcher(I32Array *doc_ids,
for (i = 0; i < num_matchers; i++) {
int32_t offset = I32Arr_Get(offsets, i);
int32_t max = i == num_matchers - 1
- ? doc_max + 1
- : I32Arr_Get(offsets, i + 1);
+ ? doc_max + 1
+ : I32Arr_Get(offsets, i + 1);
BitVector *bit_vec = BitVec_new(max - offset);
while (tick < num_doc_ids) {
int32_t doc_id = I32Arr_Get(doc_ids, tick);
@@ -57,14 +56,13 @@ S_make_series_matcher(I32Array *doc_ids,
}
static I32Array*
-S_generate_match_list(int32_t first, int32_t max, int32_t doc_inc)
-{
+S_generate_match_list(int32_t first, int32_t max, int32_t doc_inc) {
int32_t count = (int32_t)ceil(((float)max - first) / doc_inc);
int32_t *doc_ids = (int32_t*)MALLOCATE(count * sizeof(int32_t));
int32_t doc_id = first;
- int32_t i = 0;
+ int32_t i = 0;
- for ( ; doc_id < max; doc_id += doc_inc, i++) {
+ for (; doc_id < max; doc_id += doc_inc, i++) {
doc_ids[i] = doc_id;
}
if (i != count) { THROW(ERR, "Screwed up somehow: %i32 %i32", i, count); }
@@ -73,10 +71,9 @@ S_generate_match_list(int32_t first, int
}
static void
-S_do_test_matrix(TestBatch *batch, int32_t doc_max, int32_t first_doc_id,
- int32_t doc_inc, int32_t offset_inc)
-{
- I32Array *doc_ids
+S_do_test_matrix(TestBatch *batch, int32_t doc_max, int32_t first_doc_id,
+ int32_t doc_inc, int32_t offset_inc) {
+ I32Array *doc_ids
= S_generate_match_list(first_doc_id, doc_max, doc_inc);
I32Array *offsets
= S_generate_match_list(0, doc_max, offset_inc);
@@ -90,8 +87,8 @@ S_do_test_matrix(TestBatch *batch, int32
num_in_agreement++;
}
TEST_INT_EQ(batch, num_in_agreement, I32Arr_Get_Size(doc_ids),
- "doc_max=%d first_doc_id=%d doc_inc=%d offset_inc=%d",
- doc_max, first_doc_id, doc_inc, offset_inc);
+ "doc_max=%d first_doc_id=%d doc_inc=%d offset_inc=%d",
+ doc_max, first_doc_id, doc_inc, offset_inc);
DECREF(doc_ids);
DECREF(offsets);
@@ -99,10 +96,9 @@ S_do_test_matrix(TestBatch *batch, int32
}
static void
-test_matrix(TestBatch *batch)
-{
- int32_t doc_max_nums[] = { 10, 100, 1000, 0 };
- int32_t first_doc_ids[] = { 1, 2, 10, 0 };
+test_matrix(TestBatch *batch) {
+ int32_t doc_max_nums[] = { 10, 100, 1000, 0 };
+ int32_t first_doc_ids[] = { 1, 2, 10, 0 };
int32_t doc_inc_nums[] = { 20, 13, 9, 4, 2, 0 };
int32_t offset_inc_nums[] = { 7, 29, 71, 0 };
int32_t a, b, c, d;
@@ -110,17 +106,17 @@ test_matrix(TestBatch *batch)
for (a = 0; doc_max_nums[a] != 0; a++) {
for (b = 0; first_doc_ids[b] != 0; b++) {
for (c = 0; doc_inc_nums[c] != 0; c++) {
- for(d = 0; offset_inc_nums[d] != 0; d++) {
+ for (d = 0; offset_inc_nums[d] != 0; d++) {
int32_t doc_max = doc_max_nums[a];
int32_t first_doc_id = first_doc_ids[b];
int32_t doc_inc = doc_inc_nums[c];
int32_t offset_inc = offset_inc_nums[d];
- if (first_doc_id > doc_max) {
- continue;
+ if (first_doc_id > doc_max) {
+ continue;
}
else {
- S_do_test_matrix(batch, doc_max, first_doc_id,
- doc_inc, offset_inc);
+ S_do_test_matrix(batch, doc_max, first_doc_id,
+ doc_inc, offset_inc);
}
}
}
@@ -129,8 +125,7 @@ test_matrix(TestBatch *batch)
}
void
-TestSeriesMatcher_run_tests()
-{
+TestSeriesMatcher_run_tests() {
TestBatch *batch = TestBatch_new(135);
TestBatch_Plan(batch);
test_matrix(batch);
Modified: incubator/lucy/trunk/core/Lucy/Test/Search/TestTermQuery.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Test/Search/TestTermQuery.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Test/Search/TestTermQuery.c (original)
+++ incubator/lucy/trunk/core/Lucy/Test/Search/TestTermQuery.c Sun May 1 23:50:24 2011
@@ -24,8 +24,7 @@
#include "Lucy/Search/TermQuery.h"
static void
-test_Dump_Load_and_Equals(TestBatch *batch)
-{
+test_Dump_Load_and_Equals(TestBatch *batch) {
TermQuery *query = TestUtils_make_term_query("content", "foo");
TermQuery *field_differs = TestUtils_make_term_query("stuff", "foo");
TermQuery *term_differs = TestUtils_make_term_query("content", "bar");
@@ -34,14 +33,14 @@ test_Dump_Load_and_Equals(TestBatch *bat
TermQuery *clone = (TermQuery*)TermQuery_Load(term_differs, dump);
TEST_FALSE(batch, TermQuery_Equals(query, (Obj*)field_differs),
- "Equals() false with different field");
+ "Equals() false with different field");
TEST_FALSE(batch, TermQuery_Equals(query, (Obj*)term_differs),
- "Equals() false with different term");
+ "Equals() false with different term");
TermQuery_Set_Boost(boost_differs, 0.5);
TEST_FALSE(batch, TermQuery_Equals(query, (Obj*)boost_differs),
- "Equals() false with different boost");
- TEST_TRUE(batch, TermQuery_Equals(query, (Obj*)clone),
- "Dump => Load round trip");
+ "Equals() false with different boost");
+ TEST_TRUE(batch, TermQuery_Equals(query, (Obj*)clone),
+ "Dump => Load round trip");
DECREF(query);
DECREF(term_differs);
@@ -52,8 +51,7 @@ test_Dump_Load_and_Equals(TestBatch *bat
}
void
-TestTermQuery_run_tests()
-{
+TestTermQuery_run_tests() {
TestBatch *batch = TestBatch_new(4);
TestBatch_Plan(batch);
test_Dump_Load_and_Equals(batch);
Modified: incubator/lucy/trunk/core/Lucy/Test/Store/MockFileHandle.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Test/Store/MockFileHandle.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Test/Store/MockFileHandle.c (original)
+++ incubator/lucy/trunk/core/Lucy/Test/Store/MockFileHandle.c Sun May 1 23:50:24 2011
@@ -22,46 +22,41 @@
#include "Lucy/Store/FileWindow.h"
MockFileHandle*
-MockFileHandle_new(const CharBuf *path, int64_t length)
-{
+MockFileHandle_new(const CharBuf *path, int64_t length) {
MockFileHandle *self = (MockFileHandle*)VTable_Make_Obj(MOCKFILEHANDLE);
return MockFileHandle_init(self, path, length);
}
MockFileHandle*
-MockFileHandle_init(MockFileHandle *self, const CharBuf *path, int64_t length)
-{
+MockFileHandle_init(MockFileHandle *self, const CharBuf *path,
+ int64_t length) {
FH_do_open((FileHandle*)self, path, 0);
self->len = length;
return self;
}
bool_t
-MockFileHandle_window(MockFileHandle *self, FileWindow *window, int64_t offset,
- int64_t len)
-{
+MockFileHandle_window(MockFileHandle *self, FileWindow *window,
+ int64_t offset, int64_t len) {
UNUSED_VAR(self);
FileWindow_Set_Window(window, NULL, offset, len);
return true;
}
bool_t
-MockFileHandle_release_window(MockFileHandle *self, FileWindow *window)
-{
+MockFileHandle_release_window(MockFileHandle *self, FileWindow *window) {
UNUSED_VAR(self);
FileWindow_Set_Window(window, NULL, 0, 0);
return true;
}
int64_t
-MockFileHandle_length(MockFileHandle *self)
-{
+MockFileHandle_length(MockFileHandle *self) {
return self->len;
}
bool_t
-MockFileHandle_close(MockFileHandle *self)
-{
+MockFileHandle_close(MockFileHandle *self) {
UNUSED_VAR(self);
return true;
}
Modified: incubator/lucy/trunk/core/Lucy/Test/Store/MockFileHandle.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Test/Store/MockFileHandle.cfh?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Test/Store/MockFileHandle.cfh (original)
+++ incubator/lucy/trunk/core/Lucy/Test/Store/MockFileHandle.cfh Sun May 1 23:50:24 2011
@@ -31,7 +31,7 @@ class Lucy::Store::MockFileHandle inheri
bool_t
Window(MockFileHandle *self, FileWindow *window, int64_t offset, int64_t len);
- bool_t
+ bool_t
Release_Window(MockFileHandle *self, FileWindow *window);
int64_t
Modified: incubator/lucy/trunk/core/Lucy/Test/Store/TestCompoundFileReader.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Test/Store/TestCompoundFileReader.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Test/Store/TestCompoundFileReader.c (original)
+++ incubator/lucy/trunk/core/Lucy/Test/Store/TestCompoundFileReader.c Sun May 1 23:50:24 2011
@@ -36,8 +36,7 @@ static ZombieCharBuf baz = ZCB_L
static ZombieCharBuf stuff = ZCB_LITERAL("stuff");
static Folder*
-S_folder_with_contents()
-{
+S_folder_with_contents() {
ZombieCharBuf seg_1 = ZCB_LITERAL("seg_1");
RAMFolder *folder = RAMFolder_new((CharBuf*)&seg_1);
OutStream *foo_out = RAMFolder_Open_Out(folder, (CharBuf*)&foo);
@@ -53,8 +52,7 @@ S_folder_with_contents()
}
static void
-test_open(TestBatch *batch)
-{
+test_open(TestBatch *batch) {
Folder *real_folder;
CompoundFileReader *cf_reader;
Hash *metadata;
@@ -64,9 +62,9 @@ test_open(TestBatch *batch)
Folder_Delete(real_folder, (CharBuf*)&cfmeta_file);
cf_reader = CFReader_open(real_folder);
TEST_TRUE(batch, cf_reader == NULL,
- "Return NULL when cfmeta file missing");
- TEST_TRUE(batch, Err_get_error() != NULL,
- "Set Err_error when cfmeta file missing");
+ "Return NULL when cfmeta file missing");
+ TEST_TRUE(batch, Err_get_error() != NULL,
+ "Set Err_error when cfmeta file missing");
DECREF(real_folder);
Err_set_error(NULL);
@@ -74,9 +72,9 @@ test_open(TestBatch *batch)
Folder_Delete(real_folder, (CharBuf*)&cf_file);
cf_reader = CFReader_open(real_folder);
TEST_TRUE(batch, cf_reader == NULL,
- "Return NULL when cf.dat file missing");
- TEST_TRUE(batch, Err_get_error() != NULL,
- "Set Err_error when cf.dat file missing");
+ "Return NULL when cf.dat file missing");
+ TEST_TRUE(batch, Err_get_error() != NULL,
+ "Set Err_error when cf.dat file missing");
DECREF(real_folder);
Err_set_error(NULL);
@@ -87,9 +85,9 @@ test_open(TestBatch *batch)
Json_spew_json((Obj*)metadata, real_folder, (CharBuf*)&cfmeta_file);
cf_reader = CFReader_open(real_folder);
TEST_TRUE(batch, cf_reader == NULL,
- "Return NULL when format is invalid");
+ "Return NULL when format is invalid");
TEST_TRUE(batch, Err_get_error() != NULL,
- "Set Err_error when format is invalid");
+ "Set Err_error when format is invalid");
Err_set_error(NULL);
Hash_Store_Str(metadata, "format", 6, (Obj*)CB_newf("%i32", 1000));
@@ -97,9 +95,9 @@ test_open(TestBatch *batch)
Json_spew_json((Obj*)metadata, real_folder, (CharBuf*)&cfmeta_file);
cf_reader = CFReader_open(real_folder);
TEST_TRUE(batch, cf_reader == NULL,
- "Return NULL when format is too recent");
+ "Return NULL when format is too recent");
TEST_TRUE(batch, Err_get_error() != NULL,
- "Set Err_error when format too recent");
+ "Set Err_error when format too recent");
Err_set_error(NULL);
DECREF(Hash_Delete_Str(metadata, "format", 6));
@@ -107,112 +105,109 @@ test_open(TestBatch *batch)
Json_spew_json((Obj*)metadata, real_folder, (CharBuf*)&cfmeta_file);
cf_reader = CFReader_open(real_folder);
TEST_TRUE(batch, cf_reader == NULL,
- "Return NULL when format key is missing");
+ "Return NULL when format key is missing");
TEST_TRUE(batch, Err_get_error() != NULL,
- "Set Err_error when format key is missing");
+ "Set Err_error when format key is missing");
- Hash_Store_Str(metadata, "format", 6, (Obj*)CB_newf("%i32",
- CFWriter_current_file_format));
+ Hash_Store_Str(metadata, "format", 6,
+ (Obj*)CB_newf("%i32", CFWriter_current_file_format));
DECREF(Hash_Delete_Str(metadata, "files", 5));
Folder_Delete(real_folder, (CharBuf*)&cfmeta_file);
Json_spew_json((Obj*)metadata, real_folder, (CharBuf*)&cfmeta_file);
cf_reader = CFReader_open(real_folder);
TEST_TRUE(batch, cf_reader == NULL,
- "Return NULL when files key is missing");
+ "Return NULL when files key is missing");
TEST_TRUE(batch, Err_get_error() != NULL,
- "Set Err_error when files key is missing");
+ "Set Err_error when files key is missing");
DECREF(metadata);
DECREF(real_folder);
}
static void
-test_Local_MkDir_and_Find_Folder(TestBatch *batch)
-{
+test_Local_MkDir_and_Find_Folder(TestBatch *batch) {
Folder *real_folder = S_folder_with_contents();
CompoundFileReader *cf_reader = CFReader_open(real_folder);
- TEST_FALSE(batch,
- CFReader_Local_Is_Directory(cf_reader, (CharBuf*)&stuff),
- "Local_Is_Directory returns false for non-existent entry");
-
- TEST_TRUE(batch, CFReader_MkDir(cf_reader, (CharBuf*)&stuff),
- "MkDir returns true");
- TEST_TRUE(batch,
- Folder_Find_Folder(real_folder, (CharBuf*)&stuff) != NULL,
- "Local_MkDir pass-through");
- TEST_TRUE(batch,
- Folder_Find_Folder(real_folder, (CharBuf*)&stuff) ==
- CFReader_Find_Folder(cf_reader, (CharBuf*)&stuff),
- "Local_Find_Folder pass-through");
- TEST_TRUE(batch,
- CFReader_Local_Is_Directory(cf_reader, (CharBuf*)&stuff),
- "Local_Is_Directory pass through");
+ TEST_FALSE(batch,
+ CFReader_Local_Is_Directory(cf_reader, (CharBuf*)&stuff),
+ "Local_Is_Directory returns false for non-existent entry");
+
+ TEST_TRUE(batch, CFReader_MkDir(cf_reader, (CharBuf*)&stuff),
+ "MkDir returns true");
+ TEST_TRUE(batch,
+ Folder_Find_Folder(real_folder, (CharBuf*)&stuff) != NULL,
+ "Local_MkDir pass-through");
+ TEST_TRUE(batch,
+ Folder_Find_Folder(real_folder, (CharBuf*)&stuff)
+ == CFReader_Find_Folder(cf_reader, (CharBuf*)&stuff),
+ "Local_Find_Folder pass-through");
+ TEST_TRUE(batch,
+ CFReader_Local_Is_Directory(cf_reader, (CharBuf*)&stuff),
+ "Local_Is_Directory pass through");
Err_set_error(NULL);
- TEST_FALSE(batch, CFReader_MkDir(cf_reader, (CharBuf*)&stuff),
- "MkDir returns false when dir already exists");
+ TEST_FALSE(batch, CFReader_MkDir(cf_reader, (CharBuf*)&stuff),
+ "MkDir returns false when dir already exists");
TEST_TRUE(batch, Err_get_error() != NULL,
- "MkDir sets Err_error when dir already exists");
+ "MkDir sets Err_error when dir already exists");
Err_set_error(NULL);
- TEST_FALSE(batch, CFReader_MkDir(cf_reader, (CharBuf*)&foo),
- "MkDir returns false when virtual file exists");
+ TEST_FALSE(batch, CFReader_MkDir(cf_reader, (CharBuf*)&foo),
+ "MkDir returns false when virtual file exists");
TEST_TRUE(batch, Err_get_error() != NULL,
- "MkDir sets Err_error when virtual file exists");
+ "MkDir sets Err_error when virtual file exists");
- TEST_TRUE(batch,
- CFReader_Find_Folder(cf_reader, (CharBuf*)&foo) == NULL,
- "Virtual file not reported as directory");
+ TEST_TRUE(batch,
+ CFReader_Find_Folder(cf_reader, (CharBuf*)&foo) == NULL,
+ "Virtual file not reported as directory");
TEST_FALSE(batch, CFReader_Local_Is_Directory(cf_reader, (CharBuf*)&foo),
- "Local_Is_Directory returns false for virtual file");
+ "Local_Is_Directory returns false for virtual file");
DECREF(real_folder);
DECREF(cf_reader);
}
static void
-test_Local_Delete_and_Exists(TestBatch *batch)
-{
+test_Local_Delete_and_Exists(TestBatch *batch) {
Folder *real_folder = S_folder_with_contents();
CompoundFileReader *cf_reader = CFReader_open(real_folder);
CFReader_MkDir(cf_reader, (CharBuf*)&stuff);
TEST_TRUE(batch, CFReader_Local_Exists(cf_reader, (CharBuf*)&stuff),
- "pass through for Local_Exists");
+ "pass through for Local_Exists");
TEST_TRUE(batch, CFReader_Local_Exists(cf_reader, (CharBuf*)&foo),
- "Local_Exists returns true for virtual file");
+ "Local_Exists returns true for virtual file");
- TEST_TRUE(batch,
- CFReader_Local_Exists(cf_reader, (CharBuf*)&cfmeta_file),
- "cfmeta file exists");
+ TEST_TRUE(batch,
+ CFReader_Local_Exists(cf_reader, (CharBuf*)&cfmeta_file),
+ "cfmeta file exists");
- TEST_TRUE(batch, CFReader_Local_Delete(cf_reader, (CharBuf*)&stuff),
- "Local_Delete returns true when zapping real entity");
+ TEST_TRUE(batch, CFReader_Local_Delete(cf_reader, (CharBuf*)&stuff),
+ "Local_Delete returns true when zapping real entity");
TEST_FALSE(batch, CFReader_Local_Exists(cf_reader, (CharBuf*)&stuff),
- "Local_Exists returns false after real entity zapped");
+ "Local_Exists returns false after real entity zapped");
- TEST_TRUE(batch, CFReader_Local_Delete(cf_reader, (CharBuf*)&foo),
- "Local_Delete returns true when zapping virtual file");
+ TEST_TRUE(batch, CFReader_Local_Delete(cf_reader, (CharBuf*)&foo),
+ "Local_Delete returns true when zapping virtual file");
TEST_FALSE(batch, CFReader_Local_Exists(cf_reader, (CharBuf*)&foo),
- "Local_Exists returns false after virtual file zapped");
+ "Local_Exists returns false after virtual file zapped");
- TEST_TRUE(batch, CFReader_Local_Delete(cf_reader, (CharBuf*)&bar),
- "Local_Delete returns true when zapping last virtual file");
- TEST_FALSE(batch,
- CFReader_Local_Exists(cf_reader, (CharBuf*)&cfmeta_file),
- "cfmeta file deleted when last virtual file deleted");
- TEST_FALSE(batch,
- CFReader_Local_Exists(cf_reader, (CharBuf*)&cf_file),
- "compound data file deleted when last virtual file deleted");
+ TEST_TRUE(batch, CFReader_Local_Delete(cf_reader, (CharBuf*)&bar),
+ "Local_Delete returns true when zapping last virtual file");
+ TEST_FALSE(batch,
+ CFReader_Local_Exists(cf_reader, (CharBuf*)&cfmeta_file),
+ "cfmeta file deleted when last virtual file deleted");
+ TEST_FALSE(batch,
+ CFReader_Local_Exists(cf_reader, (CharBuf*)&cf_file),
+ "compound data file deleted when last virtual file deleted");
DECREF(cf_reader);
DECREF(real_folder);
}
static void
-test_Local_Open_Dir(TestBatch *batch)
-{
+test_Local_Open_Dir(TestBatch *batch) {
Folder *real_folder = S_folder_with_contents();
CompoundFileReader *cf_reader = CFReader_open(real_folder);
@@ -223,7 +218,7 @@ test_Local_Open_Dir(TestBatch *batch)
bool_t stuff_was_dir = false;
CFReader_MkDir(cf_reader, (CharBuf*)&stuff);
-
+
dh = CFReader_Local_Open_Dir(cf_reader);
entry = DH_Get_Entry(dh);
while (DH_Next(dh)) {
@@ -235,11 +230,11 @@ test_Local_Open_Dir(TestBatch *batch)
stuff_was_dir = DH_Entry_Is_Dir(dh);
}
}
-
+
TEST_TRUE(batch, saw_foo, "DirHandle iterated over virtual file");
TEST_TRUE(batch, saw_stuff, "DirHandle iterated over real directory");
- TEST_TRUE(batch, stuff_was_dir,
- "DirHandle knew that real entry was dir");
+ TEST_TRUE(batch, stuff_was_dir,
+ "DirHandle knew that real entry was dir");
DECREF(dh);
DECREF(cf_reader);
@@ -247,8 +242,7 @@ test_Local_Open_Dir(TestBatch *batch)
}
static void
-test_Local_Open_FileHandle(TestBatch *batch)
-{
+test_Local_Open_FileHandle(TestBatch *batch) {
Folder *real_folder = S_folder_with_contents();
CompoundFileReader *cf_reader = CFReader_open(real_folder);
FileHandle *fh;
@@ -261,43 +255,43 @@ test_Local_Open_FileHandle(TestBatch *ba
}
fh = CFReader_Local_Open_FileHandle(cf_reader, (CharBuf*)&baz,
- FH_READ_ONLY);
- TEST_TRUE(batch, fh != NULL,
- "Local_Open_FileHandle pass-through for real file");
+ FH_READ_ONLY);
+ TEST_TRUE(batch, fh != NULL,
+ "Local_Open_FileHandle pass-through for real file");
DECREF(fh);
Err_set_error(NULL);
fh = CFReader_Local_Open_FileHandle(cf_reader, (CharBuf*)&stuff,
- FH_READ_ONLY);
+ FH_READ_ONLY);
TEST_TRUE(batch, fh == NULL,
- "Local_Open_FileHandle for non-existent file returns NULL");
- TEST_TRUE(batch, Err_get_error() != NULL,
- "Local_Open_FileHandle for non-existent file sets Err_error");
+ "Local_Open_FileHandle for non-existent file returns NULL");
+ TEST_TRUE(batch, Err_get_error() != NULL,
+ "Local_Open_FileHandle for non-existent file sets Err_error");
Err_set_error(NULL);
- fh = CFReader_Local_Open_FileHandle(cf_reader, (CharBuf*)&foo,
- FH_READ_ONLY);
+ fh = CFReader_Local_Open_FileHandle(cf_reader, (CharBuf*)&foo,
+ FH_READ_ONLY);
TEST_TRUE(batch, fh == NULL,
- "Local_Open_FileHandle for virtual file returns NULL");
- TEST_TRUE(batch, Err_get_error() != NULL,
- "Local_Open_FileHandle for virtual file sets Err_error");
+ "Local_Open_FileHandle for virtual file returns NULL");
+ TEST_TRUE(batch, Err_get_error() != NULL,
+ "Local_Open_FileHandle for virtual file sets Err_error");
DECREF(cf_reader);
DECREF(real_folder);
}
static void
-test_Local_Open_In(TestBatch *batch)
-{
+test_Local_Open_In(TestBatch *batch) {
Folder *real_folder = S_folder_with_contents();
CompoundFileReader *cf_reader = CFReader_open(real_folder);
InStream *instream;
instream = CFReader_Local_Open_In(cf_reader, (CharBuf*)&foo);
TEST_TRUE(batch, instream != NULL,
- "Local_Open_In for virtual file");
- TEST_TRUE(batch, CB_Starts_With(InStream_Get_Filename(instream),
- CFReader_Get_Path(cf_reader)), "InStream's path includes directory");
+ "Local_Open_In for virtual file");
+ TEST_TRUE(batch,
+ CB_Starts_With(InStream_Get_Filename(instream), CFReader_Get_Path(cf_reader)),
+ "InStream's path includes directory");
DECREF(instream);
{
@@ -306,25 +300,24 @@ test_Local_Open_In(TestBatch *batch)
OutStream_Close(outstream);
DECREF(outstream);
instream = CFReader_Local_Open_In(cf_reader, (CharBuf*)&baz);
- TEST_TRUE(batch, instream != NULL,
- "Local_Open_In pass-through for real file");
+ TEST_TRUE(batch, instream != NULL,
+ "Local_Open_In pass-through for real file");
DECREF(instream);
}
Err_set_error(NULL);
instream = CFReader_Local_Open_In(cf_reader, (CharBuf*)&stuff);
TEST_TRUE(batch, instream == NULL,
- "Local_Open_In for non-existent file returns NULL");
- TEST_TRUE(batch, Err_get_error() != NULL,
- "Local_Open_In for non-existent file sets Err_error");
+ "Local_Open_In for non-existent file returns NULL");
+ TEST_TRUE(batch, Err_get_error() != NULL,
+ "Local_Open_In for non-existent file sets Err_error");
DECREF(cf_reader);
DECREF(real_folder);
}
static void
-test_Close(TestBatch *batch)
-{
+test_Close(TestBatch *batch) {
Folder *real_folder = S_folder_with_contents();
CompoundFileReader *cf_reader = CFReader_open(real_folder);
@@ -339,8 +332,7 @@ test_Close(TestBatch *batch)
}
void
-TestCFReader_run_tests()
-{
+TestCFReader_run_tests() {
TestBatch *batch = TestBatch_new(48);
TestBatch_Plan(batch);
Modified: incubator/lucy/trunk/core/Lucy/Test/Store/TestCompoundFileReader.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Test/Store/TestCompoundFileReader.cfh?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Test/Store/TestCompoundFileReader.cfh (original)
+++ incubator/lucy/trunk/core/Lucy/Test/Store/TestCompoundFileReader.cfh Sun May 1 23:50:24 2011
@@ -16,7 +16,7 @@
parcel Lucy;
-inert class Lucy::Test::Store::TestCompoundFileReader
+inert class Lucy::Test::Store::TestCompoundFileReader
cnick TestCFReader {
inert void
run_tests();
Modified: incubator/lucy/trunk/core/Lucy/Test/Store/TestCompoundFileWriter.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Test/Store/TestCompoundFileWriter.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Test/Store/TestCompoundFileWriter.c (original)
+++ incubator/lucy/trunk/core/Lucy/Test/Store/TestCompoundFileWriter.c Sun May 1 23:50:24 2011
@@ -33,8 +33,7 @@ static CharBuf bar = ZCB_LITERAL
static CharBuf seg_1 = ZCB_LITERAL("seg_1");
static Folder*
-S_folder_with_contents()
-{
+S_folder_with_contents() {
RAMFolder *folder = RAMFolder_new(&seg_1);
OutStream *foo_out = RAMFolder_Open_Out(folder, &foo);
OutStream *bar_out = RAMFolder_Open_Out(folder, &bar);
@@ -48,17 +47,16 @@ S_folder_with_contents()
}
static void
-test_Consolidate(TestBatch *batch)
-{
+test_Consolidate(TestBatch *batch) {
Folder *folder = S_folder_with_contents();
FileHandle *fh;
-
+
// Fake up detritus from failed consolidation.
- fh = Folder_Open_FileHandle(folder, &cf_file,
- FH_CREATE | FH_WRITE_ONLY | FH_EXCLUSIVE );
+ fh = Folder_Open_FileHandle(folder, &cf_file,
+ FH_CREATE | FH_WRITE_ONLY | FH_EXCLUSIVE);
DECREF(fh);
- fh = Folder_Open_FileHandle(folder, &cfmeta_temp,
- FH_CREATE | FH_WRITE_ONLY | FH_EXCLUSIVE );
+ fh = Folder_Open_FileHandle(folder, &cfmeta_temp,
+ FH_CREATE | FH_WRITE_ONLY | FH_EXCLUSIVE);
DECREF(fh);
{
@@ -68,21 +66,20 @@ test_Consolidate(TestBatch *batch)
DECREF(cf_writer);
}
- TEST_TRUE(batch, Folder_Exists(folder, &cf_file),
- "cf.dat file written");
- TEST_TRUE(batch, Folder_Exists(folder, &cfmeta_file),
- "cfmeta.json file written");
- TEST_FALSE(batch, Folder_Exists(folder, &foo),
- "original file zapped");
- TEST_FALSE(batch, Folder_Exists(folder, &cfmeta_temp),
- "detritus from failed consolidation zapped");
+ TEST_TRUE(batch, Folder_Exists(folder, &cf_file),
+ "cf.dat file written");
+ TEST_TRUE(batch, Folder_Exists(folder, &cfmeta_file),
+ "cfmeta.json file written");
+ TEST_FALSE(batch, Folder_Exists(folder, &foo),
+ "original file zapped");
+ TEST_FALSE(batch, Folder_Exists(folder, &cfmeta_temp),
+ "detritus from failed consolidation zapped");
DECREF(folder);
}
static void
-test_offsets(TestBatch *batch)
-{
+test_offsets(TestBatch *batch) {
Folder *folder = S_folder_with_contents();
CompoundFileWriter *cf_writer = CFWriter_new(folder);
Hash *cf_metadata;
@@ -91,9 +88,9 @@ test_offsets(TestBatch *batch)
CFWriter_Consolidate(cf_writer);
cf_metadata = (Hash*)CERTIFY(
- Json_slurp_json(folder, &cfmeta_file), HASH);
+ Json_slurp_json(folder, &cfmeta_file), HASH);
files = (Hash*)CERTIFY(
- Hash_Fetch_Str(cf_metadata, "files", 5), HASH);
+ Hash_Fetch_Str(cf_metadata, "files", 5), HASH);
{
CharBuf *file;
Obj *filestats;
@@ -109,7 +106,7 @@ test_offsets(TestBatch *batch)
if (offs % 8 != 0) {
offsets_ok = false;
FAIL(batch, "Offset %" I64P " for %s not a multiple of 8",
- offset, CB_Get_Ptr8(file));
+ offset, CB_Get_Ptr8(file));
break;
}
}
@@ -124,8 +121,7 @@ test_offsets(TestBatch *batch)
}
void
-TestCFWriter_run_tests()
-{
+TestCFWriter_run_tests() {
TestBatch *batch = TestBatch_new(7);
TestBatch_Plan(batch);
Modified: incubator/lucy/trunk/core/Lucy/Test/Store/TestCompoundFileWriter.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Test/Store/TestCompoundFileWriter.cfh?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Test/Store/TestCompoundFileWriter.cfh (original)
+++ incubator/lucy/trunk/core/Lucy/Test/Store/TestCompoundFileWriter.cfh Sun May 1 23:50:24 2011
@@ -16,7 +16,7 @@
parcel Lucy;
-inert class Lucy::Test::Store::TestCompoundFileWriter
+inert class Lucy::Test::Store::TestCompoundFileWriter
cnick TestCFWriter {
inert void
run_tests();
Modified: incubator/lucy/trunk/core/Lucy/Test/Store/TestFSDirHandle.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Test/Store/TestFSDirHandle.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Test/Store/TestFSDirHandle.c (original)
+++ incubator/lucy/trunk/core/Lucy/Test/Store/TestFSDirHandle.c Sun May 1 23:50:24 2011
@@ -33,8 +33,7 @@
#include "Lucy/Store/OutStream.h"
static void
-test_all(TestBatch *batch)
-{
+test_all(TestBatch *batch) {
CharBuf *foo = (CharBuf*)ZCB_WRAP_STR("foo", 3);
CharBuf *boffo = (CharBuf*)ZCB_WRAP_STR("boffo", 5);
CharBuf *foo_boffo = (CharBuf*)ZCB_WRAP_STR("foo/boffo", 9);
@@ -43,7 +42,7 @@ test_all(TestBatch *batch)
bool_t saw_foo = false;
bool_t saw_boffo = false;
bool_t foo_was_dir = false;
- bool_t boffo_was_dir = false;
+ bool_t boffo_was_dir = false;
int count = 0;
// Clean up after previous failed runs.
@@ -63,7 +62,7 @@ test_all(TestBatch *batch)
CharBuf *entry = FSDH_Get_Entry(dh);
while (FSDH_Next(dh)) {
count++;
- if (CB_Equals(entry, (Obj*)foo)) {
+ if (CB_Equals(entry, (Obj*)foo)) {
saw_foo = true;
foo_was_dir = FSDH_Entry_Is_Dir(dh);
}
@@ -74,11 +73,11 @@ test_all(TestBatch *batch)
}
TEST_INT_EQ(batch, 2, count, "correct number of entries");
TEST_TRUE(batch, saw_foo, "Directory was iterated over");
- TEST_TRUE(batch, foo_was_dir,
- "Dir correctly identified by Entry_Is_Dir");
+ TEST_TRUE(batch, foo_was_dir,
+ "Dir correctly identified by Entry_Is_Dir");
TEST_TRUE(batch, saw_boffo, "File was iterated over");
- TEST_FALSE(batch, boffo_was_dir,
- "File correctly identified by Entry_Is_Dir");
+ TEST_FALSE(batch, boffo_was_dir,
+ "File correctly identified by Entry_Is_Dir");
DECREF(dh);
FSFolder_Delete(folder, foo_boffo);
@@ -89,8 +88,7 @@ test_all(TestBatch *batch)
}
void
-TestFSDH_run_tests()
-{
+TestFSDH_run_tests() {
TestBatch *batch = TestBatch_new(5);
TestBatch_Plan(batch);
Modified: incubator/lucy/trunk/core/Lucy/Test/Store/TestFSFileHandle.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Test/Store/TestFSFileHandle.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Test/Store/TestFSFileHandle.c (original)
+++ incubator/lucy/trunk/core/Lucy/Test/Store/TestFSFileHandle.c Sun May 1 23:50:24 2011
@@ -21,7 +21,7 @@
#define C_LUCY_FILEWINDOW
#include "Lucy/Util/ToolSet.h"
-#ifdef CHY_HAS_UNISTD_H
+#ifdef CHY_HAS_UNISTD_H
#include <unistd.h> // close
#elif defined(CHY_HAS_IO_H)
#include <io.h> // close
@@ -33,8 +33,7 @@
#include "Lucy/Store/FileWindow.h"
static void
-test_open(TestBatch *batch)
-{
+test_open(TestBatch *batch) {
FSFileHandle *fh;
CharBuf *test_filename = (CharBuf*)ZCB_WRAP_STR("_fstest", 7);
@@ -43,24 +42,24 @@ test_open(TestBatch *batch)
Err_set_error(NULL);
fh = FSFH_open(test_filename, FH_READ_ONLY);
- TEST_TRUE(batch, fh == NULL,
- "open() with FH_READ_ONLY on non-existent file returns NULL");
+ TEST_TRUE(batch, fh == NULL,
+ "open() with FH_READ_ONLY on non-existent file returns NULL");
TEST_TRUE(batch, Err_get_error() != NULL,
- "open() with FH_READ_ONLY on non-existent file sets error");
+ "open() with FH_READ_ONLY on non-existent file sets error");
Err_set_error(NULL);
fh = FSFH_open(test_filename, FH_WRITE_ONLY);
- TEST_TRUE(batch, fh == NULL,
- "open() without FH_CREATE returns NULL");
+ TEST_TRUE(batch, fh == NULL,
+ "open() without FH_CREATE returns NULL");
TEST_TRUE(batch, Err_get_error() != NULL,
- "open() without FH_CREATE sets error");
+ "open() without FH_CREATE sets error");
Err_set_error(NULL);
fh = FSFH_open(test_filename, FH_CREATE);
- TEST_TRUE(batch, fh == NULL,
- "open() without FH_WRITE_ONLY returns NULL");
+ TEST_TRUE(batch, fh == NULL,
+ "open() without FH_WRITE_ONLY returns NULL");
TEST_TRUE(batch, Err_get_error() != NULL,
- "open() without FH_WRITE_ONLY sets error");
+ "open() without FH_WRITE_ONLY sets error");
Err_set_error(NULL);
fh = FSFH_open(test_filename, FH_CREATE | FH_WRITE_ONLY | FH_EXCLUSIVE);
@@ -74,14 +73,14 @@ test_open(TestBatch *batch)
fh = FSFH_open(test_filename, FH_CREATE | FH_WRITE_ONLY | FH_EXCLUSIVE);
TEST_TRUE(batch, fh == NULL, "FH_EXCLUSIVE blocks open()");
TEST_TRUE(batch, Err_get_error() != NULL,
- "FH_EXCLUSIVE blocks open(), sets error");
+ "FH_EXCLUSIVE blocks open(), sets error");
Err_set_error(NULL);
fh = FSFH_open(test_filename, FH_CREATE | FH_WRITE_ONLY);
- TEST_TRUE(batch, fh && FSFH_Is_A(fh, FSFILEHANDLE),
- "open() for append");
- TEST_TRUE(batch, Err_get_error() == NULL,
- "open() for append -- no errors");
+ TEST_TRUE(batch, fh && FSFH_Is_A(fh, FSFILEHANDLE),
+ "open() for append");
+ TEST_TRUE(batch, Err_get_error() == NULL,
+ "open() for append -- no errors");
FSFH_Write(fh, "bar", 3);
if (!FSFH_Close(fh)) { RETHROW(INCREF(Err_get_error())); }
DECREF(fh);
@@ -89,16 +88,15 @@ test_open(TestBatch *batch)
Err_set_error(NULL);
fh = FSFH_open(test_filename, FH_READ_ONLY);
TEST_TRUE(batch, fh && FSFH_Is_A(fh, FSFILEHANDLE), "open() read only");
- TEST_TRUE(batch, Err_get_error() == NULL,
- "open() read only -- no errors");
+ TEST_TRUE(batch, Err_get_error() == NULL,
+ "open() read only -- no errors");
DECREF(fh);
-
+
remove((char*)CB_Get_Ptr8(test_filename));
}
static void
-test_Read_Write(TestBatch *batch)
-{
+test_Read_Write(TestBatch *batch) {
FSFileHandle *fh;
const char *foo = "foo";
const char *bar = "bar";
@@ -107,8 +105,8 @@ test_Read_Write(TestBatch *batch)
CharBuf *test_filename = (CharBuf*)ZCB_WRAP_STR("_fstest", 7);
remove((char*)CB_Get_Ptr8(test_filename));
- fh = FSFH_open(test_filename,
- FH_CREATE | FH_WRITE_ONLY | FH_EXCLUSIVE);
+ fh = FSFH_open(test_filename,
+ FH_CREATE | FH_WRITE_ONLY | FH_EXCLUSIVE);
TEST_TRUE(batch, FSFH_Length(fh) == I64_C(0), "Length initially 0");
TEST_TRUE(batch, FSFH_Write(fh, foo, 3), "Write returns success");
@@ -117,10 +115,10 @@ test_Read_Write(TestBatch *batch)
TEST_TRUE(batch, FSFH_Length(fh) == I64_C(6), "Length after 2 Writes");
Err_set_error(NULL);
- TEST_FALSE(batch, FSFH_Read(fh, buf, 0, 2),
- "Reading from a write-only handle returns false");
- TEST_TRUE(batch, Err_get_error() != NULL,
- "Reading from a write-only handle sets error");
+ TEST_FALSE(batch, FSFH_Read(fh, buf, 0, 2),
+ "Reading from a write-only handle returns false");
+ TEST_TRUE(batch, Err_get_error() != NULL,
+ "Reading from a write-only handle sets error");
if (!FSFH_Close(fh)) { RETHROW(INCREF(Err_get_error())); }
DECREF(fh);
@@ -136,51 +134,50 @@ test_Read_Write(TestBatch *batch)
Err_set_error(NULL);
TEST_FALSE(batch, FSFH_Read(fh, buf, -1, 4),
- "Read() with a negative offset returns false");
- TEST_TRUE(batch, Err_get_error() != NULL,
- "Read() with a negative offset sets error");
+ "Read() with a negative offset returns false");
+ TEST_TRUE(batch, Err_get_error() != NULL,
+ "Read() with a negative offset sets error");
Err_set_error(NULL);
TEST_FALSE(batch, FSFH_Read(fh, buf, 6, 1),
- "Read() past EOF returns false");
- TEST_TRUE(batch, Err_get_error() != NULL,
- "Read() past EOF sets error");
+ "Read() past EOF returns false");
+ TEST_TRUE(batch, Err_get_error() != NULL,
+ "Read() past EOF sets error");
Err_set_error(NULL);
- TEST_FALSE(batch, FSFH_Write(fh, foo, 3),
- "Writing to a read-only handle returns false");
- TEST_TRUE(batch, Err_get_error() != NULL,
- "Writing to a read-only handle sets error");
+ TEST_FALSE(batch, FSFH_Write(fh, foo, 3),
+ "Writing to a read-only handle returns false");
+ TEST_TRUE(batch, Err_get_error() != NULL,
+ "Writing to a read-only handle sets error");
DECREF(fh);
remove((char*)CB_Get_Ptr8(test_filename));
}
static void
-test_Close(TestBatch *batch)
-{
+test_Close(TestBatch *batch) {
CharBuf *test_filename = (CharBuf*)ZCB_WRAP_STR("_fstest", 7);
FSFileHandle *fh;
bool_t result;
remove((char*)CB_Get_Ptr8(test_filename));
- fh = FSFH_open(test_filename,
- FH_CREATE | FH_WRITE_ONLY | FH_EXCLUSIVE);
+ fh = FSFH_open(test_filename,
+ FH_CREATE | FH_WRITE_ONLY | FH_EXCLUSIVE);
TEST_TRUE(batch, FSFH_Close(fh), "Close returns true for write-only");
DECREF(fh);
// Simulate an OS error when closing the file descriptor. This
// approximates what would happen if, say, we run out of disk space.
remove((char*)CB_Get_Ptr8(test_filename));
- fh = FSFH_open(test_filename,
- FH_CREATE | FH_WRITE_ONLY | FH_EXCLUSIVE);
+ fh = FSFH_open(test_filename,
+ FH_CREATE | FH_WRITE_ONLY | FH_EXCLUSIVE);
close(fh->fd);
fh->fd = -1;
Err_set_error(NULL);
result = FSFH_Close(fh);
TEST_FALSE(batch, result, "Failed Close() returns false");
- TEST_TRUE(batch, Err_get_error() != NULL,
- "Failed Close() sets Err_error");
+ TEST_TRUE(batch, Err_get_error() != NULL,
+ "Failed Close() sets Err_error");
DECREF(fh);
fh = FSFH_open(test_filename, FH_READ_ONLY);
@@ -191,16 +188,15 @@ test_Close(TestBatch *batch)
}
static void
-test_Window(TestBatch *batch)
-{
+test_Window(TestBatch *batch) {
CharBuf *test_filename = (CharBuf*)ZCB_WRAP_STR("_fstest", 7);
FSFileHandle *fh;
FileWindow *window = FileWindow_new();
uint32_t i;
remove((char*)CB_Get_Ptr8(test_filename));
- fh = FSFH_open(test_filename,
- FH_CREATE | FH_WRITE_ONLY | FH_EXCLUSIVE);
+ fh = FSFH_open(test_filename,
+ FH_CREATE | FH_WRITE_ONLY | FH_EXCLUSIVE);
for (i = 0; i < 1024; i++) {
FSFH_Write(fh, "foo ", 4);
}
@@ -213,24 +209,24 @@ test_Window(TestBatch *batch)
Err_set_error(NULL);
TEST_FALSE(batch, FSFH_Window(fh, window, -1, 4),
- "Window() with a negative offset returns false");
- TEST_TRUE(batch, Err_get_error() != NULL,
- "Window() with a negative offset sets error");
+ "Window() with a negative offset returns false");
+ TEST_TRUE(batch, Err_get_error() != NULL,
+ "Window() with a negative offset sets error");
Err_set_error(NULL);
TEST_FALSE(batch, FSFH_Window(fh, window, 4000, 1000),
- "Window() past EOF returns false");
- TEST_TRUE(batch, Err_get_error() != NULL,
- "Window() past EOF sets error");
-
- TEST_TRUE(batch, FSFH_Window(fh, window, 1021, 2),
- "Window() returns true");
- TEST_TRUE(batch,
- strncmp(window->buf - window->offset + 1021, "oo", 2) == 0,
- "Window()");
+ "Window() past EOF returns false");
+ TEST_TRUE(batch, Err_get_error() != NULL,
+ "Window() past EOF sets error");
+
+ TEST_TRUE(batch, FSFH_Window(fh, window, 1021, 2),
+ "Window() returns true");
+ TEST_TRUE(batch,
+ strncmp(window->buf - window->offset + 1021, "oo", 2) == 0,
+ "Window()");
- TEST_TRUE(batch, FSFH_Release_Window(fh, window),
- "Release_Window() returns true");
+ TEST_TRUE(batch, FSFH_Release_Window(fh, window),
+ "Release_Window() returns true");
TEST_TRUE(batch, window->buf == NULL, "Release_Window() resets buf");
TEST_TRUE(batch, window->offset == 0, "Release_Window() resets offset");
TEST_TRUE(batch, window->len == 0, "Release_Window() resets len");
@@ -241,8 +237,7 @@ test_Window(TestBatch *batch)
}
void
-TestFSFH_run_tests()
-{
+TestFSFH_run_tests() {
TestBatch *batch = TestBatch_new(46);
TestBatch_Plan(batch);
Modified: incubator/lucy/trunk/core/Lucy/Test/Store/TestFSFolder.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Test/Store/TestFSFolder.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Test/Store/TestFSFolder.c (original)
+++ incubator/lucy/trunk/core/Lucy/Test/Store/TestFSFolder.c Sun May 1 23:50:24 2011
@@ -38,8 +38,7 @@
#include "Lucy/Store/OutStream.h"
static Folder*
-S_set_up()
-{
+S_set_up() {
rmdir("_fstest");
CharBuf *test_dir = (CharBuf*)ZCB_WRAP_STR("_fstest", 7);
FSFolder *folder = FSFolder_new(test_dir);
@@ -51,8 +50,7 @@ S_set_up()
}
static void
-S_tear_down()
-{
+S_tear_down() {
struct stat stat_buf;
rmdir("_fstest");
if (stat("_fstest", &stat_buf) != -1) {
@@ -61,38 +59,36 @@ S_tear_down()
}
static void
-test_Initialize_and_Check(TestBatch *batch)
-{
+test_Initialize_and_Check(TestBatch *batch) {
rmdir("_fstest");
CharBuf *test_dir = (CharBuf*)ZCB_WRAP_STR("_fstest", 7);
FSFolder *folder = FSFolder_new(test_dir);
- TEST_FALSE(batch, FSFolder_Check(folder),
- "Check() returns false when folder dir doesn't exist");
+ TEST_FALSE(batch, FSFolder_Check(folder),
+ "Check() returns false when folder dir doesn't exist");
FSFolder_Initialize(folder);
PASS(batch, "Initialize() concludes without incident");
- TEST_TRUE(batch, FSFolder_Check(folder),
- "Initialize() created dir, and now Check() succeeds");
+ TEST_TRUE(batch, FSFolder_Check(folder),
+ "Initialize() created dir, and now Check() succeeds");
DECREF(folder);
S_tear_down();
}
static void
-test_protect_symlinks(TestBatch *batch)
-{
+test_protect_symlinks(TestBatch *batch) {
#ifdef CHY_HAS_UNISTD_H
FSFolder *folder = (FSFolder*)S_set_up();
CharBuf *foo = (CharBuf*)ZCB_WRAP_STR("foo", 3);
CharBuf *bar = (CharBuf*)ZCB_WRAP_STR("bar", 3);
CharBuf *foo_boffo = (CharBuf*)ZCB_WRAP_STR("foo/boffo", 9);
-
+
FSFolder_MkDir(folder, foo);
FSFolder_MkDir(folder, bar);
OutStream *outstream = FSFolder_Open_Out(folder, foo_boffo);
DECREF(outstream);
- if ( symlink("_fstest/foo/boffo", "_fstest/bar/banana")
+ if (symlink("_fstest/foo/boffo", "_fstest/bar/banana")
|| symlink("_fstest/foo", "_fstest/bar/bazooka")
- ) {
+ ) {
FAIL(batch, "symlink() failed");
FAIL(batch, "symlink() failed");
FAIL(batch, "symlink() failed");
@@ -108,18 +104,18 @@ test_protect_symlinks(TestBatch *batch)
saw_bazooka_boffo = true;
}
}
- TEST_FALSE(batch, saw_bazooka_boffo,
- "List_R() shouldn't follow symlinks");
+ TEST_FALSE(batch, saw_bazooka_boffo,
+ "List_R() shouldn't follow symlinks");
DECREF(list);
- TEST_TRUE(batch, FSFolder_Delete_Tree(folder, bar),
- "Delete_Tree() returns true"),
- TEST_FALSE(batch, FSFolder_Exists(folder, bar),
- "Tree is really gone");
+ TEST_TRUE(batch, FSFolder_Delete_Tree(folder, bar),
+ "Delete_Tree() returns true"),
+ TEST_FALSE(batch, FSFolder_Exists(folder, bar),
+ "Tree is really gone");
TEST_TRUE(batch, FSFolder_Exists(folder, foo),
- "Original folder sill there");
+ "Original folder sill there");
TEST_TRUE(batch, FSFolder_Exists(folder, foo_boffo),
- "Delete_Tree() did not follow directory symlink");
+ "Delete_Tree() did not follow directory symlink");
FSFolder_Delete_Tree(folder, foo);
}
DECREF(folder);
@@ -135,8 +131,7 @@ test_protect_symlinks(TestBatch *batch)
}
void
-test_disallow_updir(TestBatch *batch)
-{
+test_disallow_updir(TestBatch *batch) {
FSFolder *outer_folder = (FSFolder*)S_set_up();
CharBuf *foo = (CharBuf*)ZCB_WRAP_STR("foo", 3);
@@ -147,8 +142,8 @@ test_disallow_updir(TestBatch *batch)
CharBuf *inner_path = (CharBuf*)ZCB_WRAP_STR("_fstest/foo", 11);
FSFolder *foo_folder = FSFolder_new(inner_path);
CharBuf *up_bar = (CharBuf*)ZCB_WRAP_STR("../bar", 6);
- TEST_FALSE(batch, FSFolder_Exists(foo_folder, up_bar),
- "up-dirs are inaccessible.");
+ TEST_FALSE(batch, FSFolder_Exists(foo_folder, up_bar),
+ "up-dirs are inaccessible.");
DECREF(foo_folder);
FSFolder_Delete(outer_folder, foo);
@@ -158,8 +153,7 @@ test_disallow_updir(TestBatch *batch)
}
void
-TestFSFolder_run_tests()
-{
+TestFSFolder_run_tests() {
uint32_t num_tests = TestFolderCommon_num_tests() + 9;
TestBatch *batch = TestBatch_new(num_tests);
Modified: incubator/lucy/trunk/core/Lucy/Test/Store/TestFileHandle.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Test/Store/TestFileHandle.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Test/Store/TestFileHandle.c (original)
+++ incubator/lucy/trunk/core/Lucy/Test/Store/TestFileHandle.c Sun May 1 23:50:24 2011
@@ -25,28 +25,25 @@
#include "Lucy/Store/FileWindow.h"
static void
-S_no_op_method(const void *vself)
-{
+S_no_op_method(const void *vself) {
UNUSED_VAR(vself);
}
static FileHandle*
-S_new_filehandle()
-{
+S_new_filehandle() {
ZombieCharBuf *klass = ZCB_WRAP_STR("TestFileHandle", 14);
FileHandle *fh;
VTable *vtable = VTable_fetch_vtable((CharBuf*)klass);
if (!vtable) {
vtable = VTable_singleton((CharBuf*)klass, FILEHANDLE);
- }
+ }
VTable_Override(vtable, S_no_op_method, Lucy_FH_Close_OFFSET);
fh = (FileHandle*)VTable_Make_Obj(vtable);
return FH_do_open(fh, NULL, 0);
}
void
-TestFH_run_tests()
-{
+TestFH_run_tests() {
TestBatch *batch = TestBatch_new(2);
FileHandle *fh = S_new_filehandle();
ZombieCharBuf *foo = ZCB_WRAP_STR("foo", 3);
Modified: incubator/lucy/trunk/core/Lucy/Test/Store/TestFolder.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Test/Store/TestFolder.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Test/Store/TestFolder.c (original)
+++ incubator/lucy/trunk/core/Lucy/Test/Store/TestFolder.c Sun May 1 23:50:24 2011
@@ -39,8 +39,7 @@ static CharBuf foo_bar_baz_boffo = ZCB_L
static CharBuf nope = ZCB_LITERAL("nope");
static void
-test_Exists(TestBatch *batch)
-{
+test_Exists(TestBatch *batch) {
Folder *folder = (Folder*)RAMFolder_new(NULL);
FileHandle *fh;
@@ -48,146 +47,143 @@ test_Exists(TestBatch *batch)
Folder_MkDir(folder, &foo_bar);
fh = Folder_Open_FileHandle(folder, &boffo, FH_CREATE | FH_WRITE_ONLY);
DECREF(fh);
- fh = Folder_Open_FileHandle(folder, &foo_boffo,
- FH_CREATE | FH_WRITE_ONLY);
+ fh = Folder_Open_FileHandle(folder, &foo_boffo,
+ FH_CREATE | FH_WRITE_ONLY);
DECREF(fh);
TEST_TRUE(batch, Folder_Exists(folder, &foo), "Dir exists");
TEST_TRUE(batch, Folder_Exists(folder, &boffo), "File exists");
- TEST_TRUE(batch, Folder_Exists(folder, &foo_bar),
- "Nested dir exists");
- TEST_TRUE(batch, Folder_Exists(folder, &foo_boffo),
- "Nested file exists");
+ TEST_TRUE(batch, Folder_Exists(folder, &foo_bar),
+ "Nested dir exists");
+ TEST_TRUE(batch, Folder_Exists(folder, &foo_boffo),
+ "Nested file exists");
- TEST_FALSE(batch, Folder_Exists(folder, &banana),
- "Non-existent entry");
- TEST_FALSE(batch, Folder_Exists(folder, &foo_foo),
- "Non-existent nested entry");
+ TEST_FALSE(batch, Folder_Exists(folder, &banana),
+ "Non-existent entry");
+ TEST_FALSE(batch, Folder_Exists(folder, &foo_foo),
+ "Non-existent nested entry");
DECREF(folder);
}
static void
-test_Set_Path_and_Get_Path(TestBatch *batch)
-{
+test_Set_Path_and_Get_Path(TestBatch *batch) {
Folder *folder = (Folder*)RAMFolder_new(&foo);
TEST_TRUE(batch, CB_Equals(Folder_Get_Path(folder), (Obj*)&foo),
- "Get_Path");
+ "Get_Path");
Folder_Set_Path(folder, &bar);
TEST_TRUE(batch, CB_Equals(Folder_Get_Path(folder), (Obj*)&bar),
- "Set_Path");
+ "Set_Path");
DECREF(folder);
}
static void
-test_MkDir_and_Is_Directory(TestBatch *batch)
-{
+test_MkDir_and_Is_Directory(TestBatch *batch) {
Folder *folder = (Folder*)RAMFolder_new(NULL);
FileHandle *fh;
- TEST_FALSE(batch, Folder_Is_Directory(folder, &foo),
- "Is_Directory() false for non-existent entry");
+ TEST_FALSE(batch, Folder_Is_Directory(folder, &foo),
+ "Is_Directory() false for non-existent entry");
- TEST_TRUE(batch, Folder_MkDir(folder, &foo),
- "MkDir returns true on success");
- TEST_TRUE(batch, Folder_Is_Directory(folder, &foo),
- "Is_Directory() true for local folder");
+ TEST_TRUE(batch, Folder_MkDir(folder, &foo),
+ "MkDir returns true on success");
+ TEST_TRUE(batch, Folder_Is_Directory(folder, &foo),
+ "Is_Directory() true for local folder");
- TEST_FALSE(batch, Folder_Is_Directory(folder, &foo_bar_baz),
- "Is_Directory() false for non-existent deeply nested dir");
+ TEST_FALSE(batch, Folder_Is_Directory(folder, &foo_bar_baz),
+ "Is_Directory() false for non-existent deeply nested dir");
Err_set_error(NULL);
- TEST_FALSE(batch, Folder_MkDir(folder, &foo_bar_baz),
- "MkDir for deeply nested dir fails");
+ TEST_FALSE(batch, Folder_MkDir(folder, &foo_bar_baz),
+ "MkDir for deeply nested dir fails");
TEST_TRUE(batch, Err_get_error() != NULL,
- "MkDir for deeply nested dir sets Err_error");
+ "MkDir for deeply nested dir sets Err_error");
- TEST_TRUE(batch, Folder_MkDir(folder, &foo_bar),
- "MkDir for nested dir");
- TEST_TRUE(batch, Folder_Is_Directory(folder, &foo_bar),
- "Is_Directory() true for nested dir");
+ TEST_TRUE(batch, Folder_MkDir(folder, &foo_bar),
+ "MkDir for nested dir");
+ TEST_TRUE(batch, Folder_Is_Directory(folder, &foo_bar),
+ "Is_Directory() true for nested dir");
Err_set_error(NULL);
- TEST_FALSE(batch, Folder_MkDir(folder, &foo_bar),
- "Overwrite dir with MkDir fails");
+ TEST_FALSE(batch, Folder_MkDir(folder, &foo_bar),
+ "Overwrite dir with MkDir fails");
TEST_TRUE(batch, Err_get_error() != NULL,
- "Overwrite dir with MkDir sets Err_error");
+ "Overwrite dir with MkDir sets Err_error");
- fh = Folder_Open_FileHandle(folder, &foo_boffo,
- FH_CREATE | FH_WRITE_ONLY);
+ fh = Folder_Open_FileHandle(folder, &foo_boffo,
+ FH_CREATE | FH_WRITE_ONLY);
DECREF(fh);
Err_set_error(NULL);
- TEST_FALSE(batch, Folder_MkDir(folder, &foo_boffo),
- "Overwrite file with MkDir fails");
+ TEST_FALSE(batch, Folder_MkDir(folder, &foo_boffo),
+ "Overwrite file with MkDir fails");
TEST_TRUE(batch, Err_get_error() != NULL,
- "Overwrite file with MkDir sets Err_error");
- TEST_FALSE(batch, Folder_Is_Directory(folder, &foo_boffo),
- "Is_Directory() false for nested file");
+ "Overwrite file with MkDir sets Err_error");
+ TEST_FALSE(batch, Folder_Is_Directory(folder, &foo_boffo),
+ "Is_Directory() false for nested file");
DECREF(folder);
}
static void
-test_Enclosing_Folder_and_Find_Folder(TestBatch *batch)
-{
+test_Enclosing_Folder_and_Find_Folder(TestBatch *batch) {
Folder *folder = (Folder*)RAMFolder_new(NULL);
FileHandle *fh;
Folder_MkDir(folder, &foo);
Folder_MkDir(folder, &foo_bar);
Folder_MkDir(folder, &foo_bar_baz);
- fh = Folder_Open_FileHandle(folder, &foo_bar_baz_boffo,
- FH_CREATE | FH_WRITE_ONLY);
+ fh = Folder_Open_FileHandle(folder, &foo_bar_baz_boffo,
+ FH_CREATE | FH_WRITE_ONLY);
{
Folder *encloser = Folder_Enclosing_Folder(folder, (CharBuf*)&nope);
Folder *found = Folder_Find_Folder(folder, (CharBuf*)&nope);
- TEST_TRUE(batch, encloser == folder,
- "Enclosing_Folder() - non-existent entry yields parent");
+ TEST_TRUE(batch, encloser == folder,
+ "Enclosing_Folder() - non-existent entry yields parent");
TEST_TRUE(batch, found == NULL,
- "Find_Folder() - non-existent entry yields NULL");
+ "Find_Folder() - non-existent entry yields NULL");
}
{
Folder *encloser = Folder_Enclosing_Folder(folder, &foo_bar);
Folder *found = Folder_Find_Folder(folder, &foo_bar);
- TEST_TRUE(batch,
- encloser
- && Folder_Is_A(encloser, FOLDER)
- && CB_Ends_With(Folder_Get_Path(encloser), &foo),
- "Enclosing_Folder() - find one directory down");
- TEST_TRUE(batch,
- found
- && Folder_Is_A(found, FOLDER)
- && CB_Ends_With(Folder_Get_Path(found), &bar),
- "Find_Folder() - 'foo/bar'");
+ TEST_TRUE(batch,
+ encloser
+ && Folder_Is_A(encloser, FOLDER)
+ && CB_Ends_With(Folder_Get_Path(encloser), &foo),
+ "Enclosing_Folder() - find one directory down");
+ TEST_TRUE(batch,
+ found
+ && Folder_Is_A(found, FOLDER)
+ && CB_Ends_With(Folder_Get_Path(found), &bar),
+ "Find_Folder() - 'foo/bar'");
}
{
Folder *encloser = Folder_Enclosing_Folder(folder, &foo_bar_baz);
Folder *found = Folder_Find_Folder(folder, &foo_bar_baz);
- TEST_TRUE(batch,
- encloser
- && Folder_Is_A(encloser, FOLDER)
- && CB_Ends_With(Folder_Get_Path(encloser), &bar),
- "Find two directories down");
- TEST_TRUE(batch,
- found
- && Folder_Is_A(found, FOLDER)
- && CB_Ends_With(Folder_Get_Path(found), &baz),
- "Find_Folder() - 'foo/bar/baz'");
+ TEST_TRUE(batch,
+ encloser
+ && Folder_Is_A(encloser, FOLDER)
+ && CB_Ends_With(Folder_Get_Path(encloser), &bar),
+ "Find two directories down");
+ TEST_TRUE(batch,
+ found
+ && Folder_Is_A(found, FOLDER)
+ && CB_Ends_With(Folder_Get_Path(found), &baz),
+ "Find_Folder() - 'foo/bar/baz'");
}
{
- Folder *encloser
+ Folder *encloser
= Folder_Enclosing_Folder(folder, &foo_bar_baz_boffo);
Folder *found = Folder_Find_Folder(folder, &foo_bar_baz_boffo);
- TEST_TRUE(batch,
- encloser
- && Folder_Is_A(encloser, FOLDER)
- && CB_Ends_With(Folder_Get_Path(encloser), &baz),
- "Recurse to find a directory containing a real file");
+ TEST_TRUE(batch,
+ encloser
+ && Folder_Is_A(encloser, FOLDER)
+ && CB_Ends_With(Folder_Get_Path(encloser), &baz),
+ "Recurse to find a directory containing a real file");
TEST_TRUE(batch, found == NULL,
- "Find_Folder() - file instead of folder yields NULL");
+ "Find_Folder() - file instead of folder yields NULL");
}
DECREF(fh);
@@ -195,8 +191,7 @@ test_Enclosing_Folder_and_Find_Folder(Te
}
static void
-test_List(TestBatch *batch)
-{
+test_List(TestBatch *batch) {
Folder *folder = (Folder*)RAMFolder_new(NULL);
FileHandle *fh;
VArray *list;
@@ -214,11 +209,11 @@ test_List(TestBatch *batch)
VA_Sort(list, NULL, NULL);
TEST_INT_EQ(batch, VA_Get_Size(list), 3, "List");
elem = (CharBuf*)DOWNCAST(VA_Fetch(list, 0), CHARBUF);
- TEST_TRUE(batch, elem && CB_Equals(elem, (Obj*)&banana),
- "List first file");
+ TEST_TRUE(batch, elem && CB_Equals(elem, (Obj*)&banana),
+ "List first file");
elem = (CharBuf*)DOWNCAST(VA_Fetch(list, 1), CHARBUF);
- TEST_TRUE(batch, elem && CB_Equals(elem, (Obj*)&boffo),
- "List second file");
+ TEST_TRUE(batch, elem && CB_Equals(elem, (Obj*)&boffo),
+ "List second file");
elem = (CharBuf*)DOWNCAST(VA_Fetch(list, 2), CHARBUF);
TEST_TRUE(batch, elem && CB_Equals(elem, (Obj*)&foo), "List dir");
DECREF(list);
@@ -226,16 +221,15 @@ test_List(TestBatch *batch)
list = Folder_List(folder, &foo_bar);
TEST_INT_EQ(batch, VA_Get_Size(list), 1, "List subdirectory contents");
elem = (CharBuf*)DOWNCAST(VA_Fetch(list, 0), CHARBUF);
- TEST_TRUE(batch, elem && CB_Equals(elem, (Obj*)&baz),
- "Just the filename");
+ TEST_TRUE(batch, elem && CB_Equals(elem, (Obj*)&baz),
+ "Just the filename");
DECREF(list);
DECREF(folder);
}
static void
-test_Open_Dir(TestBatch *batch)
-{
+test_Open_Dir(TestBatch *batch) {
Folder *folder = (Folder*)RAMFolder_new(NULL);
DirHandle *dh;
@@ -252,23 +246,22 @@ test_Open_Dir(TestBatch *batch)
Err_set_error(NULL);
dh = Folder_Open_Dir(folder, &bar);
TEST_TRUE(batch, dh == NULL,
- "Open_Dir on non-existent entry fails");
+ "Open_Dir on non-existent entry fails");
TEST_TRUE(batch, Err_get_error() != NULL,
- "Open_Dir on non-existent entry sets Err_error");
+ "Open_Dir on non-existent entry sets Err_error");
Err_set_error(NULL);
dh = Folder_Open_Dir(folder, &foo_foo);
TEST_TRUE(batch, dh == NULL,
- "Open_Dir on non-existent nested entry fails");
+ "Open_Dir on non-existent nested entry fails");
TEST_TRUE(batch, Err_get_error() != NULL,
- "Open_Dir on non-existent nested entry sets Err_error");
+ "Open_Dir on non-existent nested entry sets Err_error");
DECREF(folder);
}
static void
-test_Open_FileHandle(TestBatch *batch)
-{
+test_Open_FileHandle(TestBatch *batch) {
Folder *folder = (Folder*)RAMFolder_new(NULL);
FileHandle *fh;
@@ -278,75 +271,73 @@ test_Open_FileHandle(TestBatch *batch)
TEST_TRUE(batch, fh && FH_Is_A(fh, FILEHANDLE), "Open_FileHandle");
DECREF(fh);
- fh = Folder_Open_FileHandle(folder, &foo_boffo,
- FH_CREATE | FH_WRITE_ONLY);
- TEST_TRUE(batch, fh && FH_Is_A(fh, FILEHANDLE),
- "Open_FileHandle for nested file");
+ fh = Folder_Open_FileHandle(folder, &foo_boffo,
+ FH_CREATE | FH_WRITE_ONLY);
+ TEST_TRUE(batch, fh && FH_Is_A(fh, FILEHANDLE),
+ "Open_FileHandle for nested file");
DECREF(fh);
Err_set_error(NULL);
fh = Folder_Open_FileHandle(folder, &foo, FH_CREATE | FH_WRITE_ONLY);
TEST_TRUE(batch, fh == NULL,
- "Open_FileHandle on existing dir path fails");
+ "Open_FileHandle on existing dir path fails");
TEST_TRUE(batch, Err_get_error() != NULL,
- "Open_FileHandle on existing dir name sets Err_error");
+ "Open_FileHandle on existing dir name sets Err_error");
Err_set_error(NULL);
- fh = Folder_Open_FileHandle(folder, &foo_bar_baz_boffo,
- FH_CREATE | FH_WRITE_ONLY);
+ fh = Folder_Open_FileHandle(folder, &foo_bar_baz_boffo,
+ FH_CREATE | FH_WRITE_ONLY);
TEST_TRUE(batch, fh == NULL,
- "Open_FileHandle for entry within non-existent dir fails");
+ "Open_FileHandle for entry within non-existent dir fails");
TEST_TRUE(batch, Err_get_error() != NULL,
- "Open_FileHandle for entry within non-existent dir sets Err_error");
+ "Open_FileHandle for entry within non-existent dir sets Err_error");
DECREF(folder);
}
static void
-test_Open_Out(TestBatch *batch)
-{
+test_Open_Out(TestBatch *batch) {
Folder *folder = (Folder*)RAMFolder_new(NULL);
OutStream *outstream;
Folder_MkDir(folder, &foo);
outstream = Folder_Open_Out(folder, &boffo);
- TEST_TRUE(batch, outstream && OutStream_Is_A(outstream, OUTSTREAM),
- "Open_Out");
+ TEST_TRUE(batch, outstream && OutStream_Is_A(outstream, OUTSTREAM),
+ "Open_Out");
DECREF(outstream);
outstream = Folder_Open_Out(folder, &foo_boffo);
- TEST_TRUE(batch, outstream && OutStream_Is_A(outstream, OUTSTREAM),
- "Open_Out for nested file");
+ TEST_TRUE(batch, outstream && OutStream_Is_A(outstream, OUTSTREAM),
+ "Open_Out for nested file");
DECREF(outstream);
Err_set_error(NULL);
outstream = Folder_Open_Out(folder, &boffo);
TEST_TRUE(batch, outstream == NULL,
- "Open_OutStream on existing file fails");
+ "Open_OutStream on existing file fails");
TEST_TRUE(batch, Err_get_error() != NULL,
- "Open_Out on existing file sets Err_error");
+ "Open_Out on existing file sets Err_error");
Err_set_error(NULL);
outstream = Folder_Open_Out(folder, &foo);
TEST_TRUE(batch, outstream == NULL,
- "Open_OutStream on existing dir path fails");
+ "Open_OutStream on existing dir path fails");
TEST_TRUE(batch, Err_get_error() != NULL,
- "Open_Out on existing dir name sets Err_error");
+ "Open_Out on existing dir name sets Err_error");
Err_set_error(NULL);
outstream = Folder_Open_Out(folder, &foo_bar_baz_boffo);
TEST_TRUE(batch, outstream == NULL,
- "Open_Out for entry within non-existent dir fails");
+ "Open_Out for entry within non-existent dir fails");
TEST_TRUE(batch, Err_get_error() != NULL,
- "Open_Out for entry within non-existent dir sets Err_error");
+ "Open_Out for entry within non-existent dir sets Err_error");
DECREF(folder);
}
static void
-test_Open_In(TestBatch *batch)
-{
+test_Open_In(TestBatch *batch) {
Folder *folder = (Folder*)RAMFolder_new(NULL);
FileHandle *fh;
InStream *instream;
@@ -359,35 +350,34 @@ test_Open_In(TestBatch *batch)
DECREF(fh);
instream = Folder_Open_In(folder, &boffo);
- TEST_TRUE(batch, instream && InStream_Is_A(instream, INSTREAM),
- "Open_In");
+ TEST_TRUE(batch, instream && InStream_Is_A(instream, INSTREAM),
+ "Open_In");
DECREF(instream);
instream = Folder_Open_In(folder, &foo_boffo);
- TEST_TRUE(batch, instream && InStream_Is_A(instream, INSTREAM),
- "Open_In for nested file");
+ TEST_TRUE(batch, instream && InStream_Is_A(instream, INSTREAM),
+ "Open_In for nested file");
DECREF(instream);
Err_set_error(NULL);
instream = Folder_Open_In(folder, &foo);
TEST_TRUE(batch, instream == NULL,
- "Open_InStream on existing dir path fails");
+ "Open_InStream on existing dir path fails");
TEST_TRUE(batch, Err_get_error() != NULL,
- "Open_In on existing dir name sets Err_error");
+ "Open_In on existing dir name sets Err_error");
Err_set_error(NULL);
instream = Folder_Open_In(folder, &foo_bar_baz_boffo);
TEST_TRUE(batch, instream == NULL,
- "Open_In for entry within non-existent dir fails");
+ "Open_In for entry within non-existent dir fails");
TEST_TRUE(batch, Err_get_error() != NULL,
- "Open_In for entry within non-existent dir sets Err_error");
+ "Open_In for entry within non-existent dir sets Err_error");
DECREF(folder);
}
static void
-test_Delete(TestBatch *batch)
-{
+test_Delete(TestBatch *batch) {
Folder *folder = (Folder*)RAMFolder_new(NULL);
FileHandle *fh;
bool_t result;
@@ -396,8 +386,8 @@ test_Delete(TestBatch *batch)
Folder_MkDir(folder, &foo_bar);
fh = Folder_Open_FileHandle(folder, &boffo, FH_CREATE | FH_WRITE_ONLY);
DECREF(fh);
- fh = Folder_Open_FileHandle(folder, &foo_boffo,
- FH_CREATE | FH_WRITE_ONLY);
+ fh = Folder_Open_FileHandle(folder, &foo_boffo,
+ FH_CREATE | FH_WRITE_ONLY);
DECREF(fh);
Err_set_error(NULL);
@@ -408,14 +398,14 @@ test_Delete(TestBatch *batch)
result = Folder_Delete(folder, &foo);
TEST_FALSE(batch, result, "Delete on non-empty dir returns false");
- TEST_TRUE(batch, Folder_Delete(folder, &foo_boffo),
- "Delete nested file");
- TEST_FALSE(batch, Folder_Exists(folder, &foo_boffo),
- "File is really gone");
- TEST_TRUE(batch, Folder_Delete(folder, &foo_bar),
- "Delete nested dir");
- TEST_FALSE(batch, Folder_Exists(folder, &foo_bar),
- "Dir is really gone");
+ TEST_TRUE(batch, Folder_Delete(folder, &foo_boffo),
+ "Delete nested file");
+ TEST_FALSE(batch, Folder_Exists(folder, &foo_boffo),
+ "File is really gone");
+ TEST_TRUE(batch, Folder_Delete(folder, &foo_bar),
+ "Delete nested dir");
+ TEST_FALSE(batch, Folder_Exists(folder, &foo_bar),
+ "Dir is really gone");
TEST_TRUE(batch, Folder_Delete(folder, &foo), "Delete empty dir");
TEST_FALSE(batch, Folder_Exists(folder, &foo), "Dir is really gone");
@@ -423,8 +413,7 @@ test_Delete(TestBatch *batch)
}
static void
-test_Delete_Tree(TestBatch *batch)
-{
+test_Delete_Tree(TestBatch *batch) {
Folder *folder = (Folder*)RAMFolder_new(NULL);
FileHandle *fh;
bool_t result;
@@ -433,8 +422,8 @@ test_Delete_Tree(TestBatch *batch)
Folder_MkDir(folder, &foo);
Folder_MkDir(folder, &foo_bar);
Folder_MkDir(folder, &foo_bar_baz);
- fh = Folder_Open_FileHandle(folder, &foo_bar_baz_boffo,
- FH_CREATE | FH_WRITE_ONLY);
+ fh = Folder_Open_FileHandle(folder, &foo_bar_baz_boffo,
+ FH_CREATE | FH_WRITE_ONLY);
DECREF(fh);
// Create bystanders.
@@ -446,10 +435,10 @@ test_Delete_Tree(TestBatch *batch)
TEST_TRUE(batch, result, "Delete_Tree() succeeded");
TEST_FALSE(batch, Folder_Exists(folder, &foo), "Tree really gone");
- TEST_TRUE(batch, Folder_Exists(folder, &bar),
- "local dir with same name as nested dir left intact");
- TEST_TRUE(batch, Folder_Exists(folder, &baz),
- "local file with same name as nested dir left intact");
+ TEST_TRUE(batch, Folder_Exists(folder, &bar),
+ "local dir with same name as nested dir left intact");
+ TEST_TRUE(batch, Folder_Exists(folder, &baz),
+ "local file with same name as nested dir left intact");
// Kill off the bystanders.
result = Folder_Delete_Tree(folder, &bar);
@@ -461,27 +450,26 @@ test_Delete_Tree(TestBatch *batch)
Folder_MkDir(folder, &foo);
Folder_MkDir(folder, &foo_bar);
Folder_MkDir(folder, &foo_bar_baz);
- fh = Folder_Open_FileHandle(folder, &foo_bar_baz_boffo,
- FH_CREATE | FH_WRITE_ONLY);
+ fh = Folder_Open_FileHandle(folder, &foo_bar_baz_boffo,
+ FH_CREATE | FH_WRITE_ONLY);
DECREF(fh);
// Remove tree in subdir.
result = Folder_Delete_Tree(folder, &foo_bar);
TEST_TRUE(batch, result, "Delete_Tree() of subdir succeeded");
- TEST_FALSE(batch, Folder_Exists(folder, &foo_bar),
- "subdir really gone");
- TEST_TRUE(batch, Folder_Exists(folder, &foo),
- "enclosing dir left intact");
+ TEST_FALSE(batch, Folder_Exists(folder, &foo_bar),
+ "subdir really gone");
+ TEST_TRUE(batch, Folder_Exists(folder, &foo),
+ "enclosing dir left intact");
DECREF(folder);
}
static void
-test_Slurp_File(TestBatch *batch)
-{
+test_Slurp_File(TestBatch *batch) {
Folder *folder = (Folder*)RAMFolder_new(NULL);
- FileHandle *fh = Folder_Open_FileHandle(folder, &foo,
- FH_CREATE | FH_WRITE_ONLY);
+ FileHandle *fh = Folder_Open_FileHandle(folder, &foo,
+ FH_CREATE | FH_WRITE_ONLY);
ByteBuf *contents;
FH_Write(fh, "stuff", 5);
@@ -495,8 +483,7 @@ test_Slurp_File(TestBatch *batch)
}
void
-TestFolder_run_tests()
-{
+TestFolder_run_tests() {
TestBatch *batch = TestBatch_new(79);
TestBatch_Plan(batch);