github.com/Konstantin8105/c4go@v0.0.0-20240505174241-768bb1c65a51/ast/string_literal_test.go (about) 1 package ast 2 3 import ( 4 "testing" 5 ) 6 7 func TestStringLiteral(t *testing.T) { 8 nodes := map[string]Node{ 9 `0x7fe16f0b4d58 <col:11> 'char [45]' lvalue "Number of command line arguments passed: %d\n"`: &StringLiteral{ 10 Addr: 0x7fe16f0b4d58, 11 Pos: NewPositionFromString("col:11"), 12 Type: "char [45]", 13 IsLvalue: true, 14 Value: "Number of command line arguments passed: %d\n", 15 ChildNodes: []Node{}, 16 }, 17 `0x7fe16f0b4d58 <col:11> 'char [45]' lvalue "\\"`: &StringLiteral{ 18 Addr: 0x7fe16f0b4d58, 19 Pos: NewPositionFromString("col:11"), 20 Type: "char [45]", 21 IsLvalue: true, 22 Value: "\\", 23 ChildNodes: []Node{}, 24 }, 25 `0x22ac548 <col:14> 'char [14]' lvalue "x\vx\000xxx\axx\tx\n"`: &StringLiteral{ 26 Addr: 0x22ac548, 27 Pos: NewPositionFromString("col:14"), 28 Type: "char [14]", 29 IsLvalue: true, 30 Runes: false, 31 Value: "x\vx\x00xxx\axx\tx\n", 32 ChildNodes: []Node{}, 33 }, 34 `0x3ed1658 <col:16> 'int [16]' lvalue L"copy successful"`: &StringLiteral{ 35 Addr: 0x3ed1658, 36 Pos: NewPositionFromString("col:16"), 37 Type: "int [16]", 38 IsLvalue: true, 39 Runes: true, 40 Value: "copy successful", 41 ChildNodes: []Node{}, 42 }, 43 `0x2759028 <col:19> 'STRING':'char [100]' lvalue "C"`: &StringLiteral{ 44 Addr: 0x2759028, 45 Pos: NewPositionFromString("col:19"), 46 Type: "STRING", 47 Type2: "char [100]", 48 IsLvalue: true, 49 Runes: false, 50 Value: "C", 51 ChildNodes: []Node{}, 52 }, 53 } 54 55 runNodeTests(t, nodes) 56 }