% This is a file written using noweb
%
% $Id: outtest.nw,v 1.1 1996/03/13 11:29:02 gaertner Exp $
%

\documentclass{article}
\usepackage{a4,version,pretzeldoc,noweb}
\begin{document}

\includeversion{bigspecs}
%\includeversion{impls}
%\excludeversion{bigspecs}% without elaborate specification
\excludeversion{impls}% without implementation



\title{Testing the [[Output]] Class}
\author{Felix G\"artner}
\maketitle


%\begin{abstract}
%    XXX
%\end{abstract}


\tableofcontents


\section{Introduction}

This is a short program to have a little confidence that the output
class is doing what it should do. We'll test the output class a few
times: First in normal mode and then in debug mode.

<<implementation>>=
#include<iostream>

using namespace std;

#include"output.h"

<<Global variables>>
<<Functions>>

int main() {

cout << "Starting to test the outputs..." << endl;
<<Test once>>
<<Test twice (debug)>>
<<Third go>>
cout << "Done." << endl;
return 0;
}

@ Testing is done on an output object that will be global and simply
called |o|. It is connected with the standard output.

<<Global variables>>=
Latex_cweb_output o(cout);


@ To have the code written only once, here's a function that does
the testing. It creates various calls of |do_output| and thus invokes
action within the output routine.

<<Functions>>=
void do_testing()
{
    o.do_output("if");
    o.do_output(" ");
    o.do_output("(x<0)");
    o.do_output(" ");
    o.do_output("then");
    o.do_output(indent);
    o.do_output(force);
    o.do_output("begin");
    o.do_output(" ");
    o.do_output("abs");
    o.do_output(":=");
    o.do_output("-1");
    o.do_output(" ");
    o.do_output("end");
    o.do_output(";");
    o.do_output(outdent);
    o.do_output(force);
    o.do_output("");	/* to flush output */
    return;
}

@ The first test is done in normal mode. We'll switch the debug mode
on and off again once to look what happens.

<<Test once>>=
cout << "Doing first round of testing:" << endl;
o.debug_on();
o.debug_off();
do_testing();
cout << endl << endl;

@ The second round is done in debug mode.

<<Test twice (debug)>>=
cout << "Doing second round of testing:" << endl;
o.debug_on();
do_testing();
o.debug_off();
cout << endl << endl;

@ The third go uses \C\ comments as debug delimiters.

<<Third go>>=
cout << "Doing third round of testing:" << endl;
o.debug_on("/*","*/");
do_testing();
o.debug_off();
cout << endl << endl;

@


\end{document}


%
% $Log: outtest.nw,v $
% Revision 1.1  1996/03/13  11:29:02  gaertner
% Initial revision
%
%

