Subversion Repositories PlanixRsrch.SVN

Compare Revisions

Ignore whitespace Rev 172 → Rev 175

/tags/libmutests-1.1.0/LICENSE
0,0 → 1,26
/*
* Copyright 2019, The PLANIX Project
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/tags/libmutests-1.1.0/Makefile
0,0 → 1,30
 
OBJS=mutests_run.o
 
LIBNAME=libmutests.a
 
PREFIX=~
 
.c.o:
$(CC) -c $(CFLAGS) $<
 
$(LIBNAME): $(OBJS)
$(AR) rcs $(LIBNAME) $(OBJS)
 
example1: $(LIBNAME) example1.o
$(CC) -o example1 example1.o $(LIBNAME)
 
 
clean:
rm -f $(OBJS)
rm -f $(LIBNAME)
rm -f example1.o example1
rm -f example2.o example2
rm -f *.core
 
install: $(LIBNAME)
mkdir -p $(PREFIX)/lib
mkdir -p $(PREFIX)/include/
$(INSTALL) -p $(LIBNAME) $(PREFIX)/lib/$(LIBNAME)
$(INSTALL) -p mutests.h $(PREFIX)/include/mutests.h
 
/tags/libmutests-1.1.0/example1.c
0,0 → 1,31
/* file minunit_example.c */
#include <stdio.h>
#include "mutests.h"
int foo = 7;
int bar = 15;
static int test_foo() {
mu_assert(foo == 7, "error, foo != 7");
return 1;
}
static int test_bar() {
mu_assert(bar == 5, "error, bar != 5" );
return 1;
}
 
 
int main() {
mutests tests = {
test_foo,
test_bar,
NULL
};
return mutests_run(tests);
}
 
 
 
/tags/libmutests-1.1.0/mutests.h
0,0 → 1,40
/*
* Copyright 2019 2020, The PLANIX Project
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/* mutests.h
* based loosely on
* http://www.jera.com/techinfo/jtns/jtn002.html#Source_Code
*/
#ifndef _MUTESTS_H
#define _MUTESTS_H
 
int mutests_run( int (*tflist[])() );
typedef int(*mutests[])();
 
void mu_assert(int test, const char *, ...);
 
#endif
/tags/libmutests-1.1.0/mutests_run.c
0,0 → 1,70
/*
* Copyright 2019, The PLANIX Project
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
#include <stdio.h>
#include <setjmp.h>
#include <stdarg.h>
 
#include "mutests.h"
 
static jmp_buf mubuf;
 
void mu_assert(int test, const char * msg, ...)
{
va_list vl;
 
if (test)
return;
 
va_start(vl,msg);
(void)fprintf(stderr,"FAIL: ");
(void)vfprintf(stderr,msg,vl);
(void)fprintf(stderr,"\n");
va_end(vl);
longjmp(mubuf,1);
}
 
int mutests_run( int (*tflist[])() )
{
int i,failed;
 
failed = 0;
for (i=0; tflist[i]!=NULL; i++){
if (setjmp(mubuf) ){
failed ++;
}
else{
if (!tflist[i]()){
failed ++;
};
}
}
if (!failed)
(void)printf("ALL %d TESTS PASSED\n",i);
return failed;
}
 
/tags/libmutests-1.1.0
Property changes:
Added: svn:mergeinfo
## -0,0 +0,1 ##
Merged /branches/bnf/libmutests:r79-129