#include <stdio.h>
#include <stdlib.h>

#include <libxml/parserInternals.h>
#include <libxml/xmlstring.h>

void check (const char*, int);

void
check (const char* xmllang, int expected)
{
    int ret = xmlCheckLanguageID(xmlCharStrdup(xmllang));
    fprintf (stderr, "xmlCheckLanguageID on: %s", xmllang);
    if (ret != expected)
        fprintf (stderr, ": check failed: expected %d, got %d\n", expected, ret);
    else 
        fprintf (stderr, ": check passed\n");
}

int
main (int argc, char **argv)
{
    check ("e", 1);
    check ("en", 1);
    check ("en-US", 1);
    check ("en_US", 0);
    check ("longchar-valid", 1);
    check ("evenlonger-invalid", 0);
    check ("en-1-mark-2", 1);
    check ("en-", 0);
    check ("en-longchar", 1);
    check ("en-longchars", 0);
    check ("en-longchar-", 0);
    check ("en-longchars-", 0);

    return (0);
}
