diff test/suite3/main.cc @ 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/suite3/main.cc	Sun Oct 03 19:41:41 2021 +0200
+++ b/test/suite3/main.cc	Tue Oct 05 21:53:04 2021 +0200
@@ -3,10 +3,10 @@
  Package: dyncall
  Library: test
  File: test/suite3/main.cc
- Description: 
+ Description:
  License:
 
-   Copyright (c) 2007-2018 Daniel Adler <dadler@uni-goettingen.de>, 
+   Copyright (c) 2007-2018 Daniel Adler <dadler@uni-goettingen.de>,
                            Tassilo Philipp <tphilipp@potion-studios.com>
 
    Permission to use, copy, modify, and distribute this software for any
@@ -69,13 +69,13 @@
     valueLongLong[i] = DClonglong(i);
     valueDouble[i]   = DCdouble(i);
     valueFloat[i]    = DCfloat(i);
-  } 
+  }
 }
 
 
 void push(DCCallVM* pCall, int select, int pos)
 {
-  switch(select) 
+  switch(select)
   {
     case 0: dcArgInt     ( pCall, valueInt     [pos] ); break;
     case 1: dcArgLongLong( pCall, valueLongLong[pos] ); break;
@@ -85,7 +85,7 @@
 }
 
 
-#define assert(x) if (!(x)) return false
+#define test(x) if (!(x)) return false
 
 
 bool test(int x)
@@ -97,21 +97,21 @@
   int y = x;
   int selects[NARGS] = { 0, };
   int pos = 0;
-  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(int i = 0;i<pos;++i) {
-    assert( equals( selects[i], i, getArg(i) ) );      
+    test( equals( selects[i], i, getArg(i) ) );
   }
-  
+
   dcFree(pCall);
   return true;
 }
@@ -146,7 +146,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;
@@ -156,11 +156,11 @@
     success = run_range(0,ncalls);
   }
 
-  printf("result: suite3: %s\n", success ? "1" : "0");
+  printf("result: suite3: %d\n", success);
 
   dcTest_deInitPlatform();
 
-  return (success) ? 0 : -1;
+  return !success;
 }
 
 }  // extern "C"