Skip to main content
Contents Index
Dark Mode Prev Up Next
\(\newcommand{\N}{\mathbb N}
\newcommand{\Z}{\mathbb Z}
\newcommand{\Q}{\mathbb Q}
\newcommand{\R}{\mathbb R}
\newcommand{\lt}{<}
\newcommand{\gt}{>}
\newcommand{\amp}{&}
\definecolor{fillinmathshade}{gray}{0.9}
\newcommand{\fillinmath}[1]{\mathchoice{\colorbox{fillinmathshade}{$\displaystyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\textstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptscriptstyle\phantom{\,#1\,}$}}}
\)
Section 19.6 Bottom-Up Testing
When working on a small sub-sub-problem of a big program via a function it is important to test the function extensively before making it part of the bigger program.
To do so, one simply writes a so-called
driver , that is, a main function whose purpose it is to call your new function in order to check whether if works correctly.
Suppose, for example, you are writing the function
simplify()
that simplifies a fraction. Here is a sample driver to test this function:
int main(void) {
int numer = 50;
int denom = 10;
printf("original: %d/%d\n", numer, denom);
simplify(&numer, &denom);
printf("simplified: %d/%d\n", numer, denom);
}
There is no point in making this fancy: you’ll discard it later!
Investigate 19.4 .
What should your driver do to the function you are testing?