From 06d39dd3358617d48e9ab41a65316fd488b8d5b4 Mon Sep 17 00:00:00 2001 From: Derek Cresswell Date: Tue, 5 May 2020 22:55:03 -0700 Subject: [PATCH] Fixes wording of examples (#49) Co-authored-by: dcresswell --- examples/c-example.c | 22 ++++++++++------------ examples/cpp-example.cc | 10 ++++------ 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/examples/c-example.c b/examples/c-example.c index abf79ef..2b36758 100644 --- a/examples/c-example.c +++ b/examples/c-example.c @@ -1,8 +1,8 @@ #include "acutest.h" - -void test_tutorial(void) +void +test_tutorial(void) { void* mem; @@ -20,13 +20,13 @@ test_fail(void) { int a, b; - /* This condition is designed to fail so you can see how the failed test + /* This condition is designed to fail so you can see what the failed test * output looks like. */ a = 1; b = 2; TEST_CHECK(a + b == 5); - /* Also show TEST_CHECK_ in action */ + /* Here is TEST_CHECK_ in action. */ TEST_CHECK_(a + b == 5, "%d + %d == 5", a, b); /* We may also show more information about the failure. */ @@ -35,15 +35,13 @@ test_fail(void) TEST_MSG("b: %d", b); } - /* The macros TEST_MSG() do write down something only when the precedin - * condition fails, so we can avoid the 'if'. */ + /* The macro TEST_MSG() only outputs something when the preceding + * condition fails, so we can avoid the 'if' statement. */ TEST_CHECK(a + b == 3); TEST_MSG("a: %d", a); TEST_MSG("b: %d", b); } - - static void helper(void) { @@ -59,7 +57,8 @@ test_abort(void) { helper(); - /* This never happens because the test is aborted inside the helper(). */ + /* This test never happens because the test is aborted inside the helper() + * function. */ TEST_CHECK(1 * 2 == 2 * 1); } @@ -69,11 +68,10 @@ test_crash(void) int* invalid = ((int*)NULL) + 0xdeadbeef; *invalid = 42; - TEST_CHECK_(1 == 1, "We should never get here, due to the write into " - "the invalid address."); + TEST_CHECK_(1 == 1, "This should never execute, due to a write into " + "an invalid address."); } - TEST_LIST = { { "tutorial", test_tutorial }, { "fail", test_fail }, diff --git a/examples/cpp-example.cc b/examples/cpp-example.cc index 4e422ef..decdd0f 100644 --- a/examples/cpp-example.cc +++ b/examples/cpp-example.cc @@ -31,7 +31,7 @@ enum What { }; /* This dummy function represents some code which we want to test. - * As we are in C++, they can throw some exceptions. + * As this is written in C++, they can throw exceptions. */ static void some_function(What what, const char* msg = NULL) @@ -72,12 +72,12 @@ void test_exception_type(void) TEST_EXCEPTION(some_function(THROW_TEST_EXC), std::exception); TEST_EXCEPTION(some_function(THROW_INVALID_ARG), std::exception); - /* Uncommon types used as exceptions work too. */ + /* Fundemental types used as exceptions work too. */ TEST_EXCEPTION(some_function(THROW_CHAR_PTR), const char*); TEST_EXCEPTION(some_function(THROW_INT), int); /* These checks fail because the given code does not throw an exception - * at all, or throws something incompatible. */ + * at all, or throws a different type of exception. */ TEST_EXCEPTION(some_function(NO_THROW), std::exception); TEST_EXCEPTION(some_function(THROW_INT), std::exception); TEST_EXCEPTION(some_function(THROW_INVALID_ARG), TestException); @@ -96,9 +96,7 @@ void test_uncaught_std_exception(void) void test_uncaught_strange_exception(void) { /* If the test throws unhandled exception, Acutest aborts the test unit - * and considers it a failure. - * - * Even if it is not derived from std::exception. + * and considers it a failure even if it is not derived from std::exception. */ some_function(THROW_CHAR_PTR, "Acutest knows how to catch me :-)"); }