2 * Copyright (C) 2000, 2001 Free Software Foundation, Inc.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
30 pass (const char *s
) {
32 printf ("\tPASSED: %s\n", s
);
36 fail (const char *s
) {
38 printf ("\tFAILED: %s\n", s
);
42 untested (const char *s
) {
44 printf ("\tUNTESTED: %s\n", s
);
48 unresolved (const char *s
) {
50 printf ("\tUNRESOLVED: %s\n", s
);
55 printf ("\nTotals:\n");
56 printf ("\t#passed:\t\t%d\n", passed
);
57 printf ("\t#failed:\t\t%d\n", failed
);
59 printf ("\t#untested:\t\t%d\n", untest
);
61 printf ("\t#unresolved:\t\t%d\n", unresolved
);
80 extern ios
& __iomanip_testout (ios
&, int);
81 inline smanip
<int> testout (int n
) {
82 return smanip
<int> (__iomanip_testout
, n
);
84 ios
& __iomanip_testout (ios
& i
, int x
) {
92 ostream
&(*f
)(ostream
&, T
);
94 OMANIP(ostream
& (*ff
)(ostream
&, T
), T ii
) : f(ff
), i(ii
) {
96 friend ostream
operator<<(ostream
& us
, OMANIP
& m
) {
102 freakout(ostream
& os
, int x
) {
103 return os
<< "FREAKOUT" ;
104 // return x << "TESTOUT " << x ;
107 OMANIP
<int> testout(int i
) {
108 return OMANIP
<int>(&freakout
,i
);
112 char *testout (int x
) {
114 static char buf
[len
];
115 static ostrstream
oss(buf
, len
, ios::out
);
117 oss
<< outstate
[x
] << ends
;
121 enum teststate
{FAILED
, PASSED
,UNTESTED
,UNRESOLVED
} laststate
;
138 void testrun (bool b
, string s
) {
145 void pass (string s
) {
149 cout
<< "\t" << testout(PASSED
) << s
<< endl
;
151 void pass (const char *c
) {
156 void fail (string s
) {
160 cout
<< "\t" << testout(FAILED
) << s
<< endl
;
162 void fail (const char *c
) {
167 void untested (string s
) {
169 laststate
= UNTESTED
;
171 cout
<< "\t" << testout(UNTESTED
) << s
<< endl
;
173 void untested (const char *c
) {
178 void unresolved (string s
) {
180 laststate
= UNRESOLVED
;
182 cout
<< "\t" << testout(UNRESOLVED
) << s
<< endl
;
184 void unresolved (const char *c
) {
190 cout
<< "\t#passed:\t\t" << passed
<< endl
;
191 cout
<< "\t#failed:\t\t" << failed
<< endl
;
193 cout
<< "\t#untested:\t\t" << untest
<< endl
;
195 cout
<< "\t#unresolved:\t\t" << unresolve
<< endl
;
198 // This is so thjis class can be printed in an ostream.
199 friend ostream
& operator << (ostream
&os
, TestState
& t
) {
200 return os
<< "\t" << outstate
[t
.laststate
] << t
.lastmsg
;
206 string
GetMsg(void) {
211 #endif // __cplusplus
212 #endif // _DEJAGNU_H_