LCOV - code coverage report
Current view: top level - ccan/container_of/test - run.c (source / functions) Hit Total Coverage
Test: skiboot.info Lines: 13 13 100.0 %
Date: 2024-09-10 18:37:41 Functions: 1 1 100.0 %
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : #include <ccan/container_of/container_of.h>
       2                 :            : #include <ccan/tap/tap.h>
       3                 :            : 
       4                 :            : struct foo {
       5                 :            :         int a;
       6                 :            :         char b;
       7                 :            : };
       8                 :            : 
       9                 :          2 : int main(void)
      10                 :            : {
      11                 :          2 :         struct foo foo = { .a = 1, .b = 2 };
      12                 :          2 :         int *intp = &foo.a;
      13                 :          2 :         char *charp = &foo.b;
      14                 :            : 
      15                 :            :         plan_tests(12);
      16                 :          2 :         ok1(container_of(intp, struct foo, a) == &foo);
      17                 :          2 :         ok1(container_of(charp, struct foo, b) == &foo);
      18                 :          2 :         ok1(container_of_or_null(intp, struct foo, a) == &foo);
      19                 :          2 :         ok1(container_of_or_null(charp, struct foo, b) == &foo);
      20                 :          2 :         ok1(container_of_or_null((int *)NULL, struct foo, a) == NULL);
      21                 :          2 :         ok1(container_of_or_null((char *)NULL, struct foo, b) == NULL);
      22                 :          2 :         ok1(container_of_var(intp, &foo, a) == &foo);
      23                 :          2 :         ok1(container_of_var(charp, &foo, b) == &foo);
      24                 :            : 
      25                 :            :         ok1(container_off(struct foo, a) == 0);
      26                 :            :         ok1(container_off(struct foo, b) == offsetof(struct foo, b));
      27                 :            :         ok1(container_off_var(&foo, a) == 0);
      28                 :            :         ok1(container_off_var(&foo, b) == offsetof(struct foo, b));
      29                 :          2 :         return exit_status();
      30                 :            : }

Generated by: LCOV version 1.14