+++ /dev/null
-/* Copyright (C) 2003 TSUTSUMI Kikuo.
- This file is part of the CCUnit Library.
-
- The CCUnit Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public License
- as published by the Free Software Foundation; either version 2.1 of
- the License, or (at your option) any later version.
-
- The CCUnit Library is distributed in the hope that it will be
- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the CCUnit Library; see the file COPYING.LESSER.
- If not, write to the Free Software Foundation, Inc., 59 Temple
- Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-/*
- * $Id$
- */
-#include <stdio.h>
-#include <ccunit/CCUnitFailure.h>
-
-/**
- * convert failure object to string.
- * @param f failure object.
- * @return string as failure.
- */
-static const char* toString (CCUnitFailure* f)
-{
- if (!f)
- return NULL;
- else
- {
- char* str = NULL;
- size_t size = 63;
- size_t require;
- for (str = malloc (size); str != NULL; str = realloc (str, size))
- {
- if (!f->expect && !f->actual)
- {
- require = snprintf (str, size,
- "%s:%u: %s\n", f->file, f->line, f->condstr);
- }
- else
- {
- require = snprintf (str, size,
- "%s:%u: %s\n"
- "\texpect: %s\n"
- "\tactual: %s\n",
- f->file, f->line, f->condstr,
- f->expect,
- f->actual);
- }
- if (require < 0)
- size *= 2;
- else if (require >= size)
- size = require + 1;
- else
- {
- str = realloc (str, require + 1);
- break;
- }
- }
- return str;
- }
-}
-
-CCUnitFailure* ccunit_newFailure (const char* file,
- unsigned int line,
- const char* condstr,
- const char* expect,
- const char* actual)
-{
- CCUnitFailure* f = calloc (1, sizeof (*f));
- f->file = file;
- f->line = line;
- f->condstr = condstr;
- f->expect = safe_strdup (expect);
- f->actual = safe_strdup (actual);
- f->toString = toString;
- return f;
-}
-
-void ccunit_deleteFailure (CCUnitFailure* failure)
-{
- safe_free ((char*)failure->expect);
- safe_free ((char*)failure->actual);
- safe_free (failure);
-}
+++ /dev/null
-/* -*- C -*- */
-/* Copyright (C) 2003 TSUTSUMI Kikuo.
- This file is part of the CCUnit Library.
-
- The CCUnit Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public License
- as published by the Free Software Foundation; either version 2.1 of
- the License, or (at your option) any later version.
-
- The CCUnit Library is distributed in the hope that it will be
- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the CCUnit Library; see the file COPYING.LESSER.
- If not, write to the Free Software Foundation, Inc., 59 Temple
- Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-/*
- * $Id$
- */
-#ifndef CCUNITFAILURE_H
-#define CCUNITFAILURE_H
-
-#include <ccunit/CCUnitConfig.h>
-
-typedef struct CCUnitFailure CCUnitFailure;
-
-/**
- * Failure information.
- */
-struct CCUnitFailure
-{
- const char* file; /**< file name */
- unsigned int line; /**< line No. */
- const char* condstr; /**< test condition */
- const char* expect; /**< expect value as string */
- const char* actual; /**< actual value as string */
- const char* (*toString) (CCUnitFailure* failure); /**< convert string function */
-};
-
-/**
- * create new failure.
- *
- * @param file file name cause failure.
- * @param line line number cause failure.
- * @param condstr test condition as string.
- * @param expect expect value as string.
- * @param actual actual value as string.
- * @return new failure object.
- */
-extern CCUnitFailure* ccunit_newFailure (const char* file,
- unsigned int line,
- const char* condstr,
- const char* expect,
- const char* actual);
-
-/**
- * delete failure object.
- */
-extern void ccunit_deleteFailure (CCUnitFailure* failure);
-
-#endif