/[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.10 by sysadm, Thu May 22 11:10:19 2025 UTC Revision 1.13 by sysadm, Fri May 23 00:12:59 2025 UTC
# Line 66  int main(int argc, char *argv[]) Line 66  int main(int argc, char *argv[])
66          log_err_redirect(STDERR_FILENO);          log_err_redirect(STDERR_FILENO);
67    
68          // - 1 to make blocks allocated is less than required, to trigger error handling          // - 1 to make blocks allocated is less than required, to trigger error handling
69          block_count = BBS_article_limit_per_section * BBS_max_section / ARTICLE_PER_BLOCK - 1;          block_count = BBS_article_limit_per_section * BBS_max_section / ARTICLE_PER_BLOCK;
70    
71          if (article_block_init("../conf/menu.conf", block_count) < 0)          if (article_block_init("../conf/menu.conf", block_count) < 0)
72          {          {
# Line 346  int main(int argc, char *argv[]) Line 346  int main(int argc, char *argv[])
346    
347          printf("Testing #4 ...\n");          printf("Testing #4 ...\n");
348    
349          for (i = 0; i < BBS_max_section; i++)          for (i = 0; i < section_count; i++)
350          {          {
351                  step = i % 10 + 1;                  step = i % 10 + 1;
352                  for (j = group_count; j < BBS_article_limit_per_section; j += step)                  for (j = group_count; j < BBS_article_limit_per_section; j += step)
# Line 367  int main(int argc, char *argv[]) Line 367  int main(int argc, char *argv[])
367                                  break;                                  break;
368                          }                          }
369    
                         if (page * BBS_article_limit_per_page + offset != j)  
                         {  
                                 printf("Inconsistent article offset %d in section %d page %d offset %d\n", j, i, page, offset);  
                                 break;  
                         }  
   
370                          if (section_list_set_article_visible(p_section[i], last_aid, 0) != 1)                          if (section_list_set_article_visible(p_section[i], last_aid, 0) != 1)
371                          {                          {
372                                  printf("Error set article %d invisible in section %d offset %d\n", last_aid, i, j);                                  printf("Error set article %d invisible in section %d offset %d\n", last_aid, i, j);
# Line 380  int main(int argc, char *argv[]) Line 374  int main(int argc, char *argv[])
374                          }                          }
375                  }                  }
376    
377                    last_aid = p_section[i]->p_article_head->aid;
378                    if (section_list_calculate_page(p_section[i], last_aid) < 0)
379                    {
380                            printf("section_list_calculate_page(aid = %d) error in section %d offset %d\n", last_aid, i, j);
381                            break;
382                    }
383    
384                    if (p_section[i]->visible_article_count / BBS_article_limit_per_page +
385                                    (p_section[i]->visible_article_count % BBS_article_limit_per_page ? 1 : 0) !=
386                            p_section[i]->page_count)
387                    {
388                            printf("Inconsistent page count in section %d offset %d, %d != %d, "
389                                       "visible_article_count = %d, last_page_visible_count = %d\n",
390                                       i, j,
391                                       p_section[i]->visible_article_count / BBS_article_limit_per_page +
392                                               (p_section[i]->visible_article_count % BBS_article_limit_per_page ? 1 : 0),
393                                       p_section[i]->page_count, p_section[i]->visible_article_count,
394                                       p_section[i]->last_page_visible_article_count);
395                            break;
396                    }
397    
398                  affected_count = (BBS_article_limit_per_section - group_count) / step + ((BBS_article_limit_per_section - group_count) % step ? 1 : 0);                  affected_count = (BBS_article_limit_per_section - group_count) / step + ((BBS_article_limit_per_section - group_count) % step ? 1 : 0);
399                  if (p_section[i]->article_count - p_section[i]->visible_article_count != affected_count)                  if (p_section[i]->article_count - p_section[i]->visible_article_count != affected_count)
400                  {                  {
# Line 432  int main(int argc, char *argv[]) Line 447  int main(int argc, char *argv[])
447    
448                  if (p_section[i]->visible_article_count > 0)                  if (p_section[i]->visible_article_count > 0)
449                  {                  {
450                          printf("Inconsistent invisible count in section %d, %d > 0\n", i, p_section[i]->visible_article_count);                          printf("Inconsistent invisible article count in section %d, %d > 0\n", i, p_section[i]->visible_article_count);
451                            break;
452                    }
453    
454                    if (p_section[i]->visible_topic_count > 0)
455                    {
456                            printf("Inconsistent invisible topic count in section %d, %d > 0\n", i, p_section[i]->visible_topic_count);
457                            break;
458                    }
459    
460                    last_aid = p_section[i]->p_article_head->aid;
461                    if (section_list_calculate_page(p_section[i], last_aid) < 0)
462                    {
463                            printf("section_list_calculate_page(aid = %d) error in section %d offset %d\n", last_aid, i, j);
464                            break;
465                    }
466    
467                    if (p_section[i]->visible_article_count / BBS_article_limit_per_page +
468                                    (p_section[i]->visible_article_count % BBS_article_limit_per_page ? 1 : 0) !=
469                            p_section[i]->page_count)
470                    {
471                            printf("Inconsistent page count in section %d offset %d, %d != %d, "
472                                       "visible_article_count = %d, last_page_visible_count = %d\n",
473                                       i, j,
474                                       p_section[i]->visible_article_count / BBS_article_limit_per_page +
475                                               (p_section[i]->visible_article_count % BBS_article_limit_per_page ? 1 : 0),
476                                       p_section[i]->page_count, p_section[i]->visible_article_count,
477                                       p_section[i]->last_page_visible_article_count);
478                            break;
479                    }
480            }
481    
482            for (i = 0; i < BBS_max_section; i++)
483            {
484                    affected_count = 0;
485    
486                    for (j = 0; j < BBS_article_limit_per_section; j += 1)
487                    {
488                            last_aid = i * BBS_article_limit_per_section + j + 1;
489    
490                            if (section_list_set_article_visible(p_section[i], last_aid, 1) <= 0)
491                            {
492                                    printf("Error set article %d visible in section %d offset %d\n", last_aid, i, j);
493                                    break;
494                            }
495    
496                            affected_count++;
497                    }
498    
499                    if (affected_count != p_section[i]->article_count)
500                    {
501                            printf("Inconsistent total set visible article count in section %d, %d != %d\n", i, affected_count, p_section[i]->article_count);
502                            break;
503                    }
504    
505                    if (p_section[i]->visible_article_count != p_section[i]->article_count)
506                    {
507                            printf("Inconsistent visible article count in section %d, %d != %d\n", i, p_section[i]->visible_article_count, p_section[i]->article_count);
508                            break;
509                    }
510    
511                    if (p_section[i]->visible_topic_count != group_count)
512                    {
513                            printf("Inconsistent visible topic count in section %d, %d != %d\n", i, p_section[i]->visible_topic_count, group_count);
514                            break;
515                    }
516    
517                    last_aid = p_section[i]->p_article_head->aid;
518                    if (section_list_calculate_page(p_section[i], last_aid) < 0)
519                    {
520                            printf("section_list_calculate_page(aid = %d) error in section %d offset %d\n", last_aid, i, j);
521                            break;
522                    }
523    
524                    if (p_section[i]->visible_article_count / BBS_article_limit_per_page +
525                                    (p_section[i]->visible_article_count % BBS_article_limit_per_page ? 1 : 0) !=
526                            p_section[i]->page_count)
527                    {
528                            printf("Inconsistent page count in section %d offset %d, %d != %d, "
529                                       "visible_article_count = %d, last_page_visible_count = %d\n",
530                                       i, j,
531                                       p_section[i]->visible_article_count / BBS_article_limit_per_page +
532                                               (p_section[i]->visible_article_count % BBS_article_limit_per_page ? 1 : 0),
533                                       p_section[i]->page_count, p_section[i]->visible_article_count,
534                                       p_section[i]->last_page_visible_article_count);
535                          break;                          break;
536                  }                  }
537          }          }


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

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