1 #include <cstdio>
2 #include <cstdlib>
3 #include <iostream>
4 #include <string.h>
5 #include "TestMainEffectsExcelOutput.h"
6 #include "TestMainEffectsConverter.h"
7 #ifdef HAVE_STANDALONE
8 #include "TestOneWayANOVA.h"
9 #endif // HAVE_STANDALONE
10 #include "TestFactor.h"
11 #include "TestResponse.h"
12 #include "TestDDaceArraySampler.h"
13 //#include "TestDDaceStringArraySampler.h"
14 #include "TestMean.h"
15 #include "TestStdDeviation.h"
16 #include "TestDDaceSamplePoint.h"
17 #include "TestDDaceSampler.h"
18 #include "TestDDaceBoxBehnkenSampler.h"
19 #include "TestDDaceCentralCompositeSampler.h"
20 #include "TestDDaceFactorialSampler.h"
21 #include "TestDDaceLHSampler.h"
22 #include "TestDDaceOASampler.h"
23 #include "TestDDaceRandomSampler.h"
24 #include "TestDDaceUserInputSampler.h"
25 #include "TestUniformDistribution.h"
26 #include "TestNormalDistribution.h"
27 #include "TestDistribution.h"
28 #include "TestDDaceOALHSampler.h"
29 #ifdef HAVE_STANDALONE
30 #include "TestMarsAnalyzer.h"
31 #endif // HAVE_STANDALONE
32 #include "TestMainEffectsAnalyzer.h"
33 #include "TestPseudoRandom.h"
34 #ifdef _MSC_VER
35 #include <direct.h>
36 #define getcwd _getcwd
37 #define chdir _chdir
38 #else
39 #include <unistd.h>
40 #endif
41 
42 using namespace std;
43 
main(int argc,char ** argv)44 int main(int argc, char **argv) {
45 
46 try{
47 
48     /* When we are using the command line,                                 */
49     /* the Makefile cd's to this directory.                                */
50     /* When we are using an IDE,                                           */
51     /* the current working directory is wherever we launched the IDE from. */
52     /* If the current working directory does not end in "tests"            */
53     /* then cd to tests.                                                   */
54    char nameOfCurrentWorkingDirectory[1024];
55    char nameOfThisFolder[] = "tests";
56    getcwd(nameOfCurrentWorkingDirectory, 1024);
57    char *ptr = strstr(nameOfCurrentWorkingDirectory, nameOfThisFolder);
58    if (ptr==NULL) {
59    	    chdir(nameOfThisFolder);
60    }
61 
62 //    PMachine::init(argc, (void**)argv);
63 
64 
65     Suite s("DDace Test Suite", &cout);
66     s.addTest(new TestMainEffectsExcelOutput);
67     s.addTest(new TestMainEffectsConverter);
68 #ifdef HAVE_STANDALONE
69     s.addTest(new TestOneWayANOVA);
70 #endif // HAVE_STANDALONE
71     s.addTest(new TestFactor);
72     s.addTest(new TestResponse);
73     s.addTest(new TestPseudoRandom);
74     s.addTest(new TestDDaceArraySampler);
75     //s.addTest(new TestDDaceStringArraySampler);
76     s.addTest(new TestDDaceSamplePoint);
77     s.addTest(new TestDDaceSampler);
78     s.addTest(new TestDDaceBoxBehnkenSampler);
79     s.addTest(new TestDDaceCentralCompositeSampler);
80     s.addTest(new TestDDaceFactorialSampler);
81     s.addTest(new TestDDaceLHSampler);
82     s.addTest(new TestDDaceOASampler);
83     s.addTest(new TestDDaceRandomSampler);
84     s.addTest(new TestDDaceUserInputSampler);
85     s.addTest(new TestUniformDistribution);
86     s.addTest(new TestNormalDistribution);
87     s.addTest(new TestDDaceOALHSampler);
88 #ifdef HAVE_STANDALONE
89     s.addTest(new TestMarsAnalyzer);
90 #endif // HAVE_STANDALONE
91     s.addTest(new TestMainEffectsAnalyzer);
92     // if you are adding a test which involves
93     // random numbers in anyway put it after this
94     // line or else you are going to break
95     // some of the previous tests
96     s.addTest(new TestDistribution);
97     s.addTest(new TestMean);
98     s.addTest(new TestStdDeviation);
99     s.run();
100 
101 
102     /* if I do NOT have any command line arguments */
103     /* then print the entire report.               */
104     long nFail = 0;
105     if (argc==1) {
106         nFail = s.report();
107         s.free();
108         cout << "\nTotal Failures: " << nFail << endl;
109 
110     /* if I have one or more command line arguments */
111     /*     if there are no failures then print 0    */
112     /*     else print the entire report             */
113     } else {
114         nFail = s.getNumFailed();
115         cout << nFail << endl;
116         if (nFail != 0) {
117             s.report();
118             cout << "\nTotal Failures: " << nFail << endl;
119         }
120 	s.free();
121     }
122 
123 /**
124     PMachine::synchronize(PWorld());
125 
126     PMachine::finalize();
127 **/
128 return(nFail);
129 
130 }
131 catch(std::exception& e)
132 {
133 	cerr << "The following exception occured: " << e.what() << endl;
134 }
135 /**catch(...)
136 {
137 	cerr << "An exception occurred, but I don't know what it was, sorry." << endl;
138 }
139 */
140 }
141 
142