From b50a07651606849fd1f9ddd971f754287891e5c0 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 7 Sep 2009 10:07:50 +0200 Subject: [PATCH 1/1] Reformat --- src/test_config.c | 172 ++++++++++++++++++++++++------------------------- src/test_record.c | 184 +++++++++++++++++++++++++---------------------------- 2 files changed, 174 insertions(+), 182 deletions(-) diff --git a/src/test_config.c b/src/test_config.c index fce75c5..8ecfa24 100644 --- a/src/test_config.c +++ b/src/test_config.c @@ -34,93 +34,93 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA void test_conf_service(int argc, char **argv) { - struct conf_service *service = 0; - service = conf_service_create(4, 3); - - YAZ_CHECK(service); - - // expected metadata failures - YAZ_CHECK(!conf_service_add_metadata(0, 0, "service_needed", - Metadata_type_generic, - Metadata_merge_unique, - Metadata_setting_no, - 1, 1, 1, 0, - Metadata_mergekey_no)); - - YAZ_CHECK(!conf_service_add_metadata(service, -1, "out_of_bounds", - Metadata_type_generic, - Metadata_merge_unique, - Metadata_setting_no, - 1, 1, 1, 0, - Metadata_mergekey_no)); - - YAZ_CHECK(!conf_service_add_metadata(service, 4, "out_of_bounds", - Metadata_type_generic, - Metadata_merge_unique, - Metadata_setting_no, - 1, 1, 1, 0, - Metadata_mergekey_no)); - - YAZ_CHECK(!conf_service_add_metadata(service, 0, 0, //missing name - Metadata_type_generic, - Metadata_merge_unique, - Metadata_setting_no, - 1, 1, 1, 0, - Metadata_mergekey_no)); - - // expected metadata sucesses - YAZ_CHECK(conf_service_add_metadata(service, 0, "title", - Metadata_type_generic, - Metadata_merge_unique, - Metadata_setting_no, - 1, 1, 1, 0, - Metadata_mergekey_no)); - - YAZ_CHECK(conf_service_add_metadata(service, 1, "author", - Metadata_type_generic, - Metadata_merge_longest, - Metadata_setting_no, - 1, 1, 1, 0, - Metadata_mergekey_no)); - - YAZ_CHECK(conf_service_add_metadata(service, 2, "isbn", - Metadata_type_number, - Metadata_merge_no, - Metadata_setting_no, - 1, 1, 1, 0, - Metadata_mergekey_no)); - - YAZ_CHECK(conf_service_add_metadata(service, 3, "year", - Metadata_type_year, - Metadata_merge_range, - Metadata_setting_no, - 1, 1, 1, 0, - Metadata_mergekey_no)); - - - // expected sortkey failures - YAZ_CHECK(!conf_service_add_sortkey(service, -1, "out_of_bounds", - Metadata_sortkey_skiparticle)); - - YAZ_CHECK(!conf_service_add_sortkey(service, -1, "out_of_bounds", - Metadata_sortkey_string)); - - YAZ_CHECK(!conf_service_add_sortkey(service, 3, "out_of_bounds", - Metadata_sortkey_relevance)); - - YAZ_CHECK(!conf_service_add_sortkey(service, 0, 0, //missing name - Metadata_sortkey_relevance)); - - - // expected sortkey sucess - YAZ_CHECK(conf_service_add_sortkey(service, 0, "relevance", - Metadata_sortkey_relevance)); - - YAZ_CHECK(conf_service_add_sortkey(service, 1, "title", - Metadata_sortkey_string)); + struct conf_service *service = 0; + service = conf_service_create(4, 3); + + YAZ_CHECK(service); + + // expected metadata failures + YAZ_CHECK(!conf_service_add_metadata(0, 0, "service_needed", + Metadata_type_generic, + Metadata_merge_unique, + Metadata_setting_no, + 1, 1, 1, 0, + Metadata_mergekey_no)); + + YAZ_CHECK(!conf_service_add_metadata(service, -1, "out_of_bounds", + Metadata_type_generic, + Metadata_merge_unique, + Metadata_setting_no, + 1, 1, 1, 0, + Metadata_mergekey_no)); + + YAZ_CHECK(!conf_service_add_metadata(service, 4, "out_of_bounds", + Metadata_type_generic, + Metadata_merge_unique, + Metadata_setting_no, + 1, 1, 1, 0, + Metadata_mergekey_no)); + + YAZ_CHECK(!conf_service_add_metadata(service, 0, 0, //missing name + Metadata_type_generic, + Metadata_merge_unique, + Metadata_setting_no, + 1, 1, 1, 0, + Metadata_mergekey_no)); + + // expected metadata sucesses + YAZ_CHECK(conf_service_add_metadata(service, 0, "title", + Metadata_type_generic, + Metadata_merge_unique, + Metadata_setting_no, + 1, 1, 1, 0, + Metadata_mergekey_no)); + + YAZ_CHECK(conf_service_add_metadata(service, 1, "author", + Metadata_type_generic, + Metadata_merge_longest, + Metadata_setting_no, + 1, 1, 1, 0, + Metadata_mergekey_no)); + + YAZ_CHECK(conf_service_add_metadata(service, 2, "isbn", + Metadata_type_number, + Metadata_merge_no, + Metadata_setting_no, + 1, 1, 1, 0, + Metadata_mergekey_no)); + + YAZ_CHECK(conf_service_add_metadata(service, 3, "year", + Metadata_type_year, + Metadata_merge_range, + Metadata_setting_no, + 1, 1, 1, 0, + Metadata_mergekey_no)); + + + // expected sortkey failures + YAZ_CHECK(!conf_service_add_sortkey(service, -1, "out_of_bounds", + Metadata_sortkey_skiparticle)); + + YAZ_CHECK(!conf_service_add_sortkey(service, -1, "out_of_bounds", + Metadata_sortkey_string)); + + YAZ_CHECK(!conf_service_add_sortkey(service, 3, "out_of_bounds", + Metadata_sortkey_relevance)); + + YAZ_CHECK(!conf_service_add_sortkey(service, 0, 0, //missing name + Metadata_sortkey_relevance)); + + + // expected sortkey sucess + YAZ_CHECK(conf_service_add_sortkey(service, 0, "relevance", + Metadata_sortkey_relevance)); + + YAZ_CHECK(conf_service_add_sortkey(service, 1, "title", + Metadata_sortkey_string)); - YAZ_CHECK(conf_service_add_sortkey(service, 2, "year", - Metadata_sortkey_numeric)); + YAZ_CHECK(conf_service_add_sortkey(service, 2, "year", + Metadata_sortkey_numeric)); } diff --git a/src/test_record.c b/src/test_record.c index 45bf9d0..7ff8996 100644 --- a/src/test_record.c +++ b/src/test_record.c @@ -31,117 +31,113 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "pazpar2_config.h" #include "record.h" - - void test_record(int argc, char **argv) { - NMEM nmem = nmem_create(); - - struct conf_service *service = 0; - struct record *record = 0; - - struct client *client = 0; - char * bla = "blabla"; - union data_types data_text; - union data_types data_num; - struct record_metadata * tmp_md = 0; - - data_text.text.disp = bla; - data_text.text.sort = bla; - - data_num.number.min = 2; - data_num.number.max = 5; - - - service = conf_service_create(4, 3); - YAZ_CHECK(service); - - YAZ_CHECK(conf_service_add_metadata( - service, 0, "title", - Metadata_type_generic, Metadata_merge_unique, - Metadata_setting_no, 1, 1, 1, 0, - Metadata_mergekey_no - )); - - YAZ_CHECK(conf_service_add_metadata( - service, 1, "author", - Metadata_type_generic, Metadata_merge_longest, - Metadata_setting_no,1, 1, 1, 0, - Metadata_mergekey_no)); - - YAZ_CHECK(conf_service_add_metadata( - service, 2, "isbn", - Metadata_type_number, Metadata_merge_no, - Metadata_setting_no, 1, 1, 1, 0, - Metadata_mergekey_no)); - - YAZ_CHECK(conf_service_add_metadata( - service, 3, "year", - Metadata_type_year, Metadata_merge_range, - Metadata_setting_no, 1, 1, 1, 0, - Metadata_mergekey_no)); - - YAZ_CHECK(conf_service_add_sortkey( - service, 0, "relevance", - Metadata_sortkey_relevance)); + NMEM nmem = nmem_create(); + + struct conf_service *service = 0; + struct record *record = 0; + + struct client *client = 0; + char * bla = "blabla"; + union data_types data_text; + union data_types data_num; + struct record_metadata * tmp_md = 0; + + data_text.text.disp = bla; + data_text.text.sort = bla; + + data_num.number.min = 2; + data_num.number.max = 5; + + + service = conf_service_create(4, 3); + YAZ_CHECK(service); + + YAZ_CHECK(conf_service_add_metadata( + service, 0, "title", + Metadata_type_generic, Metadata_merge_unique, + Metadata_setting_no, 1, 1, 1, 0, + Metadata_mergekey_no + )); + + YAZ_CHECK(conf_service_add_metadata( + service, 1, "author", + Metadata_type_generic, Metadata_merge_longest, + Metadata_setting_no,1, 1, 1, 0, + Metadata_mergekey_no)); + + YAZ_CHECK(conf_service_add_metadata( + service, 2, "isbn", + Metadata_type_number, Metadata_merge_no, + Metadata_setting_no, 1, 1, 1, 0, + Metadata_mergekey_no)); + + YAZ_CHECK(conf_service_add_metadata( + service, 3, "year", + Metadata_type_year, Metadata_merge_range, + Metadata_setting_no, 1, 1, 1, 0, + Metadata_mergekey_no)); + + YAZ_CHECK(conf_service_add_sortkey( + service, 0, "relevance", + Metadata_sortkey_relevance)); - YAZ_CHECK(conf_service_add_sortkey( - service, 1, "title", - Metadata_sortkey_string)); + YAZ_CHECK(conf_service_add_sortkey( + service, 1, "title", + Metadata_sortkey_string)); - YAZ_CHECK(conf_service_add_sortkey( - service, 2, "year", - Metadata_sortkey_numeric)); + YAZ_CHECK(conf_service_add_sortkey( + service, 2, "year", + Metadata_sortkey_numeric)); - // testing record things - record = record_create(nmem, 4, 3, client, 1); - YAZ_CHECK(record); - - tmp_md = record_metadata_insert(nmem, &(record->metadata[0]), data_text); - YAZ_CHECK(tmp_md); - YAZ_CHECK(0 == record->metadata[0]->next); + // testing record things + record = record_create(nmem, 4, 3, client, 1); + YAZ_CHECK(record); - tmp_md = record_metadata_insert(nmem, &(record->metadata[0]->next), - data_text); - YAZ_CHECK(tmp_md); - YAZ_CHECK(record->metadata[0]->next); + tmp_md = record_metadata_insert(nmem, &(record->metadata[0]), data_text); + YAZ_CHECK(tmp_md); + YAZ_CHECK(0 == record->metadata[0]->next); - YAZ_CHECK(record_add_metadata_field_id(nmem, record, 3, data_num)); - YAZ_CHECK(0 == record->metadata[3]->next); - YAZ_CHECK(record_add_metadata_field_id(nmem, record, 3, data_num)); - YAZ_CHECK(record->metadata[3]->next); + tmp_md = record_metadata_insert(nmem, &(record->metadata[0]->next), + data_text); + YAZ_CHECK(tmp_md); + YAZ_CHECK(record->metadata[0]->next); - YAZ_CHECK(record_add_metadata(nmem, record, service, "author", data_text)); - YAZ_CHECK(0 == record->metadata[1]->next); - YAZ_CHECK(record_add_metadata(nmem, record, service, "author", data_text)); - YAZ_CHECK(record->metadata[1]->next); + YAZ_CHECK(record_add_metadata_field_id(nmem, record, 3, data_num)); + YAZ_CHECK(0 == record->metadata[3]->next); + YAZ_CHECK(record_add_metadata_field_id(nmem, record, 3, data_num)); + YAZ_CHECK(record->metadata[3]->next); + YAZ_CHECK(record_add_metadata(nmem, record, service, "author", data_text)); + YAZ_CHECK(0 == record->metadata[1]->next); + YAZ_CHECK(record_add_metadata(nmem, record, service, "author", data_text)); + YAZ_CHECK(record->metadata[1]->next); - YAZ_CHECK(0 == record->sortkeys[0]); - YAZ_CHECK(record_assign_sortkey_field_id(nmem, record, 0, data_text)); - YAZ_CHECK(record->sortkeys[0]); - YAZ_CHECK(0 == record->sortkeys[1]); - YAZ_CHECK(record_assign_sortkey_field_id(nmem, record, 1, data_text)); - YAZ_CHECK(record->sortkeys[1]); - YAZ_CHECK(0 == record->sortkeys[2]); - YAZ_CHECK(record_assign_sortkey_field_id(nmem, record, 2, data_num)); - YAZ_CHECK(record->sortkeys[2]); + YAZ_CHECK(0 == record->sortkeys[0]); + YAZ_CHECK(record_assign_sortkey_field_id(nmem, record, 0, data_text)); + YAZ_CHECK(record->sortkeys[0]); + YAZ_CHECK(0 == record->sortkeys[1]); + YAZ_CHECK(record_assign_sortkey_field_id(nmem, record, 1, data_text)); + YAZ_CHECK(record->sortkeys[1]); + YAZ_CHECK(0 == record->sortkeys[2]); + YAZ_CHECK(record_assign_sortkey_field_id(nmem, record, 2, data_num)); + YAZ_CHECK(record->sortkeys[2]); - YAZ_CHECK(record_assign_sortkey(nmem, record, service, "relevance", data_text)); - YAZ_CHECK(record_assign_sortkey(nmem, record, service, "title", data_text)); - YAZ_CHECK(record_assign_sortkey(nmem, record, service, "year", data_num)); + YAZ_CHECK(record_assign_sortkey(nmem, record, service, "relevance", data_text)); + YAZ_CHECK(record_assign_sortkey(nmem, record, service, "title", data_text)); + YAZ_CHECK(record_assign_sortkey(nmem, record, service, "year", data_num)); + nmem_destroy(nmem); - nmem_destroy(nmem); - - //YAZ_CHECK(0 == 0); - //YAZ_CHECK_EQ(0, 1); + //YAZ_CHECK(0 == 0); + //YAZ_CHECK_EQ(0, 1); } @@ -150,16 +146,12 @@ int main(int argc, char **argv) YAZ_CHECK_INIT(argc, argv); YAZ_CHECK_LOG(); - test_record(argc, argv); - YAZ_CHECK_TERM; } - - /* * Local variables: * c-basic-offset: 4 -- 1.7.10.4