---
 tests/iconv.test     | 15 +++++++++++++++
 toys/pending/iconv.c |  2 +-
 2 files changed, 16 insertions(+), 1 deletion(-)
 create mode 100644 tests/iconv.test
From a5b5b18a36a61a1bebd487e172c52b896252d136 Mon Sep 17 00:00:00 2001
From: Elliott Hughes <e...@google.com>
Date: Tue, 22 Aug 2017 14:03:45 -0700
Subject: [PATCH] Fix iconv build and add trivial test.

---
 tests/iconv.test     | 15 +++++++++++++++
 toys/pending/iconv.c |  2 +-
 2 files changed, 16 insertions(+), 1 deletion(-)
 create mode 100644 tests/iconv.test

diff --git a/tests/iconv.test b/tests/iconv.test
new file mode 100644
index 0000000..8fe7c7a
--- /dev/null
+++ b/tests/iconv.test
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+[ -f testing.sh ] && . testing.sh
+
+# Example characters from https://en.wikipedia.org/wiki/UTF-16:
+# $:U+0024  €:U+20ac  𐐷:U+10437[==U+d801,U+dc37]
+echo -n "$€𐐷" > chars
+
+#testing "name" "command" "result" "infile" "stdin"
+
+testing "" "iconv chars | xxd -p" "24e282acf09090b7\n" "" ""
+testing "-t UTF-16BE" "iconv -t utf16be chars | xxd -p" "002420acd801dc37\n" "" ""
+testing "-t UTF-16LE" "iconv -t utf16le chars | xxd -p" "2400ac2001d837dc\n" "" ""
+testing "-t UTF-32BE" "iconv -t utf32be chars | xxd -p" "00000024000020ac00010437\n" "" ""
+testing "-t UTF-32BE" "iconv -t utf32le chars | xxd -p" "24000000ac20000037040100\n" "" ""
diff --git a/toys/pending/iconv.c b/toys/pending/iconv.c
index 77b8038..75ff639 100644
--- a/toys/pending/iconv.c
+++ b/toys/pending/iconv.c
@@ -43,7 +43,7 @@ static void do_iconv(int fd, char *name)
     len = read(fd, in, 2048-inleft);
 
     if (len < 0) {
-      perror_msg("read '%s'");
+      perror_msg("read '%s'", name);
       return;
     }
     inleft += len;
-- 
2.14.1.342.g6490525c54-goog

_______________________________________________
Toybox mailing list
Toybox@lists.landley.net
http://lists.landley.net/listinfo.cgi/toybox-landley.net

Reply via email to