Mercurial > pub > dyncall > dyncall
diff test/suite/main.c @ 410:7608e34098b0
- cleanups, simplifications, some api clarification, ...
- test cases consistency:
* return status code depending on test results (for actual conformance tests, not stuff that is not an example or hack to check something, ..)
* platform init helper added for some
author | Tassilo Philipp |
---|---|
date | Tue, 05 Oct 2021 21:53:04 +0200 |
parents | f5577f6bf97a |
children | d73dc7ad37e4 |
line wrap: on
line diff
--- a/test/suite/main.c Sun Oct 03 19:41:41 2021 +0200 +++ b/test/suite/main.c Tue Oct 05 21:53:04 2021 +0200 @@ -3,10 +3,10 @@ Package: dyncall Library: test File: test/suite/main.c - Description: + Description: License: - Copyright (c) 2007-2018 Daniel Adler <dadler@uni-goettingen.de>, + Copyright (c) 2007-2021 Daniel Adler <dadler@uni-goettingen.de>, Tassilo Philipp <tphilipp@potion-studios.com> Permission to use, copy, modify, and distribute this software for any @@ -89,13 +89,13 @@ valueDouble[i] = (DCdouble) (i); valuePointer[i] = (DCpointer) (ptrdiff_t) (i); valueFloat[i] = (DCfloat) (i); - } + } } void push(DCCallVM* pCall, int select, int pos) { - switch(select) + switch(select) { case ID_BOOL: dcArgBool ( pCall, valueBool [pos] ); break; case ID_INT: dcArgInt ( pCall, valueInt [pos] ); break; @@ -107,7 +107,7 @@ } -#define assert(x) if (!(x)) return DC_FALSE +#define test(x) if (!(x)) return DC_FALSE DCbool test(int x) @@ -120,21 +120,21 @@ dcReset(pCall); clearValues(); - for(pos = 0; y>0; ++pos) + for(pos = 0; y>0; ++pos) { - int select = (y-1) % NTYPES; + int select = (y-1) % NTYPES; selects[pos] = select; push(pCall,select,pos); y = (y-1) / NTYPES; } dcCallVoid(pCall,getFunc(x)); - - assert( getId() == x ); - + + test( getId() == x ); + for(i = 0;i<pos;++i) { - assert( equals( selects[i], i, getArg(i) ) ); + test( equals( selects[i], i, getArg(i) ) ); } - + dcFree(pCall); return DC_TRUE; } @@ -170,7 +170,7 @@ init(); if (argc == 2) { int index = atoi(argv[1]); - success = run_range( index, index+1 ); + success = run_range( index, index+1 ); } else if (argc == 3) { int from = atoi(argv[1]); int to = atoi(argv[2])+1; @@ -180,9 +180,10 @@ success = run_range(0,ncalls); } - printf("result: suite: %s\n", success ? "1" : "0"); + printf("result: suite: %d\n", success); dcTest_deInitPlatform(); - return (success) ? 0 : -1; + return !success; } +