1/*======================================================================== 2 Copyright (C) 1996-2001 by Jorn Lind-Nielsen 3 All rights reserved 4 5 Permission is hereby granted, without written agreement and without 6 license or royalty fees, to use, reproduce, prepare derivative 7 works, distribute, and display this software and its documentation 8 for any purpose, provided that (1) the above copyright notice and 9 the following two paragraphs appear in all copies of the source code 10 and (2) redistributions, including without limitation binaries, 11 reproduce these notices in the supporting documentation. Substantial 12 modifications to this software may be copyrighted by their authors 13 and need not follow the licensing terms described here, provided 14 that the new terms are clearly indicated in all files where they apply. 15 16 IN NO EVENT SHALL JORN LIND-NIELSEN, OR DISTRIBUTORS OF THIS 17 SOFTWARE BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, 18 INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS 19 SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE AUTHORS OR ANY OF THE 20 ABOVE PARTIES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 21 22 JORN LIND-NIELSEN SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING, 23 BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 24 FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS 25 ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO 26 OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR 27 MODIFICATIONS. 28========================================================================*/ 29 30#include <string> 31#include "bdd.h" 32 33using namespace std; 34 35 36#define ERROR(msg) fail(msg, __FILE__, __LINE__) 37 38static void fail(const string msg, const char* file, int lineNum) 39{ 40 cout << "Error in " << file << "(" << lineNum << "): " << msg << endl; 41 exit(1); 42} 43 44 45static void testSupport(void) 46{ 47 bdd even = bdd_ithvar(0) | bdd_ithvar(2) | bdd_ithvar(4); 48 bdd odd = bdd_ithvar(1) | bdd_ithvar(3) | bdd_ithvar(5); 49 50 cout << "Testing support\n"; 51 52 bdd s1 = bdd_support(even); 53 bdd s2 = bdd_support(odd); 54 55 if (s1 != (bdd_ithvar(0) & bdd_ithvar(2) & bdd_ithvar(4))) 56 ERROR("Support of 'even' failed\n"); 57 if (s2 != (bdd_ithvar(1) & bdd_ithvar(3) & bdd_ithvar(5))) 58 ERROR("Support of 'odd' failed\n"); 59 60 /* Try many time in order check that the internal support ID 61 * is set correctly */ 62 for (int n=0 ; n<500 ; ++n) 63 { 64 s1 = bdd_support(even); 65 s2 = bdd_support(odd); 66 67 if (s1 != (bdd_ithvar(0) & bdd_ithvar(2) & bdd_ithvar(4))) 68 ERROR("Support of 'even' failed"); 69 if (s2 != (bdd_ithvar(1) & bdd_ithvar(3) & bdd_ithvar(5))) 70 ERROR("Support of 'odd' failed"); 71 } 72} 73 74 75int main(int ac, char** av) 76{ 77 bdd_init(1000,1000); 78 79 bdd_setvarnum(10); 80 81 testSupport(); 82 83 bdd_done(); 84 return 0; 85} 86