From 5f60c873d2cd0f48bba1c4a467c3625680ba7a82 Mon Sep 17 00:00:00 2001 From: shoal Date: Mon, 5 Mar 2012 09:02:25 -0800 Subject: [PATCH] Updated Getting the source code (markdown) --- Tutorial.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tutorial.md b/Tutorial.md index 4a0f8e9..d945855 100644 --- a/Tutorial.md +++ b/Tutorial.md @@ -68,7 +68,7 @@ If we change the factorial function to take and return unsigned long instead (as Although this was a simple test it's been enough to demonstrate a few things about how Catch is used. Let's take moment to consider those before we move on. -1. All we did was #define one identifier and #include one header and we got everything - even an implementation of main() that will [respond to command line arguments](https://github.com/philsquared/Catch/wiki/Command-line). You can only use that #define in one implementation file, for (hopefully) obvious reasons. Once you have more than one file with unit tests in you'll just #include "catch.hpp" and go. Usually it's a good idea to have a dedicated implementation file that just #include's "catch.hpp" with CATCH_CONFIG_MAIN #defined. You can also provide your own implementation of main and drive Catch yourself (more on that later). +1. All we did was #define one identifier and #include one header and we got everything - even an implementation of main() that will [respond to command line arguments](https://github.com/philsquared/Catch/wiki/Command-line). You can only use that #define in one implementation file, for (hopefully) obvious reasons. Once you have more than one file with unit tests in you'll just #include "catch.hpp" and go. Usually it's a good idea to have a dedicated implementation file that just #include's "catch.hpp" with CATCH_CONFIG_MAIN #defined. You can also provide your own implementation of main and drive Catch yourself (see [[Supplying-your-own-main()]]). 2. We introduce test cases with the TEST_CASE macro. This macro takes two arguments - a hierarchical test name (forward slash separated, by convention) and a free-form description. The test name should be unique - and ideally will logically group related tests together like folders in a file system. You can run sets of tests by specifying a wildcarded test name. 3. The name and description arguments are just strings. We haven't had to declare a function or method - or explicitly register the test case anywhere. Behind the scenes a function with a generated name is defined for you, and automatically registered using static registry classes. By abstracting the function name away we can name our tests without the constraints of identifier names. 4. We write our individual test assertions using the REQUIRE macro. Rather than a separate macro for each type of condition we express the condition naturally using C/C++ syntax. Behind the scenes a simple set of expression templates captures the left-hand-side and right-hand-side of the expression so we can display the values in our test report. As we'll see later there _are_ other assertion macros - but because of this technique the number of them is drastically reduced.