LCOV - code coverage report
Current view: top level - opt/gitlab-ci-multi-runner/builds/00e3338d/0/taskrambler/taskrambler/tests - classTest.c (source / functions) Hit Total Coverage
Test: taskrambler 0.1.9 Lines: 34 34 100.0 %
Date: 2016-04-13 23:18:54 Functions: 6 6 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /**
       2                 :            :  * \file
       3                 :            :  * cclassTest.c: tests for my oop C stuff
       4                 :            :  * Copyright (C) 2011  Georg Hopp
       5                 :            :  *
       6                 :            :  * This program is free software: you can redistribute it and/or modify
       7                 :            :  * it under the terms of the GNU General Public License as published by
       8                 :            :  * the Free Software Foundation, either version 3 of the License, or
       9                 :            :  * (at your option) any later version.
      10                 :            :  *
      11                 :            :  * This program is distributed in the hope that it will be useful,
      12                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      13                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      14                 :            :  * GNU General Public License for more details.
      15                 :            :  *
      16                 :            :  * You should have received a copy of the GNU General Public License
      17                 :            :  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
      18                 :            :  */
      19                 :            : #include <stdio.h>
      20                 :            : #include <sys/types.h>
      21                 :            : 
      22                 :            : #include "runtest.h"
      23                 :            : #include "mock/mock_class.h"
      24                 :            : 
      25                 :            : #include "class.h"
      26                 :            : 
      27                 :            : const char testname[] = "cclassTest";
      28                 :            : 
      29                 :            : MockClass mock = NULL;
      30                 :            : 
      31                 :            : static
      32                 :            : int
      33                 :          4 : __setUp()
      34                 :            : {
      35                 :          4 :     mock = NULL;
      36                 :          4 :     _reset();
      37                 :            : 
      38                 :          4 :     return TEST_OK;
      39                 :            : }
      40                 :            : int (* const setUp)() = __setUp;
      41                 :            : 
      42                 :            : static
      43                 :            : int
      44                 :          4 : __tearDown()
      45                 :            : {
      46                 :          4 :     if (NULL != mock) {
      47                 :          2 :         ASSERT_OBJECT(mock);
      48                 :          2 :         delete(mock);
      49                 :            :     }
      50                 :            : 
      51                 :          4 :     return TEST_OK;
      52                 :            : }
      53                 :            : int (* const tearDown)() = __tearDown;
      54                 :            : 
      55                 :            : static
      56                 :            : int
      57                 :          1 : testNew(void)
      58                 :            : {
      59                 :          1 :     mock = new(MockClass, 123);
      60                 :            : 
      61                 :          1 :     ASSERT_OBJECT_NOT_NULL(mock);
      62                 :          1 :     ASSERT_EQUAL(1, _called);
      63                 :          1 :     ASSERT_EQUAL(123, mock->value);
      64                 :            : 
      65                 :          1 :     return TEST_OK;
      66                 :            : }
      67                 :            : 
      68                 :            : static
      69                 :            : int
      70                 :          1 : testNewFail(void)
      71                 :            : {
      72                 :          1 :     mock = new(MockClass, 321);
      73                 :            : 
      74                 :          1 :     ASSERT_NULL(mock);
      75                 :            : 
      76                 :          1 :     return TEST_OK;
      77                 :            : }
      78                 :            : 
      79                 :            : static
      80                 :            : int
      81                 :          1 : testDelete(void)
      82                 :            : {
      83                 :          1 :     mock = new(MockClass, 123);
      84                 :            : 
      85                 :          1 :     ASSERT_NOT_NULL(mock);
      86                 :            : 
      87                 :          1 :     _reset();
      88                 :          1 :     delete(mock);
      89                 :            : 
      90                 :          1 :     ASSERT_NULL(mock);
      91                 :          1 :     ASSERT_EQUAL(1, _called);
      92                 :            : 
      93                 :          1 :     return TEST_OK;
      94                 :            : }
      95                 :            : 
      96                 :            : static
      97                 :            : int
      98                 :          1 : testClone(void)
      99                 :            : {
     100                 :            :     MockClass clone;
     101                 :            : 
     102                 :          1 :     mock  = new(MockClass, 123);
     103                 :          1 :     clone = clone(mock);
     104                 :            : 
     105                 :          1 :     ASSERT_INSTANCE_OF(MockClass, clone);
     106                 :          1 :     ASSERT_EQUAL(mock->value, clone->value);
     107                 :            : 
     108                 :          1 :     delete(clone);
     109                 :            : 
     110                 :          1 :     return TEST_OK;
     111                 :            : }
     112                 :            : 
     113                 :            : const testfunc tests[] = {
     114                 :            :     testNew,
     115                 :            :     testNewFail,
     116                 :            :     testDelete,
     117                 :            :     testClone
     118                 :            : };
     119                 :            : const size_t count = FUNCS_COUNT(tests);
     120                 :            : 
     121                 :            : // vim: set et ts=4 sw=4:

Generated by: LCOV version 1.11