LCOV - code coverage report
Current view: top level - test - test_thread.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 12 12 100.0 %
Date: 2026-11-26 02:32:31 Functions: 2 2 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 3 6 50.0 %

           Branch data     Line data    Source code
       1                 :            : // Copyright 2012-2022 David Robillard <d@drobilla.net>
       2                 :            : // SPDX-License-Identifier: ISC
       3                 :            : 
       4                 :            : #undef NDEBUG
       5                 :            : 
       6                 :            : #include <zix/status.h>
       7                 :            : #include <zix/thread.h>
       8                 :            : 
       9                 :            : #include <assert.h>
      10                 :            : #include <string.h>
      11                 :            : 
      12                 :            : typedef struct {
      13                 :            :   int input;
      14                 :            :   int output;
      15                 :            : } SharedData;
      16                 :            : 
      17                 :            : static ZixThreadResult ZIX_THREAD_FUNC
      18                 :          1 : thread_func(void* const arg)
      19                 :            : {
      20                 :          1 :   SharedData* const data = (SharedData*)arg;
      21                 :            : 
      22                 :          1 :   data->output = data->input * 7;
      23                 :            : 
      24                 :          1 :   return ZIX_THREAD_RESULT;
      25                 :            : }
      26                 :            : 
      27                 :            : int
      28                 :          1 : main(int argc, char** argv)
      29                 :            : {
      30                 :            :   (void)argv;
      31                 :            : 
      32                 :            :   ZixThread thread; // NOLINT
      33                 :            : 
      34                 :          1 :   SharedData data = {argc + (int)strlen(argv[0]), 0};
      35                 :            : 
      36                 :          1 :   ZixStatus st = zix_thread_create(&thread, 128, thread_func, &data);
      37         [ -  + ]:          1 :   assert(!st);
      38                 :            : 
      39                 :          1 :   st = zix_thread_join(thread);
      40         [ -  + ]:          1 :   assert(!st);
      41                 :            : 
      42         [ -  + ]:          1 :   assert(data.output == data.input * 7);
      43                 :            : 
      44                 :          1 :   return 0;
      45                 :            : }

Generated by: LCOV version 1.16