github.com/Konstantin8105/c4go@v0.0.0-20240505174241-768bb1c65a51/ast/util_test.go (about) 1 package ast 2 3 import ( 4 "fmt" 5 "testing" 6 ) 7 8 func TestRemoveQuotes(t *testing.T) { 9 tcs := []struct { 10 in string 11 out string 12 }{ 13 {" ", ""}, 14 {" \"\" ", ""}, 15 {"''", ""}, 16 17 {" \"string\" ", "string"}, 18 {"'string'", "string"}, 19 } 20 for index, tc := range tcs { 21 t.Run(fmt.Sprintf("%v", index), func(t *testing.T) { 22 a := removeQuotes(tc.in) 23 if a != tc.out { 24 t.Errorf("Not acceptable : `%v` `%v`", a, tc.out) 25 } 26 }) 27 } 28 } 29 30 func TestAtof(t *testing.T) { 31 defer func() { 32 if r := recover(); r == nil { 33 t.Errorf("Not acceptable result") 34 } 35 }() 36 _ = atof("Some not float64") 37 } 38 39 func TestUnquote(t *testing.T) { 40 defer func() { 41 if r := recover(); r != nil { 42 t.Errorf("Not acceptable result") 43 } 44 }() 45 _ = unquote("\"") 46 } 47 48 func TestTypesTree(t *testing.T) { 49 _ = typesTree(nil, 0) 50 }