LCOV - code coverage report
Current view: top level - lib/tdb/test - run-rescue-find_entry.c (source / functions) Hit Total Coverage
Test: coverage report for support-claim-type-attributes 6b5c566e Lines: 14 14 100.0 %
Date: 2023-11-21 12:31:41 Functions: 1 1 100.0 %

          Line data    Source code
       1             : #include "../common/tdb_private.h"
       2             : #include "../common/io.c"
       3             : #include "../common/tdb.c"
       4             : #include "../common/lock.c"
       5             : #include "../common/freelist.c"
       6             : #include "../common/traverse.c"
       7             : #include "../common/transaction.c"
       8             : #include "../common/error.c"
       9             : #include "../common/open.c"
      10             : #include "../common/check.c"
      11             : #include "../common/hash.c"
      12             : #include "../common/rescue.c"
      13             : #include "../common/mutex.c"
      14             : #include "tap-interface.h"
      15             : #include <stdlib.h>
      16             : #include "logging.h"
      17             : 
      18             : #define NUM 20
      19             : 
      20             : /* Binary searches are deceptively simple: easy to screw up! */
      21           1 : int main(int argc, char *argv[])
      22             : {
      23             :         unsigned int i, j, n;
      24             :         struct found f[NUM+1];
      25             :         struct found_table table;
      26             : 
      27             :         /* Set up array for searching. */
      28          22 :         for (i = 0; i < NUM+1; i++) {
      29          21 :                 f[i].head = i * 3;
      30             :         }
      31           1 :         table.arr = f;
      32             : 
      33          21 :         for (i = 0; i < NUM; i++) {
      34          20 :                 table.num = i;
      35         710 :                 for (j = 0; j < (i + 2) * 3; j++) {
      36         690 :                         n = find_entry(&table, j);
      37         690 :                         ok1(n <= i);
      38             : 
      39             :                         /* If we were searching for something too large... */
      40         690 :                         if (j > i*3)
      41         100 :                                 ok1(n == i);
      42             :                         else {
      43             :                                 /* It must give us something after j */
      44         590 :                                 ok1(f[n].head >= j);
      45         590 :                                 ok1(n == 0 || f[n-1].head < j);
      46             :                         }
      47             :                 }
      48             :         }
      49             : 
      50           1 :         return exit_status();
      51             : }

Generated by: LCOV version 1.14