LCOV - code coverage report
Current view: top level - libs/base32 - base32.c (source / functions) Coverage Total Hit
Test: hslock host coverage Lines: 92.9 % 14 13
Test Date: 2026-07-09 13:15:11 Functions: 100.0 % 1 1
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 83.3 % 6 5

             Branch data     Line data    Source code
       1                 :             : #include "base32.h"
       2                 :             : 
       3                 :             : static const char B32_CHARS[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
       4                 :             : 
       5                 :           1 : void base32_encode(const uint8_t *in, size_t in_len, char *out) {
       6                 :           1 :     uint32_t buffer    = 0;
       7                 :           1 :     int      bits_left = 0;
       8                 :           1 :     size_t out_len   = 0;
       9                 :             : 
      10         [ +  + ]:          21 :     for (size_t i = 0; i < in_len; i++) {
      11                 :          20 :         buffer = (buffer << 8) | in[i];
      12                 :          20 :         bits_left += 8;
      13         [ +  + ]:          52 :         while (bits_left >= 5) {
      14                 :          32 :             bits_left -= 5;
      15                 :          32 :             out[out_len++] = B32_CHARS[(buffer >> bits_left) & 0x1F];
      16                 :             :         }
      17                 :             :     }
      18                 :             : 
      19         [ -  + ]:           1 :     if (bits_left > 0) {
      20                 :           0 :         out[out_len++] = B32_CHARS[(buffer << (5 - bits_left)) & 0x1F];
      21                 :             :     }
      22                 :             : 
      23                 :           1 :     out[out_len] = '\0';
      24                 :           1 : }
        

Generated by: LCOV version 2.0-1