LCOV - code coverage report
Current view: top level - common - t-strlist.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 20 29 69.0 %
Date: 2016-11-29 15:00:56 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /* t-strlist.c - Regression tests for strist.c
       2             :  * Copyright (C) 2015  g10 Code GmbH
       3             :  *
       4             :  * This file is part of GnuPG.
       5             :  *
       6             :  * GnuPG is free software; you can redistribute it and/or modify it
       7             :  * under the terms of either
       8             :  *
       9             :  *   - the GNU Lesser General Public License as published by the Free
      10             :  *     Software Foundation; either version 3 of the License, or (at
      11             :  *     your option) any later version.
      12             :  *
      13             :  * or
      14             :  *
      15             :  *   - the GNU General Public License as published by the Free
      16             :  *     Software Foundation; either version 2 of the License, or (at
      17             :  *     your option) any later version.
      18             :  *
      19             :  * or both in parallel, as here.
      20             :  *
      21             :  * GnuPG is distributed in the hope that it will be useful, but
      22             :  * WITHOUT ANY WARRANTY; without even the implied warranty of
      23             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      24             :  * General Public License for more details.
      25             :  *
      26             :  * You should have received a copies of the GNU General Public License
      27             :  * and the GNU Lesser General Public License along with this program;
      28             :  * if not, see <https://www.gnu.org/licenses/>.
      29             :  */
      30             : 
      31             : #include <config.h>
      32             : #include <string.h>
      33             : 
      34             : #include "strlist.h"
      35             : 
      36             : #include "t-support.h"
      37             : 
      38             : static void
      39           1 : test_strlist_rev (void)
      40             : {
      41           1 :   strlist_t s = NULL;
      42             : 
      43             :   /* Reversing an empty list should yield the empty list.  */
      44           1 :   if (! (strlist_rev (&s) == NULL))
      45           0 :     fail (1);
      46             : 
      47           1 :   add_to_strlist (&s, "1");
      48           1 :   add_to_strlist (&s, "2");
      49           1 :   add_to_strlist (&s, "3");
      50             : 
      51           1 :   if (strcmp (s->d, "3") != 0)
      52           0 :     fail (2);
      53           1 :   if (strcmp (s->next->d, "2") != 0)
      54           0 :     fail (2);
      55           1 :   if (strcmp (s->next->next->d, "1") != 0)
      56           0 :     fail (2);
      57           1 :   if (s->next->next->next)
      58           0 :     fail (2);
      59             : 
      60           1 :   strlist_rev (&s);
      61             : 
      62           1 :   if (strcmp (s->d, "1") != 0)
      63           0 :     fail (2);
      64           1 :   if (strcmp (s->next->d, "2") != 0)
      65           0 :     fail (2);
      66           1 :   if (strcmp (s->next->next->d, "3") != 0)
      67           0 :     fail (2);
      68           1 :   if (s->next->next->next)
      69           0 :     fail (2);
      70             : 
      71           1 :   free_strlist (s);
      72           1 : }
      73             : 
      74             : 
      75             : int
      76           1 : main (int argc, char **argv)
      77             : {
      78             :   (void)argc;
      79             :   (void)argv;
      80             : 
      81           1 :   test_strlist_rev ();
      82             : 
      83           1 :   return 0;
      84             : }

Generated by: LCOV version 1.11