Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Straub <bs@github.com>2013-10-28 22:04:58 +0400
committerBen Straub <bs@github.com>2013-10-28 22:04:58 +0400
commit42c8f8f807fe986534e0cbabbfabc32cb4eb9077 (patch)
treefa76cb66e6d49855be344026b1cbe31d03962916 /tests-clar/core/iconv.c
parenta7d28f40a2a01382b76c55ca0a0672c177adaf69 (diff)
parent5c50f22a93c78190fb7d81802199ff9defc8cf55 (diff)
Merge remote-tracking branch 'libgit2/development' into blame
Diffstat (limited to 'tests-clar/core/iconv.c')
-rw-r--r--tests-clar/core/iconv.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/tests-clar/core/iconv.c b/tests-clar/core/iconv.c
new file mode 100644
index 000000000..73bc99a23
--- /dev/null
+++ b/tests-clar/core/iconv.c
@@ -0,0 +1,60 @@
+#include "clar_libgit2.h"
+#include "path.h"
+
+static git_path_iconv_t ic;
+static char *nfc = "\xC3\x85\x73\x74\x72\xC3\xB6\x6D";
+static char *nfd = "\x41\xCC\x8A\x73\x74\x72\x6F\xCC\x88\x6D";
+
+void test_core_iconv__initialize(void)
+{
+ cl_git_pass(git_path_iconv_init_precompose(&ic));
+}
+
+void test_core_iconv__cleanup(void)
+{
+ git_path_iconv_clear(&ic);
+}
+
+void test_core_iconv__unchanged(void)
+{
+ char *data = "Ascii data", *original = data;
+ size_t datalen = strlen(data);
+
+ cl_git_pass(git_path_iconv(&ic, &data, &datalen));
+ GIT_UNUSED(datalen);
+
+ /* There are no high bits set, so this should leave data untouched */
+ cl_assert(data == original);
+}
+
+void test_core_iconv__decomposed_to_precomposed(void)
+{
+ char *data = nfd;
+ size_t datalen = strlen(nfd);
+
+ cl_git_pass(git_path_iconv(&ic, &data, &datalen));
+ GIT_UNUSED(datalen);
+
+ /* The decomposed nfd string should be transformed to the nfc form
+ * (on platforms where iconv is enabled, of course).
+ */
+#ifdef GIT_USE_ICONV
+ cl_assert_equal_s(nfc, data);
+#else
+ cl_assert_equal_s(nfd, data);
+#endif
+}
+
+void test_core_iconv__precomposed_is_unmodified(void)
+{
+ char *data = nfc;
+ size_t datalen = strlen(nfc);
+
+ cl_git_pass(git_path_iconv(&ic, &data, &datalen));
+ GIT_UNUSED(datalen);
+
+ /* data is already in precomposed form, so even though some bytes have
+ * the high-bit set, the iconv transform should result in no change.
+ */
+ cl_assert_equal_s(nfc, data);
+}