For decades, Jack has wanted a language that would let him do arithmetic with vectors and matrices. Now he has it. Here's a summation of his work on vector and matrix classes.
By Jack W. Crenshaw
The test driver
To test SimpleMat.cpp, I wrote a test driver, imaginatively called TestSimpleMat. This driver is called, in turn, by the overall regression test program, TestMatrices.
The philosophy behind these test programs bears repeating.
Each function in the classes Vectors and Matrices is, itself, relatively simple. In the old days, I would have written a test driver for each function, which asked me to input some test values of the inputs. Then it would output the results, and I'd have to verify that these results were correct. To do that requires a hand check. If I had to test the same function again, I'd probably have to repeat the hand check because I couldn't remember the values I'd used the first time. It does you absolutely no good to run the test without verifying the answer. To do so would violate the criterion voiced by my pal, Jim Adams: "When testing, never ask a question unless you already know the answer." Just saying, "Yep, that looks right" is not an option.
These days, I incorporate both the test inputs and expected outputs directly in the test driver. I use asserts to verify that the answers are correct. This results in what I call "Silent Testing." If all the tests pass, no asserts are violated, no exceptions are thrown, and the test program returns with no output at all. In this case, no news is good news.
When I was developing SimpleMat, I deviated from this path for the sake of expedience, reverting instead to the "Give me a vector to test," highly verbose sort of exchange. That's why I didn't post the code on Embedded.com; I didn't want you to see just how badly I can write code when time is tight.
Since then, I've spent a lot of time cleaning up TestSimpleMat and making it conform to the Silent Test sort of behavior. That code is posted, along with all the other files, on our Embedded.com source code library (Editor's Note: you now have to sign in to download code).
I'll only mention in passing that, some months back, I promised (threatened?) to reduce the number of files involved by combining SimpleVec, SimpleMat, Vectors, and Matrices into a single file and its corresponding header file. Fortunately, I took a cold shower and forgot that idea. As with everyone else, not all my ideas are good ones.