

If gcc can’t compile C++, why can g++ compile C?.Why doesn’t the gcc command compile my C++ source code?.Step 6: Compile the code using the g++ command.Step 5: Save the file and exit the editor.Step 2: Create a directory for your source files.Step 5: The installer will download and install the software.Step 2: Run the xcode-select –install command.Step 1: Start the Terminal application.Installing the GNU GCC Package with the C++ Compiler for Mac.It feels more integrated and developer-friendly (personal opinion). It highlights the individual tests that failed/passed - You can choose to run individual tests using the GUI. The ‘Test navigator’ pane in Xcode provides you an entire overview of your test plan. But the major distinguishing factor is the GUI based support that it offers. #define CATCH_CONFIG_MAIN // Add this macro #include “catch.hpp” // the file downloaded from the link mentioned above int addNumbers(int a, int b) how is this better of all? It has the best of every other alternative that we discussed, i.e., easy to set up and works like a charm.

All you have to do is download the single header version from here -> include this catch.hpp as shown in code below and voila - your unit tests run. The best thing is you can set it up within 2 seconds. Finally, I liked this framework and it works great. XCTest (Spoiler alert - this was my final pick)Ĭatch Framework I came across this framework first thing when I searched for resources but I could not gauge how trustworthy it was. I came across these four ways of Unit testing my Cpp code - 1. Towards the end of this, I will also reveal which one I used finally and why. Let us discuss the options available and how they compare against each other wrt C++ in Xcode. I was surprised by the limited resources available online and so I just thought I would compile it all here. A few days ago, when I wanted to unit test my C++ code, I went through a long struggle to set it up on my Mac in the first place. You must be wondering - so, what's there to talk 🤔.
