isomorfeus-ferret 0.17.2 → 0.17.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. checksums.yaml +4 -4
  2. data/ext/isomorfeus_ferret_ext/benchmark.c +9 -20
  3. data/ext/isomorfeus_ferret_ext/benchmarks_all.h +1 -2
  4. data/ext/isomorfeus_ferret_ext/bm_hash.c +1 -2
  5. data/ext/isomorfeus_ferret_ext/brotli_dec_decode.c +4 -2
  6. data/ext/isomorfeus_ferret_ext/brotli_enc_encode.c +3 -2
  7. data/ext/isomorfeus_ferret_ext/frb_analysis.c +4 -5
  8. data/ext/isomorfeus_ferret_ext/frb_field_info.c +3 -4
  9. data/ext/isomorfeus_ferret_ext/frb_index.c +118 -125
  10. data/ext/isomorfeus_ferret_ext/frb_lazy_doc.c +14 -16
  11. data/ext/isomorfeus_ferret_ext/frb_search.c +31 -23
  12. data/ext/isomorfeus_ferret_ext/frb_store.c +27 -13
  13. data/ext/isomorfeus_ferret_ext/frb_utils.c +3 -6
  14. data/ext/isomorfeus_ferret_ext/frt_analysis.c +39 -46
  15. data/ext/isomorfeus_ferret_ext/frt_analysis.h +9 -9
  16. data/ext/isomorfeus_ferret_ext/frt_array.c +11 -22
  17. data/ext/isomorfeus_ferret_ext/frt_bitvector.h +3 -6
  18. data/ext/isomorfeus_ferret_ext/frt_doc_field.c +87 -0
  19. data/ext/isomorfeus_ferret_ext/frt_doc_field.h +26 -0
  20. data/ext/isomorfeus_ferret_ext/frt_document.c +4 -97
  21. data/ext/isomorfeus_ferret_ext/frt_document.h +2 -27
  22. data/ext/isomorfeus_ferret_ext/frt_except.c +8 -6
  23. data/ext/isomorfeus_ferret_ext/frt_except.h +1 -2
  24. data/ext/isomorfeus_ferret_ext/frt_field_index.c +13 -32
  25. data/ext/isomorfeus_ferret_ext/frt_field_index.h +0 -6
  26. data/ext/isomorfeus_ferret_ext/frt_field_info.c +69 -0
  27. data/ext/isomorfeus_ferret_ext/frt_field_info.h +49 -0
  28. data/ext/isomorfeus_ferret_ext/frt_field_infos.c +196 -0
  29. data/ext/isomorfeus_ferret_ext/frt_field_infos.h +35 -0
  30. data/ext/isomorfeus_ferret_ext/frt_global.c +10 -4
  31. data/ext/isomorfeus_ferret_ext/frt_global.h +11 -15
  32. data/ext/isomorfeus_ferret_ext/frt_hash.c +8 -8
  33. data/ext/isomorfeus_ferret_ext/frt_hash.h +1 -2
  34. data/ext/isomorfeus_ferret_ext/frt_hashset.c +20 -40
  35. data/ext/isomorfeus_ferret_ext/frt_hashset.h +1 -2
  36. data/ext/isomorfeus_ferret_ext/frt_helper.c +7 -15
  37. data/ext/isomorfeus_ferret_ext/frt_in_stream.c +35 -45
  38. data/ext/isomorfeus_ferret_ext/frt_in_stream.h +3 -2
  39. data/ext/isomorfeus_ferret_ext/frt_ind.c +20 -38
  40. data/ext/isomorfeus_ferret_ext/frt_index.c +292 -790
  41. data/ext/isomorfeus_ferret_ext/frt_index.h +1 -102
  42. data/ext/isomorfeus_ferret_ext/frt_lang.c +5 -10
  43. data/ext/isomorfeus_ferret_ext/frt_lazy_doc.c +3 -3
  44. data/ext/isomorfeus_ferret_ext/frt_lazy_doc.h +1 -1
  45. data/ext/isomorfeus_ferret_ext/frt_lazy_doc_field.c +18 -25
  46. data/ext/isomorfeus_ferret_ext/frt_lazy_doc_field.h +5 -5
  47. data/ext/isomorfeus_ferret_ext/frt_mdbx_store.c +102 -70
  48. data/ext/isomorfeus_ferret_ext/frt_mempool.c +8 -16
  49. data/ext/isomorfeus_ferret_ext/frt_multimapper.c +23 -46
  50. data/ext/isomorfeus_ferret_ext/frt_multimapper.h +4 -8
  51. data/ext/isomorfeus_ferret_ext/frt_out_stream.c +31 -43
  52. data/ext/isomorfeus_ferret_ext/frt_out_stream.h +2 -2
  53. data/ext/isomorfeus_ferret_ext/frt_posh.c +6 -819
  54. data/ext/isomorfeus_ferret_ext/frt_posh.h +0 -57
  55. data/ext/isomorfeus_ferret_ext/frt_priorityqueue.c +11 -22
  56. data/ext/isomorfeus_ferret_ext/frt_priorityqueue.h +1 -2
  57. data/ext/isomorfeus_ferret_ext/frt_q_boolean.c +85 -171
  58. data/ext/isomorfeus_ferret_ext/frt_q_match_all.c +8 -16
  59. data/ext/isomorfeus_ferret_ext/frt_q_multi_term.c +1 -2
  60. data/ext/isomorfeus_ferret_ext/frt_q_parser.c +49 -98
  61. data/ext/isomorfeus_ferret_ext/frt_q_phrase.c +52 -104
  62. data/ext/isomorfeus_ferret_ext/frt_q_range.c +6 -12
  63. data/ext/isomorfeus_ferret_ext/frt_q_span.c +113 -226
  64. data/ext/isomorfeus_ferret_ext/frt_q_wildcard.c +1 -2
  65. data/ext/isomorfeus_ferret_ext/frt_ram_store.c +134 -85
  66. data/ext/isomorfeus_ferret_ext/frt_search.c +82 -164
  67. data/ext/isomorfeus_ferret_ext/frt_similarity.c +11 -22
  68. data/ext/isomorfeus_ferret_ext/frt_similarity.h +1 -2
  69. data/ext/isomorfeus_ferret_ext/frt_store.c +13 -25
  70. data/ext/isomorfeus_ferret_ext/frt_store.h +86 -52
  71. data/ext/isomorfeus_ferret_ext/frt_term_vectors.c +8 -16
  72. data/ext/isomorfeus_ferret_ext/frt_win32.h +5 -10
  73. data/ext/isomorfeus_ferret_ext/isomorfeus_ferret.c +12 -11
  74. data/ext/isomorfeus_ferret_ext/isomorfeus_ferret.h +11 -13
  75. data/ext/isomorfeus_ferret_ext/lz4.c +422 -195
  76. data/ext/isomorfeus_ferret_ext/lz4.h +114 -46
  77. data/ext/isomorfeus_ferret_ext/lz4frame.c +421 -242
  78. data/ext/isomorfeus_ferret_ext/lz4frame.h +122 -53
  79. data/ext/isomorfeus_ferret_ext/lz4hc.c +127 -111
  80. data/ext/isomorfeus_ferret_ext/lz4hc.h +14 -14
  81. data/ext/isomorfeus_ferret_ext/lz4xxhash.h +1 -1
  82. data/ext/isomorfeus_ferret_ext/mdbx.c +3762 -2526
  83. data/ext/isomorfeus_ferret_ext/mdbx.h +115 -70
  84. data/ext/isomorfeus_ferret_ext/test.c +40 -87
  85. data/ext/isomorfeus_ferret_ext/test.h +3 -6
  86. data/ext/isomorfeus_ferret_ext/test_1710.c +11 -13
  87. data/ext/isomorfeus_ferret_ext/test_analysis.c +32 -64
  88. data/ext/isomorfeus_ferret_ext/test_array.c +6 -12
  89. data/ext/isomorfeus_ferret_ext/test_bitvector.c +12 -24
  90. data/ext/isomorfeus_ferret_ext/test_document.c +23 -33
  91. data/ext/isomorfeus_ferret_ext/test_except.c +10 -21
  92. data/ext/isomorfeus_ferret_ext/test_fields.c +62 -68
  93. data/ext/isomorfeus_ferret_ext/test_file_deleter.c +15 -23
  94. data/ext/isomorfeus_ferret_ext/test_filter.c +17 -27
  95. data/ext/isomorfeus_ferret_ext/test_global.c +14 -29
  96. data/ext/isomorfeus_ferret_ext/test_hash.c +19 -38
  97. data/ext/isomorfeus_ferret_ext/test_hashset.c +8 -16
  98. data/ext/isomorfeus_ferret_ext/test_helper.c +4 -8
  99. data/ext/isomorfeus_ferret_ext/test_highlighter.c +16 -28
  100. data/ext/isomorfeus_ferret_ext/test_index.c +277 -487
  101. data/ext/isomorfeus_ferret_ext/test_lang.c +7 -14
  102. data/ext/isomorfeus_ferret_ext/test_mdbx_store.c +2 -5
  103. data/ext/isomorfeus_ferret_ext/test_mempool.c +5 -10
  104. data/ext/isomorfeus_ferret_ext/test_multimapper.c +3 -6
  105. data/ext/isomorfeus_ferret_ext/test_priorityqueue.c +9 -18
  106. data/ext/isomorfeus_ferret_ext/test_q_const_score.c +4 -6
  107. data/ext/isomorfeus_ferret_ext/test_q_filtered.c +3 -4
  108. data/ext/isomorfeus_ferret_ext/test_q_fuzzy.c +9 -15
  109. data/ext/isomorfeus_ferret_ext/test_q_parser.c +8 -16
  110. data/ext/isomorfeus_ferret_ext/test_q_span.c +19 -35
  111. data/ext/isomorfeus_ferret_ext/test_ram_store.c +14 -13
  112. data/ext/isomorfeus_ferret_ext/test_search.c +60 -109
  113. data/ext/isomorfeus_ferret_ext/test_segments.c +8 -13
  114. data/ext/isomorfeus_ferret_ext/test_similarity.c +2 -4
  115. data/ext/isomorfeus_ferret_ext/test_sort.c +14 -24
  116. data/ext/isomorfeus_ferret_ext/test_store.c +96 -115
  117. data/ext/isomorfeus_ferret_ext/test_term.c +9 -15
  118. data/ext/isomorfeus_ferret_ext/test_term_vectors.c +9 -14
  119. data/ext/isomorfeus_ferret_ext/test_test.c +4 -8
  120. data/ext/isomorfeus_ferret_ext/test_threading.c +14 -20
  121. data/ext/isomorfeus_ferret_ext/testhelper.c +11 -21
  122. data/ext/isomorfeus_ferret_ext/testhelper.h +1 -1
  123. data/ext/isomorfeus_ferret_ext/tests_all.h +1 -2
  124. data/lib/isomorfeus/ferret/index/index.rb +1 -1
  125. data/lib/isomorfeus/ferret/version.rb +1 -1
  126. metadata +24 -4
@@ -21,44 +21,37 @@ static FrtFieldInfos *prep_fis(void) {
21
21
  return frt_fis_new(0 | FRT_FI_IS_INDEXED_BM | FRT_FI_IS_TOKENIZED_BM);
22
22
  }
23
23
 
24
- static void create_index(FrtStore *store)
25
- {
24
+ static void create_index(FrtStore *store) {
26
25
  FrtFieldInfos *fis = prep_fis();
27
26
  frt_index_create(store, fis);
28
27
  frt_fis_deref(fis);
29
28
  }
30
29
 
31
- static FrtIndexWriter *create_iw_lucene(FrtStore *store)
32
- {
30
+ static FrtIndexWriter *create_iw_lucene(FrtStore *store) {
33
31
  create_index(store);
34
32
  return frt_iw_open(NULL, store, frt_whitespace_analyzer_new(false), &lucene_config);
35
33
  }
36
34
 
37
- static void add_doc(FrtIndexWriter *iw, int id)
38
- {
35
+ static void add_doc(FrtIndexWriter *iw, int id) {
39
36
  FrtDocument *doc = frt_doc_new();
40
37
  rb_encoding *enc = rb_enc_find("ASCII-8BIT");
41
38
 
42
- frt_doc_add_field(doc, frt_df_add_data(frt_df_new(rb_intern(content_f)),
43
- frt_estrdup("aaa"), enc))->destroy_data = true;
44
- frt_doc_add_field(doc, frt_df_add_data(frt_df_new(rb_intern(id_f)),
45
- frt_strfmt("%d", id), enc))->destroy_data = true;
39
+ frt_doc_add_field(doc, frt_df_add_data(frt_df_new(rb_intern(content_f)), "aaa", enc));
40
+ frt_doc_add_field(doc, frt_df_add_data(frt_df_new(rb_intern(id_f)), frt_strfmt("%d", id), enc));
46
41
  frt_iw_add_doc(iw, doc);
47
- frt_doc_destroy(doc);
42
+ frt_doc_destroy(doc);
48
43
  }
49
44
 
50
- static void add_docs(FrtIndexWriter *iw, int count)
51
- {
45
+ static void add_docs(FrtIndexWriter *iw, int count) {
52
46
  int i;
53
47
  for (i = 0; i < count; i++) {
54
48
  add_doc(iw, i);
55
49
  }
56
50
  }
57
51
 
58
- static void copy_file(FrtStore *store, const char *src, const char *dest)
59
- {
60
- FrtInStream *is = store->open_input(store, src);
61
- FrtOutStream *os = store->new_output(store, dest);
52
+ static void copy_file(FrtStore *store, const char *src, const char *dest) {
53
+ FrtInStream *is = store->open_input(store, segm_idx_name, src);
54
+ FrtOutStream *os = store->new_output(store, segm_idx_name, dest);
62
55
  frt_is2os_copy_bytes(is, os, frt_is_length(is));
63
56
  frt_is_close(is);
64
57
  frt_os_close(os);
@@ -68,8 +61,7 @@ static void copy_file(FrtStore *store, const char *src, const char *dest)
68
61
  * Verify we can read the pre-XXX file format, do searches
69
62
  * against it, and add documents to it.
70
63
  */
71
- static void test_delete_leftover_files(TestCase *tc, void *data)
72
- {
64
+ static void test_delete_leftover_files(TestCase *tc, void *data) {
73
65
  FrtStore *store = (FrtStore *)data;
74
66
  FrtIndexWriter *iw = create_iw_lucene(store);
75
67
  FrtIndexReader *ir;
@@ -85,7 +77,7 @@ static void test_delete_leftover_files(TestCase *tc, void *data)
85
77
  /* Set one norm so we get a .s0 file: */
86
78
  frt_ir_set_norm(ir, 21, rb_intern(content_f), 12);
87
79
  frt_ir_close(ir);
88
- store_before = frt_store_to_s(store);
80
+ store_before = frt_store_folder_to_s(store, segm_idx_name);
89
81
 
90
82
  /* Create a bogus separate norms file for a
91
83
  * segment/field that actually has a separate norms file
@@ -127,7 +119,7 @@ static void test_delete_leftover_files(TestCase *tc, void *data)
127
119
  /* Open & close a writer: should delete the above files and nothing more: */
128
120
  frt_iw_close(frt_iw_open(NULL, store, frt_whitespace_analyzer_new(false), &lucene_config));
129
121
 
130
- store_after = frt_store_to_s(store);
122
+ store_after = frt_store_folder_to_s(store, segm_idx_name);
131
123
 
132
124
  Asequal(store_before, store_after);
133
125
  free(store_before);
@@ -140,9 +132,9 @@ static void test_delete_leftover_files(TestCase *tc, void *data)
140
132
  *
141
133
  ***************************************************************************/
142
134
 
143
- TestSuite *ts_file_deleter(TestSuite *suite)
144
- {
135
+ TestSuite *ts_file_deleter(TestSuite *suite) {
145
136
  FrtStore *store = frt_open_ram_store(NULL);
137
+ store->create_folder(store, segm_idx_name);
146
138
  suite = ADD_SUITE(suite);
147
139
 
148
140
  tst_run_test(suite, test_delete_leftover_files, store);
@@ -15,8 +15,7 @@ struct FilterData {
15
15
 
16
16
  static ID num, date, flipflop;
17
17
 
18
- void prepare_filter_index(FrtStore *store)
19
- {
18
+ void prepare_filter_index(FrtStore *store) {
20
19
  int i;
21
20
  FrtIndexWriter *iw;
22
21
  FrtFieldInfos *fis = frt_fis_new(0 | FRT_FI_IS_STORED_BM | FRT_FI_IS_INDEXED_BM | FRT_FI_IS_TOKENIZED_BM);
@@ -46,9 +45,9 @@ void prepare_filter_index(FrtStore *store)
46
45
  for (i = 0; i < FILTER_DOCS_SIZE; i++) {
47
46
  FrtDocument *doc = frt_doc_new();
48
47
  doc->boost = (float)(i+1);
49
- frt_doc_add_field(doc, frt_df_add_data(frt_df_new(num), (char *)data[i].num, enc));
50
- frt_doc_add_field(doc, frt_df_add_data(frt_df_new(date), (char *)data[i].date, enc));
51
- frt_doc_add_field(doc, frt_df_add_data(frt_df_new(flipflop), (char *)data[i].flipflop, enc));
48
+ frt_doc_add_field(doc, frt_df_add_data(frt_df_new(num), data[i].num, enc));
49
+ frt_doc_add_field(doc, frt_df_add_data(frt_df_new(date), data[i].date, enc));
50
+ frt_doc_add_field(doc, frt_df_add_data(frt_df_new(flipflop), data[i].flipflop, enc));
52
51
  frt_iw_add_doc(iw, doc);
53
52
  frt_doc_destroy(doc);
54
53
  }
@@ -56,8 +55,7 @@ void prepare_filter_index(FrtStore *store)
56
55
  return;
57
56
  }
58
57
 
59
- static void check_filtered_hits(TestCase *tc, FrtSearcher *searcher, FrtQuery *query, FrtFilter *f, FrtPostFilter *post_filter, const char *expected_hits, int top)
60
- {
58
+ static void check_filtered_hits(TestCase *tc, FrtSearcher *searcher, FrtQuery *query, FrtFilter *f, FrtPostFilter *post_filter, const char *expected_hits, int top) {
61
59
  static int num_array[ARRAY_SIZE];
62
60
  int i;
63
61
  int total_hits = s2l(expected_hits, num_array);
@@ -98,8 +96,7 @@ static void check_filtered_hits(TestCase *tc, FrtSearcher *searcher, FrtQuery *q
98
96
  free(fstr);\
99
97
  } while (0)
100
98
 
101
- static void test_range_filter(TestCase *tc, void *data)
102
- {
99
+ static void test_range_filter(TestCase *tc, void *data) {
103
100
  FrtSearcher *searcher = (FrtSearcher *)data;
104
101
  FrtQuery *q = frt_maq_new();
105
102
  FrtFilter *rf = frt_rfilt_new(num, "2", "6", true, true);
@@ -137,8 +134,7 @@ static void test_range_filter(TestCase *tc, void *data)
137
134
  frt_q_deref(q);
138
135
  }
139
136
 
140
- static void test_range_filter_hash(TestCase *tc, void *data)
141
- {
137
+ static void test_range_filter_hash(TestCase *tc, void *data) {
142
138
  FrtFilter *f1, *f2;
143
139
  (void)data;
144
140
  f1 = frt_rfilt_new(date, "20051006", "20051010", true, true);
@@ -193,8 +189,7 @@ static void test_range_filter_hash(TestCase *tc, void *data)
193
189
  frt_filt_deref(f1);
194
190
  }
195
191
 
196
- static void test_query_filter(TestCase *tc, void *data)
197
- {
192
+ static void test_query_filter(TestCase *tc, void *data) {
198
193
  FrtSearcher *searcher = (FrtSearcher *)data;
199
194
  FrtQuery *bq;
200
195
  FrtFilter *qf;
@@ -216,8 +211,7 @@ static void test_query_filter(TestCase *tc, void *data)
216
211
  frt_q_deref(q);
217
212
  }
218
213
 
219
- static void test_query_filter_hash(TestCase *tc, void *data)
220
- {
214
+ static void test_query_filter_hash(TestCase *tc, void *data) {
221
215
  FrtFilter *f1, *f2;
222
216
  (void)data;
223
217
  f1 = frt_qfilt_new_nr(frt_tq_new(rb_intern("A"), "a"));
@@ -241,12 +235,11 @@ static void test_query_filter_hash(TestCase *tc, void *data)
241
235
  frt_filt_deref(f1);
242
236
  }
243
237
 
244
- static float odd_number_filter(int doc_num, float score, FrtSearcher *sea, void *arg)
245
- {
238
+ static float odd_number_filter(int doc_num, float score, FrtSearcher *sea, void *arg) {
246
239
  float is_ok = 0.0;
247
240
  FrtLazyDoc *lazy_doc = frt_searcher_get_lazy_doc(sea, doc_num);
248
241
  FrtLazyDocField *lazy_df = frt_lazy_doc_get(lazy_doc, rb_intern("num"));
249
- char *num = frt_lazy_df_get_data(lazy_df, 0);
242
+ const char *num = frt_lazy_df_get_data(lazy_df, 0);
250
243
  (void)score;
251
244
  (void)arg;
252
245
 
@@ -258,13 +251,12 @@ static float odd_number_filter(int doc_num, float score, FrtSearcher *sea, void
258
251
  return is_ok;
259
252
  }
260
253
 
261
- static float distance_filter(int doc_num, float score, FrtSearcher *sea, void *arg)
262
- {
254
+ static float distance_filter(int doc_num, float score, FrtSearcher *sea, void *arg) {
263
255
  int start_point = *((int *)arg);
264
256
  float distance = 0.0;
265
257
  FrtLazyDoc *lazy_doc = frt_searcher_get_lazy_doc(sea, doc_num);
266
258
  FrtLazyDocField *lazy_df = frt_lazy_doc_get(lazy_doc, rb_intern("num"));
267
- char *num = frt_lazy_df_get_data(lazy_df, 0);
259
+ const char *num = frt_lazy_df_get_data(lazy_df, 0);
268
260
  (void)score;
269
261
 
270
262
  distance = 1.0/(1 + (start_point - atoi(num)) * (start_point - atoi(num)));
@@ -273,8 +265,7 @@ static float distance_filter(int doc_num, float score, FrtSearcher *sea, void *a
273
265
  return distance;
274
266
  }
275
267
 
276
- static void test_filter_func(TestCase *tc, void *data)
277
- {
268
+ static void test_filter_func(TestCase *tc, void *data) {
278
269
  FrtSearcher *searcher = (FrtSearcher *)data;
279
270
  FrtQuery *q = frt_maq_new();
280
271
  FrtFilter *rf = frt_rfilt_new(num, "2", "6", true, true);
@@ -290,8 +281,7 @@ static void test_filter_func(TestCase *tc, void *data)
290
281
  frt_q_deref(q);
291
282
  }
292
283
 
293
- static void test_score_altering_filter_func(TestCase *tc, void *data)
294
- {
284
+ static void test_score_altering_filter_func(TestCase *tc, void *data) {
295
285
  FrtSearcher *searcher = (FrtSearcher *)data;
296
286
  FrtQuery *q = frt_maq_new();
297
287
  FrtFilter *rf = frt_rfilt_new(num, "4", "8", true, true);
@@ -308,8 +298,7 @@ static void test_score_altering_filter_func(TestCase *tc, void *data)
308
298
  frt_q_deref(q);
309
299
  }
310
300
 
311
- TestSuite *ts_filter(TestSuite *suite)
312
- {
301
+ TestSuite *ts_filter(TestSuite *suite) {
313
302
  FrtStore *store;
314
303
  FrtIndexReader *ir;
315
304
  FrtSearcher *searcher;
@@ -317,6 +306,7 @@ TestSuite *ts_filter(TestSuite *suite)
317
306
  suite = ADD_SUITE(suite);
318
307
 
319
308
  store = frt_open_ram_store(NULL);
309
+ store->create_folder(store, segm_idx_name);
320
310
  prepare_filter_index(store);
321
311
  ir = frt_ir_open(NULL, store);
322
312
  searcher = frt_isea_new(ir);
@@ -2,13 +2,11 @@
2
2
  #include "test.h"
3
3
  #define _ISOC99_SOURCE
4
4
  #include <math.h>
5
- #include "fio_tmpfile.h"
6
5
 
7
6
  /**
8
7
  * Test min/max functions
9
8
  */
10
- static void test_min_max(TestCase *tc, void *data)
11
- {
9
+ static void test_min_max(TestCase *tc, void *data) {
12
10
  (void)data; /* suppress unused argument warning */
13
11
 
14
12
  Aiequal(2, FRT_MAX(2, 1));
@@ -47,8 +45,7 @@ static void test_min_max(TestCase *tc, void *data)
47
45
  /**
48
46
  * Test icmp
49
47
  */
50
- static void test_icmp(TestCase *tc, void *data)
51
- {
48
+ static void test_icmp(TestCase *tc, void *data) {
52
49
  (void)data; /* suppress unused argument warning */
53
50
  int a = 1, b = 2;
54
51
  int array[10] = {7,8,6,5,9,2,3,4,1,0};
@@ -65,8 +62,7 @@ static void test_icmp(TestCase *tc, void *data)
65
62
  /**
66
63
  * Test the various alloc functions
67
64
  */
68
- static void test_alloc(TestCase *tc, void *data)
69
- {
65
+ static void test_alloc(TestCase *tc, void *data) {
70
66
  data = frt_lmalloc(100);
71
67
  Aiequal(100, *(unsigned long *)data);
72
68
  free(data);
@@ -88,8 +84,7 @@ static void test_alloc(TestCase *tc, void *data)
88
84
  * Test the strfmt functions. This method is like sprintf except that it
89
85
  * allocates the necessary space for the string and pretty prints floats.
90
86
  */
91
- static void test_strfmt(TestCase *tc, void *data)
92
- {
87
+ static void test_strfmt(TestCase *tc, void *data) {
93
88
  char *s;
94
89
  (void)data; /* suppress unused argument warning */
95
90
 
@@ -134,8 +129,7 @@ static void test_strfmt(TestCase *tc, void *data)
134
129
  /**
135
130
  * Test dbl_to_s
136
131
  */
137
- static void test_dbl_to_s(TestCase *tc, void *data)
138
- {
132
+ static void test_dbl_to_s(TestCase *tc, void *data) {
139
133
  (void)data; /* suppress unused argument warning */
140
134
  char buf[100];
141
135
  Asequal("4.125123", frt_dbl_to_s(buf, 4.125123l));
@@ -145,8 +139,7 @@ static void test_dbl_to_s(TestCase *tc, void *data)
145
139
  Asequal("NaN", frt_dbl_to_s(buf, NAN));
146
140
  }
147
141
 
148
- static void test_count_leading_zeros(TestCase *tc, void *data)
149
- {
142
+ static void test_count_leading_zeros(TestCase *tc, void *data) {
150
143
  (void)data;
151
144
  Aiequal(32, frt_count_leading_zeros(0));
152
145
  Aiequal(31, frt_count_leading_zeros(1));
@@ -155,8 +148,7 @@ static void test_count_leading_zeros(TestCase *tc, void *data)
155
148
  Aiequal( 0, frt_count_leading_zeros(0xffffffff));
156
149
  }
157
150
 
158
- static void test_count_leading_ones(TestCase *tc, void *data)
159
- {
151
+ static void test_count_leading_ones(TestCase *tc, void *data) {
160
152
  (void)data;
161
153
  Aiequal( 0, frt_count_leading_ones(0));
162
154
  Aiequal( 0, frt_count_leading_ones(1));
@@ -165,8 +157,7 @@ static void test_count_leading_ones(TestCase *tc, void *data)
165
157
  Aiequal(32, frt_count_leading_ones(0xffffffff));
166
158
  }
167
159
 
168
- static void test_count_trailing_zeros(TestCase *tc, void *data)
169
- {
160
+ static void test_count_trailing_zeros(TestCase *tc, void *data) {
170
161
  (void)data;
171
162
  Aiequal(32, frt_count_trailing_zeros(0));
172
163
  Aiequal( 0, frt_count_trailing_zeros(1));
@@ -176,8 +167,7 @@ static void test_count_trailing_zeros(TestCase *tc, void *data)
176
167
  Aiequal( 0, frt_count_trailing_zeros(0xffffffff));
177
168
  }
178
169
 
179
- static void test_count_trailing_ones(TestCase *tc, void *data)
180
- {
170
+ static void test_count_trailing_ones(TestCase *tc, void *data) {
181
171
  (void)data;
182
172
  Aiequal( 0, frt_count_trailing_ones(0));
183
173
  Aiequal( 1, frt_count_trailing_ones(1));
@@ -187,8 +177,7 @@ static void test_count_trailing_ones(TestCase *tc, void *data)
187
177
  Aiequal(32, frt_count_trailing_ones(0xffffffff));
188
178
  }
189
179
 
190
- static void test_count_zeros(TestCase *tc, void *data)
191
- {
180
+ static void test_count_zeros(TestCase *tc, void *data) {
192
181
  (void)data;
193
182
  Aiequal(32, frt_count_zeros(0));
194
183
  Aiequal(31, frt_count_zeros(1));
@@ -198,8 +187,7 @@ static void test_count_zeros(TestCase *tc, void *data)
198
187
  Aiequal( 0, frt_count_zeros(0xffffffff));
199
188
  }
200
189
 
201
- static void test_count_ones(TestCase *tc, void *data)
202
- {
190
+ static void test_count_ones(TestCase *tc, void *data) {
203
191
  (void)data;
204
192
  Aiequal( 0, frt_count_ones(0));
205
193
  Aiequal( 1, frt_count_ones(1));
@@ -209,8 +197,7 @@ static void test_count_ones(TestCase *tc, void *data)
209
197
  Aiequal(32, frt_count_ones(0xffffffff));
210
198
  }
211
199
 
212
- static void test_round2(TestCase *tc, void *data)
213
- {
200
+ static void test_round2(TestCase *tc, void *data) {
214
201
  (void)data;
215
202
  Aiequal( 1, frt_round2(0));
216
203
  Aiequal( 2, frt_round2(1));
@@ -220,8 +207,7 @@ static void test_round2(TestCase *tc, void *data)
220
207
  Aiequal(2048, frt_round2(1024));
221
208
  }
222
209
 
223
- static void test_clean_up(TestCase *tc, void *data)
224
- {
210
+ static void test_clean_up(TestCase *tc, void *data) {
225
211
  (void)data;
226
212
  int i;
227
213
  /* excercise clean_up stack by adding enough objects to overflow stack */
@@ -231,8 +217,7 @@ static void test_clean_up(TestCase *tc, void *data)
231
217
  Assert(true, "This will really be tested by valgrind");
232
218
  }
233
219
 
234
- TestSuite *ts_global(TestSuite *suite)
235
- {
220
+ TestSuite *ts_global(TestSuite *suite) {
236
221
  suite = ADD_SUITE(suite);
237
222
 
238
223
  tst_run_test(suite, test_min_max, NULL);
@@ -5,22 +5,19 @@
5
5
  #include "test.h"
6
6
  #include "testhelper.h"
7
7
 
8
- static int *malloc_int(int val)
9
- {
8
+ static int *malloc_int(int val) {
10
9
  int *i = FRT_ALLOC(int);
11
10
  *i = val;
12
11
  return i;
13
12
  }
14
13
 
15
- static void mark_free(void *p)
16
- {
14
+ static void mark_free(void *p) {
17
15
  strcpy((char *)p, "freed");
18
16
  }
19
17
  /**
20
18
  * Basic test for string Hash. Make sure string can be retrieved
21
19
  */
22
- static void test_hash_str(TestCase *tc, void *data)
23
- {
20
+ static void test_hash_str(TestCase *tc, void *data) {
24
21
  FrtHash *h = frt_h_new_str(NULL, &free);
25
22
  FILE *f;
26
23
  char buf[100], *t;
@@ -70,27 +67,23 @@ static void test_hash_str(TestCase *tc, void *data)
70
67
  frt_h_destroy(h);
71
68
  }
72
69
 
73
- typedef struct Point
74
- {
70
+ typedef struct Point {
75
71
  int x;
76
72
  int y;
77
73
  } Point;
78
74
 
79
- static int point_eq(const void *q1, const void *q2)
80
- {
75
+ static int point_eq(const void *q1, const void *q2) {
81
76
  Point *p1 = (Point *)q1;
82
77
  Point *p2 = (Point *)q2;
83
78
  return p1->x == p2->x && p1->y == p2->y;
84
79
  }
85
80
 
86
- static unsigned long long point_hash(const void *q)
87
- {
81
+ static unsigned long point_hash(const void *q) {
88
82
  Point *p = (Point *)q;
89
83
  return p->x * p->y;
90
84
  }
91
85
 
92
- static Point *point_new(int x, int y)
93
- {
86
+ static Point *point_new(int x, int y) {
94
87
  Point *p = FRT_ALLOC(Point);
95
88
  p->x = x;
96
89
  p->y = y;
@@ -101,8 +94,7 @@ static Point *point_new(int x, int y)
101
94
  * Basic test for standard Hash. Make sure a non-string structure can be
102
95
  * used to key the Hash
103
96
  */
104
- static void test_hash_point(TestCase *tc, void *data)
105
- {
97
+ static void test_hash_point(TestCase *tc, void *data) {
106
98
  Point *p1 = point_new(1, 2);
107
99
  Point *p2 = point_new(2, 1);
108
100
  Point *p3 = point_new(1, 2);
@@ -145,8 +137,7 @@ static void test_hash_point(TestCase *tc, void *data)
145
137
  * integers as the key.
146
138
  */
147
139
  #define HASH_INT_TEST_SIZE 1000
148
- static void test_hash_int(TestCase *tc, void *data)
149
- {
140
+ static void test_hash_int(TestCase *tc, void *data) {
150
141
  int i;
151
142
  FrtHash *h = frt_h_new_int(&free);
152
143
  char buf[100];
@@ -197,8 +188,7 @@ static void test_hash_int(TestCase *tc, void *data)
197
188
  * pointers as the key.
198
189
  */
199
190
  #define HASH_INT_TEST_SIZE 1000
200
- static void test_hash_ptr(TestCase *tc, void *data)
201
- {
191
+ static void test_hash_ptr(TestCase *tc, void *data) {
202
192
  FrtHash *h = frt_h_new_ptr(&free);
203
193
  ID word1 = rb_intern("one");
204
194
  ID word2 = rb_intern("two");
@@ -245,8 +235,7 @@ static void test_hash_ptr(TestCase *tc, void *data)
245
235
  * don't take too long.
246
236
  */
247
237
  #define STRESS_SIZE 1000
248
- static void stress_hash(TestCase *tc, void *data)
249
- {
238
+ static void stress_hash(TestCase *tc, void *data) {
250
239
  int i, j, k;
251
240
  char buf[20];
252
241
  (void)data; /* suppress unused argument warning */
@@ -295,8 +284,7 @@ static void stress_hash(TestCase *tc, void *data)
295
284
  * Test that the hash table is ok while constantly growing and shrinking in
296
285
  * size
297
286
  */
298
- static void test_hash_up_and_down(TestCase *tc, void *data)
299
- {
287
+ static void test_hash_up_and_down(TestCase *tc, void *data) {
300
288
  int i, j;
301
289
  char buf[20];
302
290
 
@@ -337,12 +325,10 @@ static void test_hash_up_and_down(TestCase *tc, void *data)
337
325
  /**
338
326
  * Method used in frt_h_each test
339
327
  */
340
- static void test_each_ekv(void *key, void *value, FrtHash *h)
341
- {
328
+ static void test_each_ekv(void *key, void *value, FrtHash *h) {
342
329
  if ((strlen((char *)key) % 2) == 0) {
343
330
  frt_h_del(h, key);
344
- }
345
- else {
331
+ } else {
346
332
  frt_h_del(h, value);
347
333
  }
348
334
  }
@@ -352,8 +338,7 @@ static void test_each_ekv(void *key, void *value, FrtHash *h)
352
338
  *
353
339
  * There is also a test in here of the frt_h_each method.
354
340
  */
355
- static void test_hash_each_and_clone(TestCase *tc, void *data)
356
- {
341
+ static void test_hash_each_and_clone(TestCase *tc, void *data) {
357
342
  const char *strs[] = { "one", "two", "three", "four", "five", "six", "seven", NULL };
358
343
  const char **s = strs;
359
344
  FrtHash *h = frt_h_new_str(&free, &free);
@@ -413,15 +398,13 @@ struct StringArray {
413
398
  int size;
414
399
  };
415
400
 
416
- static void add_string_ekv(void *key, void *value, struct StringArray *str_arr)
417
- {
401
+ static void add_string_ekv(void *key, void *value, struct StringArray *str_arr) {
418
402
  (void)key; /* suppress unused argument warning */
419
403
  str_arr->strings[str_arr->cnt] = (char *)value;
420
404
  str_arr->cnt++;
421
405
  }
422
406
 
423
- static struct StringArray *frt_h_extract_strings(FrtHash *h)
424
- {
407
+ static struct StringArray *frt_h_extract_strings(FrtHash *h) {
425
408
  struct StringArray *str_arr = FRT_ALLOC(struct StringArray);
426
409
 
427
410
  str_arr->strings = FRT_ALLOC_N(char *, h->size);
@@ -437,8 +420,7 @@ static struct StringArray *frt_h_extract_strings(FrtHash *h)
437
420
  * Again, test the frt_h_each function, this time testing the example given in the
438
421
  * documentation for the each function.
439
422
  */
440
- static void test_hash_extract_strings(TestCase *tc, void *data)
441
- {
423
+ static void test_hash_extract_strings(TestCase *tc, void *data) {
442
424
  int i;
443
425
  struct StringArray *str_arr;
444
426
  const char *strs[] = {"one", "two", "three", "four", "five"};
@@ -469,8 +451,7 @@ static void test_hash_extract_strings(TestCase *tc, void *data)
469
451
  free(str_arr);
470
452
  }
471
453
 
472
- TestSuite *ts_hash(TestSuite *suite)
473
- {
454
+ TestSuite *ts_hash(TestSuite *suite) {
474
455
  suite = ADD_SUITE(suite);
475
456
 
476
457
  tst_run_test(suite, test_hash_str, NULL);
@@ -6,8 +6,7 @@
6
6
  * Test basic FrtHashSet functions like adding elements and testing for
7
7
  * existence.
8
8
  */
9
- static void test_hs(TestCase *tc, void *data)
10
- {
9
+ static void test_hs(TestCase *tc, void *data) {
11
10
  char *two = frt_estrdup("two");
12
11
  FrtHashSet *hs = frt_hs_new_str(&free);
13
12
  (void)data; /* suppress unused argument warning */
@@ -58,8 +57,7 @@ static void test_hs(TestCase *tc, void *data)
58
57
  frt_hs_destroy(hs);
59
58
  }
60
59
 
61
- static void test_hs_ptr(TestCase *tc, void *data)
62
- {
60
+ static void test_hs_ptr(TestCase *tc, void *data) {
63
61
  FrtHashSet *hs = frt_hs_new_ptr(NULL);
64
62
  ID word1 = rb_intern("one"), word2 = rb_intern("two");
65
63
  char *word_one = frt_estrdup("one");
@@ -96,8 +94,7 @@ static void test_hs_ptr(TestCase *tc, void *data)
96
94
  * Test hs_add_safe
97
95
  */
98
96
 
99
- static void test_hs_add_safe(TestCase *tc, void *data)
100
- {
97
+ static void test_hs_add_safe(TestCase *tc, void *data) {
101
98
  char *str = frt_estrdup("one");
102
99
  FrtHashSet *hs = frt_hs_new_str(&free);
103
100
  (void)data; /* suppress unused argument warning */
@@ -129,8 +126,7 @@ static void test_hs_add_safe(TestCase *tc, void *data)
129
126
  * FrtHashSet that was merged should be destroyed including all elements that
130
127
  * weren't added to the final HashSet.
131
128
  */
132
- static void test_hs_merge(TestCase *tc, void *data)
133
- {
129
+ static void test_hs_merge(TestCase *tc, void *data) {
134
130
  FrtHashSet *hs1 = frt_hs_new_str(&free);
135
131
  FrtHashSet *hs2 = frt_hs_new_str(&free);
136
132
  FrtHashSetEntry *hse;
@@ -163,8 +159,7 @@ static void test_hs_merge(TestCase *tc, void *data)
163
159
  * Free Mock used to test that certain elements are being freed when the
164
160
  * FrtHashSet is destroyed.
165
161
  */
166
- static void hs_free_mock(void *p)
167
- {
162
+ static void hs_free_mock(void *p) {
168
163
  char *str = (char *) p;
169
164
  strcpy(str, "free");
170
165
  }
@@ -174,8 +169,7 @@ static void hs_free_mock(void *p)
174
169
  * FrtHashSet is destroyed, all elements have the correct free function called on
175
170
  * them
176
171
  */
177
- static void test_hs_free(TestCase *tc, void *data)
178
- {
172
+ static void test_hs_free(TestCase *tc, void *data) {
179
173
  char str1[10], str2[10], str3[10], str4[10], str5[10];
180
174
  FrtHashSet *hs1 = frt_hs_new_str(&hs_free_mock);
181
175
  FrtHashSet *hs2 = frt_hs_new_str(&hs_free_mock);
@@ -241,8 +235,7 @@ static void test_hs_free(TestCase *tc, void *data)
241
235
  */
242
236
  #define HS_STRESS_NUM 10000 /* number of adds to the FrtHashSet */
243
237
  #define HS_STRESS_MAX 100 /* number of elements allowed in the FrtHashSet */
244
- static void stress_hs(TestCase *tc, void *data)
245
- {
238
+ static void stress_hs(TestCase *tc, void *data) {
246
239
  int i;
247
240
  char buf[100];
248
241
  FrtHashSet *hs = frt_hs_new_str(&free);
@@ -273,8 +266,7 @@ static void stress_hs(TestCase *tc, void *data)
273
266
  /**
274
267
  * FrtHashSet Test Suite
275
268
  */
276
- TestSuite *ts_hashset(TestSuite *suite)
277
- {
269
+ TestSuite *ts_hashset(TestSuite *suite) {
278
270
  suite = ADD_SUITE(suite);
279
271
 
280
272
  tst_run_test(suite, test_hs, NULL);
@@ -1,8 +1,7 @@
1
1
  #include "frt_helper.h"
2
2
  #include "test.h"
3
3
 
4
- static void test_hlp_string_diff(TestCase *tc, void *data)
5
- {
4
+ static void test_hlp_string_diff(TestCase *tc, void *data) {
6
5
  (void)data; /* suppress unused argument warning */
7
6
 
8
7
  Aiequal(3, frt_hlp_string_diff("David", "Dave"));
@@ -12,8 +11,7 @@ static void test_hlp_string_diff(TestCase *tc, void *data)
12
11
  Aiequal(4, frt_hlp_string_diff("bookstop", "bookworm"));
13
12
  }
14
13
 
15
- void test_byte2float(TestCase *tc, void *data)
16
- {
14
+ void test_byte2float(TestCase *tc, void *data) {
17
15
  int i;
18
16
  (void)data;
19
17
 
@@ -22,8 +20,7 @@ void test_byte2float(TestCase *tc, void *data)
22
20
  }
23
21
  }
24
22
 
25
- void test_int2float(TestCase *tc, void *data)
26
- {
23
+ void test_int2float(TestCase *tc, void *data) {
27
24
  int i;
28
25
  (void)data;
29
26
 
@@ -35,8 +32,7 @@ void test_int2float(TestCase *tc, void *data)
35
32
  }
36
33
  }
37
34
 
38
- TestSuite *ts_helper(TestSuite *suite)
39
- {
35
+ TestSuite *ts_helper(TestSuite *suite) {
40
36
  suite = ADD_SUITE(suite);
41
37
 
42
38
  tst_run_test(suite, test_hlp_string_diff, NULL);