-
-
Notifications
You must be signed in to change notification settings - Fork 297
Expand file tree
/
Copy pathairline_test.go
More file actions
204 lines (158 loc) · 3.84 KB
/
Copy pathairline_test.go
File metadata and controls
204 lines (158 loc) · 3.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
package gofakeit
import (
"fmt"
"strings"
"testing"
)
func ExampleAirlineAircraftType() {
Seed(11)
fmt.Println(AirlineAircraftType())
// Output: regional
}
func ExampleFaker_AirlineAircraftType() {
f := New(11)
fmt.Println(f.AirlineAircraftType())
// Output: regional
}
func BenchmarkAirlineAircraftType(b *testing.B) {
for i := 0; i < b.N; i++ {
AirlineAircraftType()
}
}
func ExampleAirlineAirplane() {
Seed(11)
fmt.Println(AirlineAirplane())
// Output: De Havilland Dash 8
}
func ExampleFaker_AirlineAirplane() {
f := New(11)
fmt.Println(f.AirlineAirplane())
// Output: De Havilland Dash 8
}
func BenchmarkAirlineAirplane(b *testing.B) {
for i := 0; i < b.N; i++ {
AirlineAirplane()
}
}
func ExampleAirlineAirport() {
Seed(11)
fmt.Println(AirlineAirport())
// Output: Cairo International Airport
}
func ExampleFaker_AirlineAirport() {
f := New(11)
fmt.Println(f.AirlineAirport())
// Output: Cairo International Airport
}
func BenchmarkAirlineAirport(b *testing.B) {
for i := 0; i < b.N; i++ {
AirlineAirport()
}
}
func ExampleAirlineAirportIATA() {
Seed(11)
fmt.Println(AirlineAirportIATA())
// Output: CAI
}
func ExampleFaker_AirlineAirportIATA() {
f := New(11)
fmt.Println(f.AirlineAirportIATA())
// Output: CAI
}
func BenchmarkAirlineAirportIATA(b *testing.B) {
for i := 0; i < b.N; i++ {
AirlineAirportIATA()
}
}
func ExampleAirlineFlightNumber() {
Seed(11)
fmt.Println(AirlineFlightNumber())
// Output: US1996
}
func ExampleFaker_AirlineFlightNumber() {
f := New(11)
fmt.Println(f.AirlineFlightNumber())
// Output: US1996
}
func BenchmarkAirlineFlightNumber(b *testing.B) {
for i := 0; i < b.N; i++ {
AirlineFlightNumber()
}
}
func TestAirlineFlightNumber(t *testing.T) {
for i := 0; i < 100; i++ {
flightNum := AirlineFlightNumber()
// Should be 3-6 characters (2 letters + 1-4 digits)
if len(flightNum) < 3 || len(flightNum) > 6 {
t.Errorf("Flight number length should be 3-6, got %d: %s", len(flightNum), flightNum)
}
// First 2 characters should be letters
if !isLetter(rune(flightNum[0])) || !isLetter(rune(flightNum[1])) {
t.Errorf("First 2 characters should be letters: %s", flightNum)
}
}
}
func ExampleAirlineRecordLocator() {
Seed(11)
fmt.Println(AirlineRecordLocator())
// Output: USKKBM
}
func ExampleFaker_AirlineRecordLocator() {
f := New(11)
fmt.Println(f.AirlineRecordLocator())
// Output: USKKBM
}
func BenchmarkAirlineRecordLocator(b *testing.B) {
for i := 0; i < b.N; i++ {
AirlineRecordLocator()
}
}
func TestAirlineRecordLocator(t *testing.T) {
for i := 0; i < 100; i++ {
locator := AirlineRecordLocator()
// Should be exactly 6 characters
if len(locator) != 6 {
t.Errorf("Record locator should be 6 characters, got %d: %s", len(locator), locator)
}
// All characters should be uppercase letters
for _, c := range locator {
if !isLetter(c) || c < 'A' || c > 'Z' {
t.Errorf("Record locator should only contain uppercase letters: %s", locator)
break
}
}
}
}
func ExampleAirlineSeat() {
Seed(11)
fmt.Println(AirlineSeat())
// Output: 54J
}
func ExampleFaker_AirlineSeat() {
f := New(11)
fmt.Println(f.AirlineSeat())
// Output: 54J
}
func BenchmarkAirlineSeat(b *testing.B) {
for i := 0; i < b.N; i++ {
AirlineSeat()
}
}
func TestAirlineSeat(t *testing.T) {
for i := 0; i < 100; i++ {
seat := AirlineSeat()
// Should be 2-3 characters (row number + letter)
if len(seat) < 2 || len(seat) > 3 {
t.Errorf("Seat should be 2-3 characters, got %d: %s", len(seat), seat)
}
// Last character should be a letter (A-K, excluding I)
lastChar := seat[len(seat)-1]
validSeats := "ABCDEFGHJK"
if !strings.ContainsRune(validSeats, rune(lastChar)) {
t.Errorf("Seat letter should be A-K (excluding I), got: %c in %s", lastChar, seat)
}
}
}
func isLetter(c rune) bool {
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
}