blob: 394a5a496b2a4dba38c4677590a17f925a51d4db [file] [log] [blame]
Marcel van Lohuizend96ad3d2018-12-10 15:30:20 +01001// 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
15package parser
16
17import (
18 "reflect"
19 "testing"
20
21 "cuelang.org/go/cue/ast"
22 "cuelang.org/go/cue/token"
23)
24
25func 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 := readSource(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
50func TestParseFile(t *testing.T) {
51 type args struct {
52 fset *token.FileSet
53 filename string
54 src interface{}
55 options []Option
56 }
57 tests := []struct {
58 name string
59 args args
60 wantF *ast.File
61 wantErr bool
62 }{
63 // TODO: Add test cases.
64 }
65 for _, tt := range tests {
66 gotF, err := ParseFile(tt.args.fset, tt.args.filename, tt.args.src, tt.args.options...)
67 if (err != nil) != tt.wantErr {
68 t.Errorf("%q. ParseFile() error = %v, wantErr %v", tt.name, err, tt.wantErr)
69 continue
70 }
71 if !reflect.DeepEqual(gotF, tt.wantF) {
72 t.Errorf("%q. ParseFile() = %v, want %v", tt.name, gotF, tt.wantF)
73 }
74 }
75}
76
77func TestParseExprFrom(t *testing.T) {
78 type args struct {
79 fset *token.FileSet
80 filename string
81 src interface{}
82 mode Option
83 }
84 tests := []struct {
85 name string
86 args args
87 want ast.Expr
88 wantErr bool
89 }{
90 // TODO: Add test cases.
91 }
92 for _, tt := range tests {
93 got, err := ParseExpr(tt.args.fset, tt.args.filename, tt.args.src, tt.args.mode)
94 if (err != nil) != tt.wantErr {
95 t.Errorf("%q. ParseExprFrom() error = %v, wantErr %v", tt.name, err, tt.wantErr)
96 continue
97 }
98 if !reflect.DeepEqual(got, tt.want) {
99 t.Errorf("%q. ParseExprFrom() = %v, want %v", tt.name, got, tt.want)
100 }
101 }
102}
103
104func TestParseExprString(t *testing.T) {
105 type args struct {
106 x string
107 }
108 tests := []struct {
109 name string
110 args args
111 want ast.Expr
112 wantErr bool
113 }{
114 // TODO: Add test cases.
115 }
116 for _, tt := range tests {
117 got, err := parseExprString(tt.args.x)
118 if (err != nil) != tt.wantErr {
119 t.Errorf("%q. ParseExpr() error = %v, wantErr %v", tt.name, err, tt.wantErr)
120 continue
121 }
122 if !reflect.DeepEqual(got, tt.want) {
123 t.Errorf("%q. ParseExpr() = %v, want %v", tt.name, got, tt.want)
124 }
125 }
126}