github.com/Konstantin8105/c4go@v0.0.0-20240505174241-768bb1c65a51/tests/do.c (about)

     1  #include "tests.h"
     2  #include <stdio.h>
     3  
     4  int main()
     5  {
     6      plan(7);
     7  
     8      int i = 0;
     9  
    10      // There will be 4 checks in the first loop.
    11      do {
    12          pass("%s", "first do statement");
    13          i = i + 1;
    14      } while (i < 4);
    15  
    16      // Only one check in the second loop.
    17      i = 0;
    18      do {
    19          i++;
    20          if (i < 3)
    21              continue;
    22          pass("%s", "second do statement");
    23      } while (i < 3);
    24  
    25      diag("check while");
    26      i = 1000;
    27      do {
    28          i--;
    29          if (i < 10) {
    30              break;
    31          }
    32      } while ((i /= 10) > 0);
    33      is_eq(i, 8);
    34  
    35      diag("do without CompoundStmt");
    36      int s = 1;
    37      do
    38          s++;
    39      while (s < 10);
    40      is_eq(s, 10);
    41  
    42      done_testing();
    43  }