/[LeafOK_CVS]/lbbs/src/test_section_list.c
ViewVC logotype

Diff of /lbbs/src/test_section_list.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.6 by sysadm, Wed May 21 09:18:17 2025 UTC Revision 1.16 by sysadm, Fri May 23 11:05:44 2025 UTC
# Line 41  int section_count = BBS_max_section; Line 41  int section_count = BBS_max_section;
41    
42  int main(int argc, char *argv[])  int main(int argc, char *argv[])
43  {  {
44          SECTION_DATA *p_section[BBS_max_section];          SECTION_LIST *p_section[BBS_max_section];
45          ARTICLE *p_article;          ARTICLE *p_article;
46            ARTICLE *p_next;
47          ARTICLE article;          ARTICLE article;
48          int block_count;          int block_count;
49          int i, j;          int i, j;
50          int last_aid;          int last_aid;
51          int group_count;          int current_tid;
52            int section_first_aid;
53            int group_count = 100;
54          int article_count;          int article_count;
55            int step;
56            int32_t page;
57            int32_t offset;
58            int affected_count;
59    
60          if (log_begin("../log/bbsd.log", "../log/error.log") < 0)          if (log_begin("../log/bbsd.log", "../log/error.log") < 0)
61          {          {
# Line 59  int main(int argc, char *argv[]) Line 66  int main(int argc, char *argv[])
66          log_std_redirect(STDOUT_FILENO);          log_std_redirect(STDOUT_FILENO);
67          log_err_redirect(STDERR_FILENO);          log_err_redirect(STDERR_FILENO);
68    
69          // block_count = BBS_article_block_limit_per_section * BBS_max_section; // This statement is correct          // - 1 to make blocks allocated is less than required, to trigger error handling
70          // - 1 to make blocks allocated is less than required          block_count = BBS_article_limit_per_section * BBS_max_section / ARTICLE_PER_BLOCK;
         // Some error will be triggered while invoking section_data_append_article()  
         block_count = BBS_article_block_limit_per_section * BBS_max_section - 1;  
71    
72          if (section_data_pool_init("../conf/menu.conf", block_count) < 0)          if (article_block_init("../conf/menu.conf", block_count) < 0)
73          {          {
74                  log_error("section_data_pool_init() error\n");                  log_error("section_data_pool_init() error\n");
75                  return -2;                  return -2;
# Line 76  int main(int argc, char *argv[]) Line 81  int main(int argc, char *argv[])
81    
82          for (i = 0; i < section_count; i++)          for (i = 0; i < section_count; i++)
83          {          {
84                  p_section[i] = section_data_create(sname[i % section_conf_count],                  p_section[i] = section_list_create(i + 1,
85                                                                                       sname[i % section_conf_count],
86                                                                                     stitle[i % section_conf_count],                                                                                     stitle[i % section_conf_count],
87                                                                                     master_name[i % section_conf_count]);                                                                                     master_name[i % section_conf_count]);
88                  if (p_section[i] == NULL)                  if (p_section[i] == NULL)
# Line 84  int main(int argc, char *argv[]) Line 90  int main(int argc, char *argv[])
90                          log_error("section_data_create(i=%d) error\n", i);                          log_error("section_data_create(i=%d) error\n", i);
91                          return -3;                          return -3;
92                  }                  }
93            }
94    
95            for (i = 0; i < section_conf_count; i++)
96            {
97                    if (section_list_find_by_name(sname[i]) == NULL)
98                    {
99                            printf("section_data_find_section_by_name(%s) error\n", sname[i]);
100                            return -3;
101                    }
102            }
103    
104                  for (j = 0; j < BBS_article_limit_per_block * BBS_article_block_limit_per_section; j++)          for (j = 0; j < BBS_article_limit_per_section; j++)
105            {
106                    for (i = 0; i < section_count; i++)
107                  {                  {
108                          last_aid++;                          last_aid++;
109    
# Line 99  int main(int argc, char *argv[]) Line 117  int main(int argc, char *argv[])
117                          article.ontop = 0;                          article.ontop = 0;
118                          article.lock = 0;                          article.lock = 0;
119    
120                          if (section_data_append_article(p_section[i], &article) < 0)                          if (section_list_append_article(p_section[i], &article) < 0)
121                          {                          {
122                                  printf("append article (aid = %d) error\n", article.aid);                                  printf("append article (aid = %d) error at section %d index %d\n", article.aid, i, j);
123                                  break;                                  break;
124                          }                          }
125                  }                  }
126            }
127    
128                  printf("Load %d articles into section %d\n", p_section[i]->article_count, i);          for (i = 0; i < section_count; i++)
129            {
130                    // printf("Loaded %d articles into section %d\n", p_section[i]->article_count, i);
131          }          }
132    
133          last_aid = 0;          last_aid = 0;
# Line 122  int main(int argc, char *argv[]) Line 143  int main(int argc, char *argv[])
143                  {                  {
144                          last_aid++;                          last_aid++;
145    
146                          p_article = section_data_find_article_by_index(p_section[i], j);                          p_article = article_block_find_by_aid(last_aid);
147                          if (p_article == NULL || p_article->aid != last_aid)                          if (p_article == NULL || p_article->aid != last_aid)
148                          {                          {
149                                  printf("Inconsistent aid at index %d != %d\n", j, last_aid);                                  printf("article_block_find_by_aid() at section %d index %d, %d != %d\n", i, j, p_article->aid, last_aid);
150                          }                          }
151    
152                          if (section_data_mark_del_article(p_section[i], p_article->aid) != 1)                          p_article = article_block_find_by_index(last_aid - 1);
153                            if (p_article == NULL || p_article->aid != last_aid)
154                          {                          {
155                                  printf("section_data_mark_del_article(aid = %d) error\n", p_article->aid);                                  printf("article_block_find_by_index() at section %d index %d, %d != %d\n", i, j, p_article->aid, last_aid);
156                            }
157    
158                            if (section_list_set_article_visible(p_section[i], p_article->aid, 0) != 1)
159                            {
160                                    printf("section_list_set_article_visible(aid = %d) error\n", p_article->aid);
161                          }                          }
162                  }                  }
163    
164                  printf("Verify %d articles in section %d\n", p_section[i]->article_count, i);                  // printf("Verified %d articles in section %d\n", p_section[i]->article_count, i);
                 printf("Delete %d articles in section %d\n", p_section[i]->delete_count, i);  
165          }          }
166    
167          printf("Testing #2 ...\n");          printf("Testing #2 ...\n");
168    
169          group_count = 100;          if (article_block_reset() != 0)
170            {
171                    log_error("section_data_free_block(i=%d) error\n", i);
172                    return -4;
173            }
174    
175          for (i = 0; i < section_count; i++)          for (i = 0; i < section_count; i++)
176          {          {
177                  if (section_data_free_block(p_section[i]) != 0)                  section_list_reset_articles(p_section[i]);
178                  {          }
                         log_error("section_data_free_block(i=%d) error\n", i);  
                         return -4;  
                 }  
179    
180                  last_aid = 0;          last_aid = 0;
181    
182                  for (j = 0; j < BBS_article_limit_per_block * BBS_article_block_limit_per_section; j++)          for (i = 0; i < section_count; i++)
183            {
184                    section_first_aid = last_aid + 1;
185    
186                    for (j = 0; j < BBS_article_limit_per_section; j++)
187                  {                  {
188                          last_aid++;                          last_aid++;
189    
190                          // Set article data                          // Set article data
191                          article.aid = last_aid;                          article.aid = last_aid;
192                          article.cid = article.aid;                          article.cid = article.aid;
193                          article.tid = (article.aid <= group_count ? 0 : (article.aid - 1) % group_count + 1); // Group articles into group_count topics                          // Group articles into group_count topics
194                          article.uid = 1;                                                                                                                                          // TODO: randomize                          article.tid = ((article.aid < section_first_aid + group_count) ? 0 : (section_first_aid + j % group_count));
195                            article.uid = 1; // TODO: randomize
196                          article.visible = 1;                          article.visible = 1;
197                          article.excerption = 0;                          article.excerption = 0;
198                          article.ontop = 0;                          article.ontop = 0;
199                          article.lock = 0;                          article.lock = 0;
200    
201                          if (section_data_append_article(p_section[i], &article) < 0)                          if (section_list_append_article(p_section[i], &article) < 0)
202                          {                          {
203                                  printf("append article (aid = %d) error\n", article.aid);                                  printf("append article (aid = %d) error at section %d index %d\n", article.aid, i, j);
204                                  break;                                  break;
205                          }                          }
206                  }                  }
207    
208                  printf("Load %d articles into section %d\n", p_section[i]->article_count, i);                  // printf("Loaded %d articles into section %d\n", p_section[i]->article_count, i);
209          }          }
210    
211          for (i = 0; i < section_count; i++)          for (i = 0; i < section_count; i++)
# Line 183  int main(int argc, char *argv[]) Line 215  int main(int argc, char *argv[])
215                          continue;                          continue;
216                  }                  }
217    
218                    article_count = 0;
219                    last_aid = 0;
220    
221                    p_article = p_section[i]->p_article_head;
222    
223                    do
224                    {
225                            article_count++;
226    
227                            if (p_article->aid <= last_aid)
228                            {
229                                    printf("Non-ascending aid found %d <= %d at article\n", p_article->aid, last_aid);
230                            }
231                            last_aid = p_article->aid;
232    
233                            p_article = p_article->p_next;
234                    } while (p_article != p_section[i]->p_article_head);
235    
236                    if (article_count != p_section[i]->article_count)
237                    {
238                            printf("Count of articles in section %d is different from expected %d != %d\n",
239                                       i, article_count, p_section[i]->article_count);
240                            break;
241                    }
242    
243                    // printf("Verified %d articles in section %d\n", group_count, i);
244            }
245    
246            for (i = 0; i < section_count; i++)
247            {
248                    if (p_section[i]->article_count == 0)
249                    {
250                            continue;
251                    }
252    
253                    if (p_section[i]->topic_count != group_count)
254                    {
255                            printf("Inconsistent topic count in section %d, %d != %d\n", i, p_section[i]->topic_count, group_count);
256                    }
257    
258                  for (j = 0; j < group_count; j++)                  for (j = 0; j < group_count; j++)
259                  {                  {
260                          p_article = section_data_find_article_by_index(p_section[i], j);                          last_aid = p_section[i]->p_article_head->aid + j;
261    
262                            p_article = article_block_find_by_aid(last_aid);
263                          if (p_article == NULL)                          if (p_article == NULL)
264                          {                          {
265                                  printf("NULL p_article at index %d\n", j);                                  printf("NULL p_article at section %d index %d\n", i, j);
266                                  break;                                  break;
267                          }                          }
268                          if (p_article->aid != j + 1)                          if (p_article->aid != last_aid)
269                          {                          {
270                                  printf("Inconsistent aid at index %d != %d\n", j, j + 1);                                  printf("Inconsistent aid at section %d index %d, %d != %d\n", i, j, p_article->aid, last_aid);
271                                  break;                                  break;
272                          }                          }
273    
274                          article_count = 1;                          article_count = 1;
275                            last_aid = 0;
276                            current_tid = p_article->aid;
277    
278                          do                          do
279                          {                          {
280                                  if (p_article->next_aid <= p_article->aid && p_article->next_aid != p_article->tid)                                  if (p_article->aid <= last_aid)
281                                  {                                  {
282                                          printf("Non-ascending aid found %d >= %d\n", p_article->aid, p_article->next_aid);                                          printf("Non-ascending aid found %d <= %d\n", p_article->aid, last_aid);
                                         break;  
283                                  }                                  }
284                                    last_aid = p_article->aid;
285    
286                                    p_article = p_article->p_topic_next;
287    
                                 last_aid = p_article->next_aid;  
                                 p_article = section_data_find_article_by_aid(p_section[i], last_aid);  
288                                  if (p_article == NULL)                                  if (p_article == NULL)
289                                  {                                  {
290                                          printf("NULL p_article at aid %d\n", last_aid);                                          printf("NULL p_article found\n");
291                                          break;                                          break;
292                                  }                                  }
293                                  if (p_article->tid == 0) // loop                                  if (p_article->tid == 0) // loop
294                                  {                                  {
295                                          break;                                          break;
296                                  }                                  }
297                                  if (p_article->tid != j + 1)                                  if (p_article->tid != current_tid)
298                                  {                                  {
299                                          printf("Inconsistent tid at aid %d != %d\n", last_aid, j + 1);                                          printf("Inconsistent tid %d != %d\n", p_article->tid, current_tid);
300                                          break;                                          break;
301                                  }                                  }
302    
303                                  article_count++;                                  article_count++;
304                          } while (1);                          } while (1);
305    
306                          if (article_count != p_section[i]->article_count / group_count)                          if (article_count != p_section[i]->article_count / group_count)
307                          {                          {
308                                  printf("Count of articles in topic %d is less than expected %d < %d\n",                                  printf("Count of articles in topic %d is different from expected %d != %d\n",
309                                             j + 1, article_count, p_section[i]->article_count / group_count);                                             j + 1, article_count, p_section[i]->article_count / group_count);
310                                    // break;
311                          }                          }
312                  }                  }
313    
314                  printf("Verify %d topics in section %d\n", group_count, i);                  // printf("Verified %d topics in section %d\n", group_count, i);
315          }          }
316    
317          printf("Testing #3 ...\n");          printf("Testing #3 ...\n");
318    
319          for (i = 0; i < section_conf_count; i++)          for (i = 0; i < section_count; i++)
320          {          {
321                  if (section_data_find_section_by_name(sname[i]) == NULL)                  last_aid = 0;
322    
323                    for (j = 0; j < p_section[i]->page_count; j++)
324                  {                  {
325                          printf("section_data_find_section_by_name(%s) error\n", sname[i]);                          if (p_section[i]->p_page_first_article[j]->aid <= last_aid)
326                            {
327                                    printf("Non-ascending aid found at section %d page %d, %d <= %d\n", i, j, p_section[i]->p_page_first_article[j]->aid, last_aid);
328                            }
329    
330                            if (j > 0)
331                            {
332                                    step = 0;
333    
334                                    for (p_article = p_section[i]->p_page_first_article[j];
335                                             p_article != p_section[i]->p_page_first_article[j - 1];
336                                             p_article = p_article->p_prior)
337                                    {
338                                            step++;
339                                    }
340    
341                                    if (step != BBS_article_limit_per_page)
342                                    {
343                                            printf("Incorrect page size %d at section %d page %d\n", step, i, j - 1);
344                                    }
345                            }
346                    }
347            }
348    
349            printf("Testing #4 ...\n");
350    
351            for (i = 0; i < section_count; i++)
352            {
353                    step = i % 10 + 1;
354                    for (j = group_count; j < BBS_article_limit_per_section; j += step)
355                    {
356                            last_aid = i * BBS_article_limit_per_section + j + 1;
357    
358                            p_article = section_list_find_article_with_offset(p_section[i], last_aid, &page, &offset, &p_next);
359    
360                            if (p_article == NULL)
361                            {
362                                    printf("Error find article %d in section %d offset %d\n", last_aid, i, j);
363                                    break;
364                            }
365    
366                            if (p_article->aid != last_aid)
367                            {
368                                    printf("Inconsistent article aid in section %d page %d offset %d %d != %d\n", i, page, offset, p_article->aid, last_aid);
369                                    break;
370                            }
371    
372                            if (section_list_set_article_visible(p_section[i], last_aid, 0) != 1)
373                            {
374                                    printf("Error set article %d invisible in section %d offset %d\n", last_aid, i, j);
375                                    break;
376                            }
377                    }
378    
379                    last_aid = p_section[i]->p_article_head->aid;
380                    if (section_list_calculate_page(p_section[i], last_aid) < 0)
381                    {
382                            printf("section_list_calculate_page(aid = %d) error in section %d offset %d\n", last_aid, i, j);
383                            break;
384                    }
385    
386                    if (p_section[i]->visible_article_count / BBS_article_limit_per_page +
387                                    (p_section[i]->visible_article_count % BBS_article_limit_per_page ? 1 : 0) !=
388                            p_section[i]->page_count)
389                    {
390                            printf("Inconsistent page count in section %d offset %d, %d != %d, "
391                                       "visible_article_count = %d, last_page_visible_count = %d\n",
392                                       i, j,
393                                       p_section[i]->visible_article_count / BBS_article_limit_per_page +
394                                               (p_section[i]->visible_article_count % BBS_article_limit_per_page ? 1 : 0),
395                                       p_section[i]->page_count, p_section[i]->visible_article_count,
396                                       p_section[i]->last_page_visible_article_count);
397                            break;
398                    }
399    
400                    affected_count = (BBS_article_limit_per_section - group_count) / step + ((BBS_article_limit_per_section - group_count) % step ? 1 : 0);
401                    if (p_section[i]->article_count - p_section[i]->visible_article_count != affected_count)
402                    {
403                            printf("Inconsistent set invisible count in section %d, %d != %d\n", i,
404                                       p_section[i]->article_count - p_section[i]->visible_article_count,
405                                       affected_count);
406                            break;
407                    }
408    
409                    article_count = p_section[i]->visible_article_count;
410    
411                    for (j = 0; j < group_count; j += 1)
412                    {
413                            last_aid = i * BBS_article_limit_per_section + j + 1;
414    
415                            p_article = section_list_find_article_with_offset(p_section[i], last_aid, &page, &offset, &p_next);
416    
417                            if (p_article == NULL)
418                            {
419                                    printf("Error find article %d in section %d offset %d\n", last_aid, i, j);
420                                    break;
421                            }
422    
423                            if (p_article->aid != last_aid)
424                            {
425                                    printf("Inconsistent article aid in section %d page %d offset %d %d != %d\n", i, page, offset, p_article->aid, last_aid);
426                                    break;
427                            }
428    
429                            if (p_article->tid != 0)
430                            {
431                                    printf("Non-topic article aid in section %d page %d offset %d %d != 0\n", i, page, offset, p_article->tid);
432                                    break;
433                            }
434    
435                            if ((affected_count = section_list_set_article_visible(p_section[i], last_aid, 0)) <= 0)
436                            {
437                                    printf("Error set topic %d invisible in section %d offset %d\n", last_aid, i, j);
438                                    break;
439                            }
440    
441                            article_count -= affected_count;
442                    }
443    
444                    if (article_count != 0)
445                    {
446                            printf("Inconsistent total set invisible topic count in section %d, %d > 0\n", i, article_count);
447                            break;
448                    }
449    
450                    if (p_section[i]->visible_article_count > 0)
451                    {
452                            printf("Inconsistent invisible article count in section %d, %d > 0\n", i, p_section[i]->visible_article_count);
453                            break;
454                    }
455    
456                    if (p_section[i]->visible_topic_count > 0)
457                    {
458                            printf("Inconsistent invisible topic count in section %d, %d > 0\n", i, p_section[i]->visible_topic_count);
459                            break;
460                    }
461    
462                    last_aid = p_section[i]->p_article_head->aid;
463                    if (section_list_calculate_page(p_section[i], last_aid) < 0)
464                    {
465                            printf("section_list_calculate_page(aid = %d) error in section %d offset %d\n", last_aid, i, j);
466                            break;
467                    }
468    
469                    if (p_section[i]->visible_article_count / BBS_article_limit_per_page +
470                                    (p_section[i]->visible_article_count % BBS_article_limit_per_page ? 1 : 0) !=
471                            p_section[i]->page_count)
472                    {
473                            printf("Inconsistent page count in section %d offset %d, %d != %d, "
474                                       "visible_article_count = %d, last_page_visible_count = %d\n",
475                                       i, j,
476                                       p_section[i]->visible_article_count / BBS_article_limit_per_page +
477                                               (p_section[i]->visible_article_count % BBS_article_limit_per_page ? 1 : 0),
478                                       p_section[i]->page_count, p_section[i]->visible_article_count,
479                                       p_section[i]->last_page_visible_article_count);
480                            break;
481                    }
482            }
483    
484            for (i = 0; i < BBS_max_section; i++)
485            {
486                    affected_count = 0;
487    
488                    for (j = 0; j < BBS_article_limit_per_section; j += 1)
489                    {
490                            last_aid = i * BBS_article_limit_per_section + j + 1;
491    
492                            if (section_list_set_article_visible(p_section[i], last_aid, 1) <= 0)
493                            {
494                                    printf("Error set article %d visible in section %d offset %d\n", last_aid, i, j);
495                                    break;
496                            }
497    
498                            affected_count++;
499                    }
500    
501                    if (affected_count != p_section[i]->article_count)
502                    {
503                            printf("Inconsistent total set visible article count in section %d, %d != %d\n", i, affected_count, p_section[i]->article_count);
504                            break;
505                    }
506    
507                    if (p_section[i]->visible_article_count != p_section[i]->article_count)
508                    {
509                            printf("Inconsistent visible article count in section %d, %d != %d\n", i, p_section[i]->visible_article_count, p_section[i]->article_count);
510                            break;
511                    }
512    
513                    if (p_section[i]->visible_topic_count != group_count)
514                    {
515                            printf("Inconsistent visible topic count in section %d, %d != %d\n", i, p_section[i]->visible_topic_count, group_count);
516                            break;
517                    }
518    
519                    last_aid = p_section[i]->p_article_head->aid;
520                    if (section_list_calculate_page(p_section[i], last_aid) < 0)
521                    {
522                            printf("section_list_calculate_page(aid = %d) error in section %d offset %d\n", last_aid, i, j);
523                            break;
524                    }
525    
526                    if (p_section[i]->visible_article_count / BBS_article_limit_per_page +
527                                    (p_section[i]->visible_article_count % BBS_article_limit_per_page ? 1 : 0) !=
528                            p_section[i]->page_count)
529                    {
530                            printf("Inconsistent page count in section %d offset %d, %d != %d, "
531                                       "visible_article_count = %d, last_page_visible_count = %d\n",
532                                       i, j,
533                                       p_section[i]->visible_article_count / BBS_article_limit_per_page +
534                                               (p_section[i]->visible_article_count % BBS_article_limit_per_page ? 1 : 0),
535                                       p_section[i]->page_count, p_section[i]->visible_article_count,
536                                       p_section[i]->last_page_visible_article_count);
537                            break;
538                    }
539            }
540    
541            printf("Testing #5 ...\n");
542    
543            if (article_block_reset() != 0)
544            {
545                    log_error("section_data_free_block(i=%d) error\n", i);
546                    return -4;
547            }
548    
549            for (i = 0; i < section_count; i++)
550            {
551                    section_list_reset_articles(p_section[i]);
552            }
553    
554            last_aid = 0;
555    
556            for (i = 0; i < section_count / 2; i++)
557            {
558                    section_first_aid = last_aid + 1;
559    
560                    for (j = 0; j < BBS_article_limit_per_section; j++)
561                    {
562                            last_aid++;
563    
564                            // Set article data
565                            article.aid = last_aid;
566                            article.cid = article.aid;
567                            // Group articles into group_count topics
568                            article.tid = ((article.aid < section_first_aid + group_count) ? 0 : (section_first_aid + j % group_count));
569                            article.uid = 1; // TODO: randomize
570                            article.visible = 1;
571                            article.excerption = 0;
572                            article.ontop = 0;
573                            article.lock = 0;
574    
575                            if (section_list_append_article(p_section[i], &article) < 0)
576                            {
577                                    printf("append article (aid = %d) error at section %d index %d\n", article.aid, i, j);
578                                    break;
579                            }
580                    }
581    
582                    // printf("Loaded %d articles into section %d\n", p_section[i]->article_count, i);
583            }
584    
585            for (i = 0; i < section_count / 2; i++)
586            {
587                    section_first_aid = p_section[i]->p_article_head->aid;
588    
589                    for (j = 0; j < group_count; j += 2)
590                    {
591                            p_article = section_list_find_article_with_offset(p_section[i], section_first_aid + j, &page, &offset, &p_next);
592                            if (p_article == NULL)
593                            {
594                                    printf("section_list_find_article_with_offset(aid = %d) not found in section %d\n",
595                                               section_first_aid + j, i);
596                                    break;
597                            }
598    
599                            if (section_list_set_article_visible(p_section[i], p_article->aid, 0) != BBS_article_limit_per_section / group_count)
600                            {
601                                    printf("section_list_set_article_visible(aid = %d) error\n", p_article->aid);
602                            }
603                    }
604            }
605    
606            for (i = 0; i < section_count / 2; i++)
607            {
608                    section_first_aid = p_section[i]->p_article_head->aid;
609    
610                    for (j = 0; j < group_count; j++)
611                    {
612                            affected_count = section_list_move_topic(p_section[i], p_section[section_count / 2 + i], section_first_aid + j);
613    
614                            if (affected_count < 0)
615                            {
616                                    printf("move topic (aid = %d) error from section %d to section %d\n", section_first_aid + j, i, section_count / 2 + i);
617                                    break;
618                            }
619    
620                            if (affected_count != BBS_article_limit_per_section / group_count)
621                            {
622                                    printf("move topic (aid = %d) affected article count %d != %d\n",
623                                               section_first_aid + j, affected_count,
624                                               BBS_article_limit_per_section / group_count);
625                                    // break;
626                            }
627                    }
628            }
629    
630            for (i = 0; i < section_count; i++)
631            {
632                    if (p_section[i]->topic_count != (i < section_count / 2 ? 0 : group_count))
633                    {
634                            printf("Topic count error in section %d, %d != %d\n", i,
635                                       p_section[i]->topic_count, (i < section_count / 2 ? 0 : group_count));
636                            break;
637                    }
638    
639                    if (p_section[i]->visible_topic_count != (i < section_count / 2 ? 0 : group_count / 2))
640                    {
641                            printf("Visible topic count error in section %d, %d != %d\n", i,
642                                       p_section[i]->visible_topic_count, (i < section_count / 2 ? 0 : group_count / 2));
643                            break;
644                    }
645    
646                    if (p_section[i]->article_count != (i < section_count / 2 ? 0 : BBS_article_limit_per_section))
647                    {
648                            printf("Article count error in section %d, %d != %d\n", i,
649                                       p_section[i]->article_count, (i < section_count / 2 ? 0 : BBS_article_limit_per_section));
650                            break;
651                    }
652    
653                    if (p_section[i]->visible_article_count != (i < section_count / 2 ? 0 : BBS_article_limit_per_section / 2))
654                    {
655                            printf("Visible article count error in section %d, %d != %d\n", i,
656                                       p_section[i]->visible_article_count, (i < section_count / 2 ? 0 : BBS_article_limit_per_section / 2));
657                            break;
658                    }
659    
660                    if (p_section[i]->page_count != (i < section_count / 2 ? 0 : BBS_article_limit_per_section / 2 / BBS_article_limit_per_page))
661                    {
662                            printf("Page count error in section %d, %d != %d\n", i,
663                                       p_section[i]->page_count, (i < section_count / 2 ? 0 : BBS_article_limit_per_section / 2 / BBS_article_limit_per_page));
664                            break;
665                  }                  }
666          }          }
667    
668          printf("Press ENTER to exit...");          printf("Press ENTER to exit...");
669          getchar();          getchar();
670            
671          section_data_pool_cleanup();          article_block_cleanup();
672    
673          log_end();          log_end();
674    


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1