Skip to content

Commit

Permalink
hypua_p2jd_ucs2_test()
Browse files Browse the repository at this point in the history
  • Loading branch information
mete0r committed Mar 6, 2019
1 parent bff6216 commit 74528b6
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
3 changes: 2 additions & 1 deletion hypua2jamo_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@
int hypua_p2jc_ucs2_encode(const unsigned short *src, int srclen, unsigned short *dst);
int hypua_p2jd_ucs4_calcsize(const unsigned int *src, int srclen);
int hypua_p2jd_ucs4_encode(const unsigned int *src, int srclen, unsigned int *dst);
int hypua_p2jd_ucs2_calcsize(const unsigned int *src, int srclen);
int hypua_p2jd_ucs2_calcsize(const unsigned short *src, int srclen);
int hypua_p2jd_ucs2_encode(const unsigned short *src, int srclen, unsigned short *dst);
void hypua_p2jd_ucs2_test();
int hypua_jc2p_ucs4_calcsize(const unsigned int *src, int srclen);
int hypua_jc2p_ucs4_decode(const unsigned int *src, int srclen, unsigned int *dst);
Expand Down
1 change: 0 additions & 1 deletion src/hypua2jamo-c/p2jc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ extern "C" int hypua_p2jc_ucs2_calcsize(const uint16_t *src, int srclen) {


extern "C" int hypua_p2jc_ucs2_encode(const uint16_t *src, int srclen, uint16_t *dst) {
printf("hypua_p2jc_ucs2_encode\n");
return encode(src, srclen, dst);
}

Expand Down
13 changes: 12 additions & 1 deletion src/hypua2jamo-c/p2jd.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "config.h"
Expand All @@ -21,7 +22,6 @@ extern "C" int hypua_p2jd_ucs2_calcsize(const uint16_t *src, int srclen) {


extern "C" int hypua_p2jd_ucs2_encode(const uint16_t *src, int srclen, uint16_t *dst) {
printf("hypua_p2jd_ucs2_encode\n");
return encode(src, srclen, dst);
}

Expand All @@ -34,3 +34,14 @@ extern "C" int hypua_p2jd_ucs4_calcsize(const uint32_t *src, int srclen) {
extern "C" int hypua_p2jd_ucs4_encode(const uint32_t *src, int srclen, uint32_t *dst) {
return encode(src, srclen, dst);
}


extern "C" void hypua_p2jd_ucs2_test() {
uint16_t src = 0xF7CA;
int size = hypua_p2jd_ucs2_calcsize(&src, 1);
void *buf = malloc(size);
int n_encoded = hypua_p2jd_ucs2_encode(&src, 1, (uint16_t*)buf);
printf("hypua_p2jd_ucs2_test: size=%d encoded=%d\n", size, n_encoded);
printf("p2jd_F7CA: len=%d\n", p2jd_F7CA[0]);
free(buf);
}
4 changes: 4 additions & 0 deletions tests/test_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,10 @@ def test_f7ca(self):
jamo = encoder.encode(u'\uf7ca', final=True)
self.assertEqual(u'\u1109\u1109', jamo)

def test_hypua_p2jd_ucs2(self):
from hypua2jamo._cffi import lib
lib.hypua_p2jd_ucs2_test()


class ComposedJamoEncoderImplementationOnCythonTest(
TestCase,
Expand Down

0 comments on commit 74528b6

Please sign in to comment.