# Copyright (C) 2002 by Red Hat, Incorporated. All rights reserved.
#
# Permission to use, copy, modify, and distribute this software
# is freely granted, provided that this notice is preserved.
#

load_lib checkoutput.exp

# Don't run this test if newlib's build does not support multibyte encodings.
set newlib_header_name "$objdir/targ-include/newlib.h"
if [file exists $newlib_header_name] {
    set newlib_header_fid [open $newlib_header_name r]
    set newlib_header_text [read $newlib_header_fid]
    close $newlib_header_fid
    if {![regexp "#define _MB_CAPABLE" $newlib_header_text] || \
            [regexp "#define _MB_LEN_MAX 1" $newlib_header_text]} {
        return
    }
}

set expected_output {
"Set C-UTF-8 locale."
"* U-00000000"
"* U-00000080"
"* U-00000800"
"* U-00010000"
"* U-00200000"
"* U-04000000"
"* U-0000007f"
"* U-000007ff"
"* U-0000ffff"
"* U-001fffff"
"* U-03ffffff"
"* U-7fffffff"
"* U-0000d7ff"
"* U-0000e000"
"* U-0000fffd"
"* U-0010ffff"
"* U-00110000"
"* 1 Invalid"
"* 1 Invalid"
"* 2 Invalid"
"* 3 Invalid"
"* 4 Invalid"
"* 5 Invalid"
"* 6 Invalid"
"* 7 Invalid"
"* 64 Invalid"
"* 32 Invalid"
"* 16 Invalid"
"* 8 Invalid"
"* 4 Invalid"
"* 2 Invalid"
"* 1 Invalid"
"* 1 Invalid"
"* 1 Invalid"
"* 1 Invalid"
"* 1 Invalid"
"* 1 Invalid"
"* 1 Invalid"
"* 1 Invalid"
"* 1 Invalid"
"* 1 Invalid"
"* 1 Invalid"
"* 1 Invalid"
"* 1 Invalid"
"* 1 Invalid"
"* 1 Invalid"
"* 1 Invalid"
"* 1 Invalid"
"* 1 Invalid"
"* 1 Invalid"
"* 1 Invalid"
"* 1 Invalid"
"* 1 Invalid"
"* 1 Invalid"
"* 1 Invalid"
"* 1 Invalid"
"* 1 Invalid"
"* 1 Invalid"
"* 1 Invalid"
"* 1 Invalid"
"* 1 Invalid"
"* 1 Invalid"
"* 1 Invalid"
"* 1 Invalid"
"* 1 Invalid"
"* 1 Invalid"
"* 1 Invalid"
"* 1 Invalid"
"* 1 Invalid"
"* 1 Invalid"
"* 1 Invalid"
"* 1 Invalid"
"* 1 Invalid"
"* 1 Invalid"
"* 1 Invalid"
}

newlib_check_output UTF-8.c $expected_output
