Commit c864233aafc7e24d5235d5641807d736dc29c9f5
1 parent
501ed758
remove test code copied from trbase.
Showing
3 changed files
with
0 additions
and
242 deletions
tests/classTest.c
deleted
100644 → 0
| 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 "tr/class.h" | |
| 26 | - | |
| 27 | -const char testname[] = "cclassTest"; | |
| 28 | - | |
| 29 | -MockClass mock = NULL; | |
| 30 | - | |
| 31 | -static | |
| 32 | -int | |
| 33 | -__setUp() | |
| 34 | -{ | |
| 35 | - mock = NULL; | |
| 36 | - _reset(); | |
| 37 | - | |
| 38 | - return TEST_OK; | |
| 39 | -} | |
| 40 | -int (* const setUp)() = __setUp; | |
| 41 | - | |
| 42 | -static | |
| 43 | -int | |
| 44 | -__tearDown() | |
| 45 | -{ | |
| 46 | - if (NULL != mock) { | |
| 47 | - ASSERT_OBJECT(mock); | |
| 48 | - TR_delete(mock); | |
| 49 | - } | |
| 50 | - | |
| 51 | - return TEST_OK; | |
| 52 | -} | |
| 53 | -int (* const tearDown)() = __tearDown; | |
| 54 | - | |
| 55 | -static | |
| 56 | -int | |
| 57 | -testNew(void) | |
| 58 | -{ | |
| 59 | - mock = TR_new(MockClass, 123); | |
| 60 | - | |
| 61 | - ASSERT_OBJECT_NOT_NULL(mock); | |
| 62 | - ASSERT_EQUAL(1, _called); | |
| 63 | - ASSERT_EQUAL(123, mock->value); | |
| 64 | - | |
| 65 | - return TEST_OK; | |
| 66 | -} | |
| 67 | - | |
| 68 | -static | |
| 69 | -int | |
| 70 | -testNewFail(void) | |
| 71 | -{ | |
| 72 | - mock = TR_new(MockClass, 321); | |
| 73 | - | |
| 74 | - ASSERT_NULL(mock); | |
| 75 | - | |
| 76 | - return TEST_OK; | |
| 77 | -} | |
| 78 | - | |
| 79 | -static | |
| 80 | -int | |
| 81 | -testDelete(void) | |
| 82 | -{ | |
| 83 | - mock = TR_new(MockClass, 123); | |
| 84 | - | |
| 85 | - ASSERT_NOT_NULL(mock); | |
| 86 | - | |
| 87 | - _reset(); | |
| 88 | - TR_delete(mock); | |
| 89 | - | |
| 90 | - ASSERT_NULL(mock); | |
| 91 | - ASSERT_EQUAL(1, _called); | |
| 92 | - | |
| 93 | - return TEST_OK; | |
| 94 | -} | |
| 95 | - | |
| 96 | -static | |
| 97 | -int | |
| 98 | -testClone(void) | |
| 99 | -{ | |
| 100 | - MockClass clone; | |
| 101 | - | |
| 102 | - mock = TR_new(MockClass, 123); | |
| 103 | - clone = TR_clone(mock); | |
| 104 | - | |
| 105 | - ASSERT_INSTANCE_OF(MockClass, clone); | |
| 106 | - ASSERT_EQUAL(mock->value, clone->value); | |
| 107 | - | |
| 108 | - TR_delete(clone); | |
| 109 | - | |
| 110 | - 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: |
tests/mock/mock_class.c
deleted
100644 → 0
| 1 | -/** | |
| 2 | - * \file | |
| 3 | - * mock/class.c: a mock to test my oop 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 | - | |
| 20 | -#include <assert.h> | |
| 21 | -#include <stdarg.h> | |
| 22 | - | |
| 23 | -#include "tr/class.h" | |
| 24 | -#include "mock_class.h" | |
| 25 | - | |
| 26 | -char _called; | |
| 27 | - | |
| 28 | -void | |
| 29 | -_reset() | |
| 30 | -{ | |
| 31 | - _called = 0; | |
| 32 | -} | |
| 33 | - | |
| 34 | -static | |
| 35 | -inline | |
| 36 | -int | |
| 37 | -mockCtor(void * _this, va_list * params) | |
| 38 | -{ | |
| 39 | - MockClass this = _this; | |
| 40 | - | |
| 41 | - _called = 1; | |
| 42 | - this->value = va_arg(* params, int); | |
| 43 | - | |
| 44 | - if (321 == this->value) | |
| 45 | - return -1; | |
| 46 | - | |
| 47 | - return 0; | |
| 48 | -} | |
| 49 | - | |
| 50 | -static | |
| 51 | -inline | |
| 52 | -void | |
| 53 | -mockDtor(void * _this) | |
| 54 | -{ | |
| 55 | - _called = 1; | |
| 56 | -} | |
| 57 | - | |
| 58 | -static | |
| 59 | -inline | |
| 60 | -void | |
| 61 | -mockClone(void * _this, void * _base) | |
| 62 | -{ | |
| 63 | - MockClass this = _this; | |
| 64 | - MockClass base = _base; | |
| 65 | - | |
| 66 | - this->value = base->value; | |
| 67 | -} | |
| 68 | - | |
| 69 | -TR_INIT_IFACE(TR_Class, mockCtor, mockDtor, mockClone); | |
| 70 | -TR_CREATE_CLASS(MockClass, NULL, TR_IF(TR_Class)); | |
| 71 | - | |
| 72 | -// vim: set et ts=4 sw=4: |
tests/mock/mock_class.h
deleted
100644 → 0
| 1 | -/** | |
| 2 | - * \file | |
| 3 | - * mock/class.h: definitions for my mock to test my oop stuff | |
| 4 | - * | |
| 5 | - * \author Georg Hopp <georg@steffers.org> | |
| 6 | - * | |
| 7 | - * \copyright | |
| 8 | - * Copyright (C) 2011 Georg Hopp | |
| 9 | - * | |
| 10 | - * This program is free software: you can redistribute it and/or modify | |
| 11 | - * it under the terms of the GNU General Public License as published by | |
| 12 | - * the Free Software Foundation, either version 3 of the License, or | |
| 13 | - * (at your option) any later version. | |
| 14 | - * | |
| 15 | - * This program is distributed in the hope that it will be useful, | |
| 16 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 17 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 18 | - * GNU General Public License for more details. | |
| 19 | - * | |
| 20 | - * You should have received a copy of the GNU General Public License | |
| 21 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 22 | - */ | |
| 23 | -#ifndef __MOCK_MOCK_CLASS_H__ | |
| 24 | -#define __MOCK_MOCK_CLASS_H__ | |
| 25 | - | |
| 26 | -#include "trbase.h" | |
| 27 | - | |
| 28 | -extern char _called; | |
| 29 | - | |
| 30 | -#ifndef _RESET | |
| 31 | -#define _RESET | |
| 32 | -void _reset(); | |
| 33 | -#endif // _RESET | |
| 34 | - | |
| 35 | - | |
| 36 | -TR_CLASS(MockClass) { | |
| 37 | - int value; | |
| 38 | -}; | |
| 39 | - | |
| 40 | -/** | |
| 41 | - * ~~~ method declarations ~~~~~~~~ | |
| 42 | - */ | |
| 43 | - | |
| 44 | -int mockClassGetValue(MockClass this); | |
| 45 | -void mockClassSetValue(MockClass this, int value); | |
| 46 | - | |
| 47 | -#endif//__MOCK_MOCK_CLASS_H__ | |
| 48 | - | |
| 49 | -// vim: set et ts=4 sw=4: |
Please
register
or
login
to post a comment