2.4 Test Node and Tree

(Mac version)

< 2.3 | 2.4 | 3.0 >

It is now time to test what we have done thus far.

Compiling and running strom

Click the large right-pointing triangular button in Xcode to start running the program (or choose Product > Run from the main menu). The expected output should be shown in the output pane in the Debug Area. (If you don’t see this, try choosing View > Debug Area > Show Debug Area from the main Xcode menu.)

You may wish to save your built executable file so that you can run it outside the Xcode IDE. Choose Product > Archive from the main menu, then click on Distribute… and choose “Save Built Products”, specifying any directory you choose (e.g. your Desktop). The executable file will be in the folder /usr/local/bin inside the archive directory that was saved.

You can run your newly created program in a terminal window, for example the window that appears when you start the Terminal app from your Applications > Utilities folder. You may wish to invest in the PathFinder app, which makes it easy to open a terminal window anywhere by Control-clicking any folder. While PathFinder is not free, you will probably find that it is well worth the investment (for example, after you have spent many hours trying to navigate to a particular folder using cd). You may also wish to use the free terminal app iTerm2 rather than the default Terminal app.

Output

The expected output of the program thus far is shown below:

Starting...
Constructing a Tree

Finished!
Destroying a Tree

The Starting... and Finished! lines are created by the main function, while the other strings are output in the Tree constructor and destructor. Note that there is no output from the Node constructor or destructor. That is because, so far, no Node objects have been created: we have created a Tree with no nodes, not even a root node!

< 2.3 | 2.4 | 3.0 >