University of Connecticut University of UC Title Fallback Connecticut

Test Node and Tree

It is now time to test what we have done thus far. The way you run the program differs depending on the operating system you are using.

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!

Windows

In VSC, click on the Local Windows Debugger button on the toolbar. VSC should say the project is out of date and ask if you would like to rebuild it; you should of course answer yes to this. If there are errors reported, you will need to carefully compare the contents of the files we have created with the tutorial versions to find what is different. Note that you will not see the output that you expect in the output area of the IDE. This IDE pane shows only output related to building the executable, not the output of the program itself!

The problem is that the terminal window in which the program runs appears (perhaps hidden behind VSC) and then disappears when the program finishes. We can stop it from disappearing by placing a breakpoint on the last line of code executed. To set the breakpoint, get main.cpp visible in the main VSC editor window and single-click in the left margin on the line containing the final right curly bracket (i.e. the last line of the file). You should see a red filled circle appear. Now click the Local Windows Debugger button on the toolbar again. The appearance of a yellow arrow inside the red filled breakpoint circle indicates that the program has been paused on this line of code. You should now be able to locate the terminal window containing the output of the program (perhaps behind the VSC window). When you are finished, you can finish running the program by clicking on the button with a red square in the toolbar (the tooltip text that appears when you hover over this button says Stop Debugging (Shift + F5).

Making the DLLs available at run time

If you chose option 2 when setting up Boost and BeagleLib, then you were told to wait until the Debug directory was created before copying the DLL files. You should now be able to do that because running your program for the first time should have created the Debug directory inside your strom solution directory. The relevant pages are Setting up the Boost C++ library and Setting up BeagleLib. Revisit these two pages and follow the instructions for option 2 in the section entitled "Making the DLLs available at run time" inside the Windows instructions.

To run the program outside of the VSC, follow these steps:

  • In Windows Explorer, hold down the shift key while right-clicking the Debug folder inside PROJECT_DIR, then choose Open command window here from the popup menu that appears
  • Type strom in the console window that appears
  • You should see the expected output when the program runs

MacIntosh

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  iTerm rather than the default Terminal app.