[systemd-devel] [PATCH 2/2] test: test for new ellipsize_mem (requires user)

Shawn Landden shawn at churchofgit.com
Fri Sep 13 07:24:39 PDT 2013


---
 Makefile.am               |  7 +++++++
 src/test/test-ellipsize.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 49 insertions(+)
 create mode 100644 src/test/test-ellipsize.c

diff --git a/Makefile.am b/Makefile.am
index 7b7539a..0e4f58c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1125,6 +1125,7 @@ tests += \
 	test-unit-file \
 	test-util \
 	test-date \
+	test-ellipsize \
 	test-sleep \
 	test-replace-var \
 	test-sched-prio \
@@ -1303,6 +1304,12 @@ test_date_SOURCES = \
 test_date_LDADD = \
 	libsystemd-core.la
 
+test_ellipsize_SOURCES = \
+        src/test/test-wellipsize.c
+
+test_ellipsize_LDADD = \
+        libsystemd-core.la
+
 test_sleep_SOURCES = \
 	src/test/test-sleep.c
 
diff --git a/src/test/test-ellipsize.c b/src/test/test-ellipsize.c
new file mode 100644
index 0000000..f6db82c
--- /dev/null
+++ b/src/test/test-ellipsize.c
@@ -0,0 +1,42 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+/***
+  This file is part of systemd.
+
+  Copyright 2013 Shawn Landden
+
+  systemd is free software; you can redistribute it and/or modify it
+  under the terms of the GNU Lesser General Public License as published by
+  the Free Software Foundation; either version 2.1 of the License, or
+  (at your option) any later version.
+
+  systemd is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public License
+  along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include <stdio.h>
+
+#include "util.h"
+#include "utf8.h"
+
+static void test_one(const char *p) {
+	_cleanup_free_ char *t = NULL;
+	t = ellipsize(p, 80, 70);
+	puts(t);
+}
+
+int main(int argc, char *argv[]) {
+        test_one("s한국어한국어한국어한국어한국어한국어한국어한국어한국어한국어한국어한국어한국어한국어한국어한국어한국어한국어");
+        test_one("日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国");
+        test_one("€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€");
+        test_one("………………………………………………………………………………………………………………………………………………………………………………………………………………………………………");
+        test_one("🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮");
+        test_one("asdfnjaskdfnklasdgnjaskdghnkasdgfklasdfjkasdfjaksdfaskldfnaskldfnaskldfnaklsdfnaklsdfnklnaskjgdknl");
+
+        return 0;
+}
-- 
1.8.4.rc3



More information about the systemd-devel mailing list