66 lines
1.9 KiB
Diff
66 lines
1.9 KiB
Diff
From 8189de64a396990ba6a7edc8fb408557da840c41 Mon Sep 17 00:00:00 2001
|
|
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
|
Date: Wed, 22 Nov 2023 08:26:14 +0900
|
|
Subject: [PATCH] test: add test for draw_cylon()
|
|
|
|
(cherry picked from commit fa3ab903f39c9986e1a86b6f7abf543dc1d4b43d)
|
|
(cherry picked from commit 7a52da5c329c6627aad99acadacab6e1e4d8ae80)
|
|
(cherry picked from commit b460406940dc6892355735255d919970f72d469c)
|
|
|
|
Conflict:adapt to the current test case framework
|
|
Reference:https://github.com/systemd/systemd/commit/fa3ab903f39c9986e1a86b6f7abf543dc1d4b43d
|
|
---
|
|
src/test/test-pretty-print.c | 29 +++++++++++++++++++++++++++++
|
|
1 file changed, 29 insertions(+)
|
|
|
|
diff --git a/src/test/test-pretty-print.c b/src/test/test-pretty-print.c
|
|
index dbae34e..3a8d206 100644
|
|
--- a/src/test/test-pretty-print.c
|
|
+++ b/src/test/test-pretty-print.c
|
|
@@ -11,6 +11,34 @@
|
|
#include "strv.h"
|
|
#include "tests.h"
|
|
|
|
+#define CYLON_WIDTH 6
|
|
+
|
|
+static void test_draw_cylon_one(unsigned pos) {
|
|
+ char buf[CYLON_WIDTH + CYLON_BUFFER_EXTRA + 1];
|
|
+
|
|
+ log_debug("/* %s(%u) */", __func__, pos);
|
|
+
|
|
+ assert(pos <= CYLON_WIDTH + 1);
|
|
+
|
|
+ memset(buf, 0xff, sizeof(buf));
|
|
+ draw_cylon(buf, sizeof(buf), CYLON_WIDTH, pos);
|
|
+ assert_se(strlen(buf) < sizeof(buf));
|
|
+}
|
|
+
|
|
+static void test_draw_cylon(void) {
|
|
+ bool saved = log_get_show_color();
|
|
+
|
|
+ log_show_color(false);
|
|
+ for (unsigned i = 0; i <= CYLON_WIDTH + 1; i++)
|
|
+ test_draw_cylon_one(i);
|
|
+
|
|
+ log_show_color(true);
|
|
+ for (unsigned i = 0; i <= CYLON_WIDTH + 1; i++)
|
|
+ test_draw_cylon_one(i);
|
|
+
|
|
+ log_show_color(saved);
|
|
+}
|
|
+
|
|
static void test_terminal_urlify(void) {
|
|
_cleanup_free_ char *formatted = NULL;
|
|
|
|
@@ -36,6 +64,7 @@ int main(int argc, char *argv[]) {
|
|
|
|
test_terminal_urlify();
|
|
test_cat_files();
|
|
+ test_draw_cylon();
|
|
|
|
print_separator();
|
|
|
|
--
|
|
2.33.0
|
|
|