Sophie

Sophie

distrib > Mageia > 7 > x86_64 > by-pkgid > 8e7905cf851649baedfb8f02c8d0b1fc > files > 2

erlang-getopt-1.0.1-1.mga7.src.rpm

From b3e4a77172d5d650329e640e3ceec25d03d8d8e6 Mon Sep 17 00:00:00 2001
From: Simon Skorokhodov <skorohodovsemen@gmail.com>
Date: Tue, 6 Mar 2018 20:54:31 +0100
Subject: [PATCH] Add tests for `utf8_binary` type

---
 test/getopt_test.erl | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/test/getopt_test.erl b/test/getopt_test.erl
index 7ec0f35..1dc9a34 100644
--- a/test/getopt_test.erl
+++ b/test/getopt_test.erl
@@ -323,3 +323,18 @@ check_test_() ->
       ?_assertEqual("option 'verbose' has invalid argument: 100",
                     format_error(OptSpecList, {error, {invalid_option_arg, {verbose, "100"}}}))}
     ].
+
+utf8_binary_test_() ->
+  OptSpecList = [{utf8, undefined, "utf8", utf8_binary, "UTF-8 arg"}],
+  Unicode = [228, 220, 223, 1455],
+  Utf8 = unicode:characters_to_binary(Unicode),
+  io:setopts(standard_error, [{encoding, utf8}]),
+  OptSpecsWithDefault = [{utf8, undefined, "utf8", {utf8_binary, Utf8}, "UTF-8 arg"}],
+  [{"Empty utf8_binary argument",
+    ?_assertEqual({ok, {[{utf8, <<>>}], []}}, parse(OptSpecList, ["--utf8", ""]))},
+   {"Non empty utf8_binary argument",
+    ?_assertEqual({ok, {[{utf8, Utf8}], []}}, parse(OptSpecList, ["--utf8", Unicode]))},
+   {"Default utf8_binary argument",
+    ?_assertEqual({ok, {[{utf8, Utf8}], []}}, parse(OptSpecsWithDefault, []))},
+   {"Default utf8_binary argument usage",
+    ?_assert(is_list(string:find(getopt:usage_options(OptSpecsWithDefault), Unicode)))}].
-- 
2.19.0