About Docs Source
LCOV - code coverage report
Current view: top level - include/nut - debug.h (source / functions) Coverage Total Hit
Test: unnamed Lines: 100.0 % 4 4
Test Date: 2025-10-22 01:14:28 Functions: 100.0 % 1 1

            Line data    Source code
       1              : #pragma once
       2              : 
       3              : /// @file
       4              : /// @author hacatu
       5              : /// @version 0.2.0
       6              : /// @section LICENSE
       7              : /// This Source Code Form is subject to the terms of the Mozilla Public
       8              : /// License, v. 2.0. If a copy of the MPL was not distributed with this
       9              : /// file, You can obtain one at http://mozilla.org/MPL/2.0/.
      10              : /// @section DESCRIPTION
      11              : /// Functions for internal use in the tests
      12              : 
      13              : #include <stdio.h>
      14              : #include <inttypes.h>
      15              : #include <stdlib.h>
      16              : 
      17              : #include <nut/modular_math.h>
      18              : 
      19              : NUT_ATTR_ARTIFICIAL
      20              : NUT_ATTR_ACCESS(read_write, 1)
      21        11488 : static inline void cleanup_free(void *_p){
      22        11488 :     free(*(void**)_p);
      23        11488 :     *(void**)_p = NULL;
      24        11488 : }
      25              : 
      26              : NUT_ATTR_NONNULL(1)
      27              : NUT_ATTR_ACCESS(read_only, 1)
      28              : NUT_ATTR_ACCESS(none, 2)
      29              : static inline void check_alloc(const char *restrict what, const void *restrict buf){
      30              :     if(!buf){
      31              :         fprintf(stderr, "\e[1;31mAllocation failed for %s!\e[0m\n", what);
      32              :         exit(0);
      33              :     }
      34              : }
      35              : 
      36              : NUT_ATTR_NONNULL(1)
      37              : NUT_ATTR_ACCESS(read_only, 1)
      38              : static inline void print_summary(const char *what, uint64_t correct, uint64_t total){
      39              :     fprintf(stderr, "%s (found %s for %"PRIu64"/%"PRIu64" numbers correctly)\e[0m\n", correct == total ? "\e[1;32mPASSED" : "\e[1;31mFAILED", what, correct, total);
      40              : }
      41              : 
        

Generated by: LCOV version 2.0-1