Source file test/char_lit.go

     1  // run
     2  
     3  // Copyright 2009 The Go Authors. All rights reserved.
     4  // Use of this source code is governed by a BSD-style
     5  // license that can be found in the LICENSE file.
     6  
     7  // Test character literal syntax.
     8  
     9  package main
    10  
    11  import "os"
    12  
    13  func main() {
    14  	var i uint64 =
    15  		' ' +
    16  		'a' +
    17  		'ä' +
    18  		'本' +
    19  		'\a' +
    20  		'\b' +
    21  		'\f' +
    22  		'\n' +
    23  		'\r' +
    24  		'\t' +
    25  		'\v' +
    26  		'\\' +
    27  		'\'' +
    28  		'\000' +
    29  		'\123' +
    30  		'\x00' +
    31  		'\xca' +
    32  		'\xFE' +
    33  		'\u0123' +
    34  		'\ubabe' +
    35  		'\U0010FFFF' +
    36  		'\U000ebabe'
    37  	if '\U000ebabe' != 0x000ebabe {
    38  		print("ebabe wrong\n")
    39  		os.Exit(1)
    40  	}
    41  	if i != 0x20e213 {
    42  		print("number is ", i, " should be ", 0x20e213, "\n")
    43  		os.Exit(1)
    44  	}
    45  }
    46  

View as plain text