When you create your test class, you override the Test member function. The Test function contains the operations you use to perform the test.
1 // File: SimpleArrayTest.C 2 // Copyright (C) 1995 Taligent, Inc. All rights reserved. 3 void TSimpleTest::Test() 4 { 5 bool success = true; 6 // Always set 'success' to false if any test fails. 7 // Always check to see that 'success' is true before beginning subsequent tests. 8 9 OutputTextStream() << "TSimpleTest - Test method called.\n"; 10 OutputTextStream() << "This tests TArray.\n\n"; 11 12 int fArraySize = 10; // number of elements in the array 13 14 TArrayOf<TCollectibleLong> array; 15 for (int i = 0; i < fArraySize; i++) { 16 array.Add(new TCollectibleLong(i)); 17 } 18 success = array.Count() == fArraySize; 19 20 array.DeleteAll(); 21 22 SetSuccess(success); // *** NEVER DELETE THIS 23 24 // This is an example of how to display messages to the console 25 OutputTextStream() << "fArraySize = " << fArraySize << "\n"; 26 }
Line number 18 checks that the number of items in the array is the same as the number of items added and sets the value of success to either True or False.
Line number 22 calls SetSuccess and passes the value of success. Based on the result of your test operation, your Test function must call SetSuccess. Call SetSuccess with True if it passed, False if it failed.
This test displays the following output on the console.
TSimpleTest - Test method called.
This tests TArray.
Test TSimpleTest ( Pass ) {}
[Contents]
[Previous]
[Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.