From e4e4e475f8f1a1d8b82ef7ad636da8536e8c6554 Mon Sep 17 00:00:00 2001 From: Haoyu Qiu Date: Wed, 15 Dec 2021 23:01:06 +0800 Subject: Make `--doctool` locale aware * Adds `indent(str)` to `String`: * Indent the (multiline) string with the given indentation. * This method is added in order to keep the translated XML correctly indented. * Moves the loading of tool/doc translation into `editor/editor_translation.{h,cpp}`. * This will be used from both `EditorSettings` and the doc tool from `main`. * Makes use of doc translation when generating XML class references, and setup the translation locale based on `-l LOCALE` CLI parameter. The XML class reference won't be translated if `-l LOCALE` parameter is not given, or when it's `-l en`. --- tests/core/string/test_string.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'tests/core/string') diff --git a/tests/core/string/test_string.h b/tests/core/string/test_string.h index eef1cac894..bb9b079e79 100644 --- a/tests/core/string/test_string.h +++ b/tests/core/string/test_string.h @@ -1132,6 +1132,25 @@ TEST_CASE("[String] c-escape/unescape") { CHECK(s.c_escape().c_unescape() == s); } +TEST_CASE("[String] indent") { + static const char *input[] = { + "", + "aaa\nbbb", + "\tcontains\n\tindent", + "empty\n\nline", + }; + static const char *expected[] = { + "", + "\taaa\n\tbbb", + "\t\tcontains\n\t\tindent", + "\tempty\n\n\tline", + }; + + for (int i = 0; i < 3; i++) { + CHECK(String(input[i]).indent("\t") == expected[i]); + } +} + TEST_CASE("[String] dedent") { String s = " aaa\n bbb"; String t = "aaa\nbbb"; -- cgit v1.2.3