⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 utf.test

📁 tcl是工具命令语言
💻 TEST
字号:
# This file contains a collection of tests for tclUtf.c# Sourcing this file into Tcl runs the tests and generates output for# errors.  No output means no errors were found.## Copyright (c) 1997 Sun Microsystems, Inc.# Copyright (c) 1998-1999 by Scriptics Corporation.## See the file "license.terms" for information on usage and redistribution# of this file, and for a DISCLAIMER OF ALL WARRANTIES.## RCS: @(#) $Id: utf.test,v 1.8 2001/05/28 04:31:14 hobbs Exp $if {[lsearch [namespace children] ::tcltest] == -1} {    package require tcltest    namespace import -force ::tcltest::*}catch {unset x}test utf-1.1 {Tcl_UniCharToUtf: 1 byte sequences} {    set x \x01} [bytestring "\x01"]test utf-1.2 {Tcl_UniCharToUtf: 2 byte sequences} {    set x "\x00"} [bytestring "\xc0\x80"]test utf-1.3 {Tcl_UniCharToUtf: 2 byte sequences} {    set x "\xe0"} [bytestring "\xc3\xa0"]test utf-1.4 {Tcl_UniCharToUtf: 3 byte sequences} {    set x "\u4e4e"} [bytestring "\xe4\xb9\x8e"]test utf-2.1 {Tcl_UtfToUniChar: low ascii} {    string length "abc"} {3}test utf-2.2 {Tcl_UtfToUniChar: naked trail bytes} {    string length [bytestring "\x82\x83\x84"]} {3}test utf-2.3 {Tcl_UtfToUniChar: lead (2-byte) followed by non-trail} {    string length [bytestring "\xC2"]} {1}test utf-2.4 {Tcl_UtfToUniChar: lead (2-byte) followed by trail} {    string length [bytestring "\xC2\xa2"]} {1}test utf-2.5 {Tcl_UtfToUniChar: lead (3-byte) followed by non-trail} {    string length [bytestring "\xE2"]} {1}test utf-2.6 {Tcl_UtfToUniChar: lead (3-byte) followed by 1 trail} {    string length [bytestring "\xE2\xA2"]} {2}test utf-2.7 {Tcl_UtfToUniChar: lead (3-byte) followed by 2 trail} {    string length [bytestring "\xE4\xb9\x8e"]} {1}test utf-2.8 {Tcl_UtfToUniChar: longer UTF sequences not supported} {    string length [bytestring "\xF4\xA2\xA2\xA2"]} {4}test utf-3.1 {Tcl_UtfCharComplete} {} {}test utf-4.1 {Tcl_NumUtfChars: zero length} {    string length ""} {0}test utf-4.2 {Tcl_NumUtfChars: length 1} {    string length [bytestring "\xC2\xA2"]} {1}test utf-4.3 {Tcl_NumUtfChars: long string} {    string length [bytestring "abc\xC2\xA2\xe4\xb9\x8e\uA2\u4e4e"]} {7}test utf-5.1 {Tcl_UtfFindFirsts} {} {}test utf-6.1 {Tcl_UtfNext} {} {}test utf-7.1 {Tcl_UtfPrev} {} {}test utf-8.1 {Tcl_UniCharAtIndex: index = 0} {    string index abcd 0} {a}test utf-8.2 {Tcl_UniCharAtIndex: index = 0} {    string index \u4e4e\u25a 0} "\u4e4e"test utf-8.3 {Tcl_UniCharAtIndex: index > 0} {    string index abcd 2} {c}test utf-8.4 {Tcl_UniCharAtIndex: index > 0} {    string index \u4e4e\u25a\xff\u543 2} "\uff"test utf-9.1 {Tcl_UtfAtIndex: index = 0} {    string range abcd 0 2} {abc}test utf-9.2 {Tcl_UtfAtIndex: index > 0} {    string range \u4e4e\u25a\xff\u543klmnop 1 5} "\u25a\xff\u543kl"test utf-10.1 {Tcl_UtfBackslash: dst == NULL} {    set x \n} {}test utf-10.2 {Tcl_UtfBackslash: \u subst} {    set x \ua2} [bytestring "\xc2\xa2"]test utf-10.3 {Tcl_UtfBackslash: longer \u subst} {    set x \u4e21} [bytestring "\xe4\xb8\xa1"]test utf-10.4 {Tcl_UtfBackslash: stops at first non-hex} {    set x \u4e2k} "[bytestring \xd3\xa2]k"test utf-10.5 {Tcl_UtfBackslash: stops after 4 hex chars} {    set x \u4e216} "[bytestring \xe4\xb8\xa1]6"proc bsCheck {char num} {    global errNum    test utf-10.$errNum {backslash substitution} {	scan $char %c value	set value    } $num    incr errNum}set errNum 6bsCheck \b	8bsCheck \e	101bsCheck \f	12bsCheck \n	10bsCheck \r	13bsCheck \t	9bsCheck \v	11bsCheck \{	123bsCheck \}	125bsCheck \[	91bsCheck \]	93bsCheck \$	36bsCheck \ 	32bsCheck \;	59bsCheck \\	92bsCheck \Ca	67bsCheck \Ma	77bsCheck \CMa	67# prior to 8.3, this returned 8, as \8 as accepted as an# octal value - but it isn't! [Bug: 3975]bsCheck \8a	56bsCheck \14	12bsCheck \141	97bsCheck b\0	98bsCheck \x	120bsCheck \xa	10bsCheck \xA	10bsCheck \x41	65bsCheck \x541	65bsCheck \u	117bsCheck \uk	117bsCheck \u41	65bsCheck \ua	10bsCheck \uA	10bsCheck \340	224bsCheck \ua1	161bsCheck \u4e21	20001test utf-11.1 {Tcl_UtfToUpper} {    string toupper {}} {}test utf-11.2 {Tcl_UtfToUpper} {    string toupper abc} ABCtest utf-11.3 {Tcl_UtfToUpper} {    string toupper \u00e3ab} \u00c3ABtest utf-11.4 {Tcl_UtfToUpper} {    string toupper \u01e3ab} \u01e2ABtest utf-12.1 {Tcl_UtfToLower} {    string tolower {}} {}test utf-12.2 {Tcl_UtfToLower} {    string tolower ABC} abctest utf-12.3 {Tcl_UtfToLower} {    string tolower \u00c3AB} \u00e3abtest utf-12.4 {Tcl_UtfToLower} {    string tolower \u01e2AB} \u01e3abtest utf-13.1 {Tcl_UtfToTitle} {    string totitle {}} {}test utf-13.2 {Tcl_UtfToTitle} {    string totitle abc} Abctest utf-13.3 {Tcl_UtfToTitle} {    string totitle \u00e3ab} \u00c3abtest utf-13.4 {Tcl_UtfToTitle} {    string totitle \u01f3ab} \u01f2abtest utf-14.1 {Tcl_UtfNcasecmp} {    string compare -nocase a b} -1test utf-14.2 {Tcl_UtfNcasecmp} {    string compare -nocase b a} 1test utf-14.3 {Tcl_UtfNcasecmp} {    string compare -nocase B a} 1test utf-14.4 {Tcl_UtfNcasecmp} {    string compare -nocase aBcB abca} 1test utf-15.1 {Tcl_UniCharToUpper, negative delta} {    string toupper aA} AAtest utf-15.2 {Tcl_UniCharToUpper, positive delta} {    string toupper \u0178\u00ff} \u0178\u0178test utf-15.3 {Tcl_UniCharToUpper, no delta} {    string toupper !} !test utf-16.1 {Tcl_UniCharToLower, negative delta} {    string tolower aA} aatest utf-16.2 {Tcl_UniCharToLower, positive delta} {    string tolower \u0178\u00ff} \u00ff\u00fftest utf-17.1 {Tcl_UniCharToLower, no delta} {    string tolower !} !test utf-18.1 {Tcl_UniCharToTitle, add one for title} {    string totitle \u01c4} \u01c5test utf-18.2 {Tcl_UniCharToTitle, subtract one for title} {    string totitle \u01c6} \u01c5test utf-18.3 {Tcl_UniCharToTitle, subtract delta for title (positive)} {    string totitle \u017f} \u0053test utf-18.4 {Tcl_UniCharToTitle, subtract delta for title (negative)} {    string totitle \u00ff} \u0178test utf-18.5 {Tcl_UniCharToTitle, no delta} {    string totitle !} !test utf-19.1 {TclUniCharLen} {    list [regexp \\d abc456def foo] $foo} {1 4}test utf-20.1 {TclUniCharNcmp} {} {}test utf-21.1 {TclUniCharIsAlnum} {    # this returns 1 with Unicode 3 compliance    string is alnum \u1040\u021f} {1}test utf-21.2 {unicode alnum char in regc_locale.c} {    # this returns 1 with Unicode 3 compliance    list [regexp {^[[:alnum:]]+$} \u1040\u021f] [regexp {^\w+$} \u1040\u021f]} {1 1}test utf-22.1 {TclUniCharIsWordChar} {    string wordend "xyz123_bar fg" 0} 10test utf-22.2 {TclUniCharIsWordChar} {    string wordend "x\u5080z123_bar\u203c fg" 0} 10test utf-23.1 {TclUniCharIsAlpha} {    # this returns 1 with Unicode 3 compliance    string is alpha \u021f} {1}test utf-23.2 {unicode alpha char in regc_locale.c} {    # this returns 1 with Unicode 3 compliance    regexp {^[[:alpha:]]+$} \u021f} {1}test utf-24.1 {TclUniCharIsDigit} {    # this returns 1 with Unicode 3 compliance    string is digit \u1040} {1}test utf-24.2 {unicode digit char in regc_locale.c} {    # this returns 1 with Unicode 3 compliance    list [regexp {^[[:digit:]]+$} \u1040] [regexp {^\d+$} \u1040]} {1 1}test utf-24.1 {TclUniCharIsSpace} {    # this returns 1 with Unicode 3 compliance    string is space \u1680} {1}test utf-24.2 {unicode space char in regc_locale.c} {    # this returns 1 with Unicode 3 compliance    list [regexp {^[[:space:]]+$} \u1680] [regexp {^\s+$} \u1680]} {1 1}# cleanup::tcltest::cleanupTestsreturn

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -