additional UTF8 testing


git-svn-id: https://asn1c.svn.sourceforge.net/svnroot/asn1c/trunk@478 59561ff5-6e30-0410-9f3c-9617f08c8826
diff --git a/tests/50-constraint-OK.asn1.-P b/tests/50-constraint-OK.asn1.-P
index 399868b..9eba469 100644
--- a/tests/50-constraint-OK.asn1.-P
+++ b/tests/50-constraint-OK.asn1.-P
@@ -2283,6 +2283,142 @@
 };
 
 
+/*** <<< INCLUDES [Utf8-4] >>> ***/
+
+#include <UTF8String.h>
+
+/*** <<< TYPE-DECLS [Utf8-4] >>> ***/
+
+
+typedef UTF8String_t	 Utf8_4_t;
+
+/*** <<< FUNC-DECLS [Utf8-4] >>> ***/
+
+extern asn_TYPE_descriptor_t asn_DEF_Utf8_4;
+asn_struct_free_f Utf8_4_free;
+asn_struct_print_f Utf8_4_print;
+asn_constr_check_f Utf8_4_constraint;
+ber_type_decoder_f Utf8_4_decode_ber;
+der_type_encoder_f Utf8_4_encode_der;
+xer_type_encoder_f Utf8_4_encode_xer;
+
+/*** <<< CTABLES [Utf8-4] >>> ***/
+
+static int check_permitted_alphabet_12(const void *sptr) {
+	if(UTF8String_length((const UTF8String_t *)sptr) < 0)
+		return -1; /* Alphabet (sic!) test failed. */
+	
+	return 0;
+}
+
+
+/*** <<< CODE [Utf8-4] >>> ***/
+
+int
+Utf8_4_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
+			asn_app_consume_bytes_f *app_errlog, void *app_key) {
+	const UTF8String_t *st = sptr;
+	
+	if(!sptr) {
+		_ASN_ERRLOG(app_errlog, app_key,
+			"%s: value not given (%s:%d)",
+			td->name, __FILE__, __LINE__);
+		return -1;
+	}
+	
+	
+	if(!check_permitted_alphabet_12(sptr)) {
+		/* Constraint check succeeded */
+		return 0;
+	} else {
+		_ASN_ERRLOG(app_errlog, app_key,
+			"%s: constraint failed (%s:%d)",
+			td->name, __FILE__, __LINE__);
+		return -1;
+	}
+}
+
+/*
+ * This type is implemented using UTF8String,
+ * so here we adjust the DEF accordingly.
+ */
+static void
+Utf8_4_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) {
+	td->free_struct    = asn_DEF_UTF8String.free_struct;
+	td->print_struct   = asn_DEF_UTF8String.print_struct;
+	td->ber_decoder    = asn_DEF_UTF8String.ber_decoder;
+	td->der_encoder    = asn_DEF_UTF8String.der_encoder;
+	td->xer_decoder    = asn_DEF_UTF8String.xer_decoder;
+	td->xer_encoder    = asn_DEF_UTF8String.xer_encoder;
+	td->elements       = asn_DEF_UTF8String.elements;
+	td->elements_count = asn_DEF_UTF8String.elements_count;
+	td->specifics      = asn_DEF_UTF8String.specifics;
+}
+
+void
+Utf8_4_free(asn_TYPE_descriptor_t *td,
+		void *struct_ptr, int contents_only) {
+	Utf8_4_inherit_TYPE_descriptor(td);
+	td->free_struct(td, struct_ptr, contents_only);
+}
+
+int
+Utf8_4_print(asn_TYPE_descriptor_t *td, const void *struct_ptr,
+		int ilevel, asn_app_consume_bytes_f *cb, void *app_key) {
+	Utf8_4_inherit_TYPE_descriptor(td);
+	return td->print_struct(td, struct_ptr, ilevel, cb, app_key);
+}
+
+ber_dec_rval_t
+Utf8_4_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
+		void **structure, void *bufptr, size_t size, int tag_mode) {
+	Utf8_4_inherit_TYPE_descriptor(td);
+	return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode);
+}
+
+asn_enc_rval_t
+Utf8_4_encode_der(asn_TYPE_descriptor_t *td,
+		void *structure, int tag_mode, ber_tlv_tag_t tag,
+		asn_app_consume_bytes_f *cb, void *app_key) {
+	Utf8_4_inherit_TYPE_descriptor(td);
+	return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
+}
+
+asn_enc_rval_t
+Utf8_4_encode_xer(asn_TYPE_descriptor_t *td, void *structure,
+		int ilevel, enum xer_encoder_flags_e flags,
+		asn_app_consume_bytes_f *cb, void *app_key) {
+	Utf8_4_inherit_TYPE_descriptor(td);
+	return td->xer_encoder(td, structure, ilevel, flags, cb, app_key);
+}
+
+
+/*** <<< STAT-DEFS [Utf8-4] >>> ***/
+
+static ber_tlv_tag_t asn_DEF_Utf8_4_tags[] = {
+	(ASN_TAG_CLASS_UNIVERSAL | (12 << 2))
+};
+asn_TYPE_descriptor_t asn_DEF_Utf8_4 = {
+	"Utf8-4",
+	Utf8_4_free,
+	Utf8_4_print,
+	Utf8_4_constraint,
+	Utf8_4_decode_ber,
+	Utf8_4_encode_der,
+	0,				/* Not implemented yet */
+	Utf8_4_encode_xer,
+	0,	/* Use generic outmost tag fetcher */
+	asn_DEF_Utf8_4_tags,
+	sizeof(asn_DEF_Utf8_4_tags)
+		/sizeof(asn_DEF_Utf8_4_tags[0]), /* 1 */
+	asn_DEF_Utf8_4_tags,	/* Same as above */
+	sizeof(asn_DEF_Utf8_4_tags)
+		/sizeof(asn_DEF_Utf8_4_tags[0]), /* 1 */
+	0, 0,	/* No members */
+	0	/* No specifics */
+};
+
+
 /*** <<< INCLUDES [Utf8-3] >>> ***/
 
 #include <Utf8-2.h>
@@ -2304,7 +2440,7 @@
 
 /*** <<< CTABLES [Utf8-3] >>> ***/
 
-static int permitted_alphabet_table_12[128] = {
+static int permitted_alphabet_table_13[128] = {
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,	/*                  */
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,	/*                  */
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,	/*                  */
@@ -2315,8 +2451,8 @@
 1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,	/* pqrstuvwxyz      */
 };
 
-static int check_permitted_alphabet_12(const void *sptr) {
-	int *table = permitted_alphabet_table_12;
+static int check_permitted_alphabet_13(const void *sptr) {
+	int *table = permitted_alphabet_table_13;
 	/* The underlying type is UTF8String */
 	const UTF8String_t *st = sptr;
 	const uint8_t *ch = st->buf;
@@ -2355,7 +2491,7 @@
 	}
 	
 	if((size >= 1 && size <= 2)
-		 && !check_permitted_alphabet_12(sptr)) {
+		 && !check_permitted_alphabet_13(sptr)) {
 		/* Constraint check succeeded */
 		return 0;
 	} else {
@@ -2640,7 +2776,7 @@
 
 /*** <<< CTABLES [Identifier] >>> ***/
 
-static int permitted_alphabet_table_14[256] = {
+static int permitted_alphabet_table_15[256] = {
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,	/*                  */
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,	/*                  */
 0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,	/*     $            */
@@ -2651,8 +2787,8 @@
 1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,	/* pqrstuvwxyz      */
 };
 
-static int check_permitted_alphabet_14(const void *sptr) {
-	int *table = permitted_alphabet_table_14;
+static int check_permitted_alphabet_15(const void *sptr) {
+	int *table = permitted_alphabet_table_15;
 	/* The underlying type is VisibleString */
 	const VisibleString_t *st = sptr;
 	const uint8_t *ch = st->buf;
@@ -2684,7 +2820,7 @@
 	size = st->size;
 	
 	if((size >= 1 && size <= 32)
-		 && !check_permitted_alphabet_14(sptr)) {
+		 && !check_permitted_alphabet_15(sptr)) {
 		/* Constraint check succeeded */
 		return 0;
 	} else {