[gjs: 17/18] doc: Update style guide with advice about g_assert()




commit 5ac6195999acebce26c7d92daa33fbc072f3ab7f
Author: Philip Chimento <philip chimento gmail com>
Date:   Thu Dec 3 17:10:58 2020 -0800

    doc: Update style guide with advice about g_assert()
    
    Suggested by Evan during code review.

 doc/CPP_Style_Guide.md | 5 +++++
 1 file changed, 5 insertions(+)
---
diff --git a/doc/CPP_Style_Guide.md b/doc/CPP_Style_Guide.md
index 9c2e33ad..516d15be 100644
--- a/doc/CPP_Style_Guide.md
+++ b/doc/CPP_Style_Guide.md
@@ -809,6 +809,11 @@ In cases where this is not practical, either use `g_critical()` and
 continue execution as best as possible, or use `g_error()` to abort with
 a fatal error.
 
+For this reason, don't use `g_assert()` or `g_assert_not_reached()` in unit tests!
+Otherwise the tests will crash in a release build.
+In unit tests, use `g_assert_true()`, `g_assert_false()`, `g_assert_cmpint()`, etc.
+Likewise, don't use these unit test assertions in the main code!
+
 Another issue is that values used only by assertions will produce an
 "unused value" warning when assertions are disabled.
 For example, this code will warn:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]