cuelang.org/go@v0.10.1/cue/parser/interface_test.go (about) 1 // Copyright 2018 The CUE Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package parser 16 17 import ( 18 "reflect" 19 "testing" 20 21 "cuelang.org/go/cue/ast" 22 "cuelang.org/go/internal/source" 23 ) 24 25 func Test_readSource(t *testing.T) { 26 type args struct { 27 filename string 28 src interface{} 29 } 30 tests := []struct { 31 name string 32 args args 33 want []byte 34 wantErr bool 35 }{ 36 // TODO: Add test cases. 37 } 38 for _, tt := range tests { 39 got, err := source.ReadAll(tt.args.filename, tt.args.src) 40 if (err != nil) != tt.wantErr { 41 t.Errorf("%q. readSource() error = %v, wantErr %v", tt.name, err, tt.wantErr) 42 continue 43 } 44 if !reflect.DeepEqual(got, tt.want) { 45 t.Errorf("%q. readSource() = %v, want %v", tt.name, got, tt.want) 46 } 47 } 48 } 49 50 func TestParseFile(t *testing.T) { 51 type args struct { 52 filename string 53 src interface{} 54 options []Option 55 } 56 tests := []struct { 57 name string 58 args args 59 wantF *ast.File 60 wantErr bool 61 }{ 62 // TODO: Add test cases. 63 } 64 for _, tt := range tests { 65 gotF, err := ParseFile(tt.args.filename, tt.args.src, tt.args.options...) 66 if (err != nil) != tt.wantErr { 67 t.Errorf("%q. ParseFile() error = %v, wantErr %v", tt.name, err, tt.wantErr) 68 continue 69 } 70 if !reflect.DeepEqual(gotF, tt.wantF) { 71 t.Errorf("%q. ParseFile() = %v, want %v", tt.name, gotF, tt.wantF) 72 } 73 } 74 } 75 76 func TestParseExprFrom(t *testing.T) { 77 type args struct { 78 filename string 79 src interface{} 80 mode Option 81 } 82 tests := []struct { 83 name string 84 args args 85 want ast.Expr 86 wantErr bool 87 }{ 88 // TODO: Add test cases. 89 } 90 for _, tt := range tests { 91 got, err := ParseExpr(tt.args.filename, tt.args.src, tt.args.mode) 92 if (err != nil) != tt.wantErr { 93 t.Errorf("%q. ParseExprFrom() error = %v, wantErr %v", tt.name, err, tt.wantErr) 94 continue 95 } 96 if !reflect.DeepEqual(got, tt.want) { 97 t.Errorf("%q. ParseExprFrom() = %v, want %v", tt.name, got, tt.want) 98 } 99 } 100 } 101 102 func TestParseExprString(t *testing.T) { 103 type args struct { 104 x string 105 } 106 tests := []struct { 107 name string 108 args args 109 want ast.Expr 110 wantErr bool 111 }{ 112 // TODO: Add test cases. 113 } 114 for _, tt := range tests { 115 got, err := parseExprString(tt.args.x) 116 if (err != nil) != tt.wantErr { 117 t.Errorf("%q. ParseExpr() error = %v, wantErr %v", tt.name, err, tt.wantErr) 118 continue 119 } 120 if !reflect.DeepEqual(got, tt.want) { 121 t.Errorf("%q. ParseExpr() = %v, want %v", tt.name, got, tt.want) 122 } 123 } 124 }