Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added car license plate generation #109

Merged
merged 2 commits into from
Aug 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions car.go
@@ -1,11 +1,15 @@
package faker

import "strconv"

var (
carMakers = []string{"Acura", "Alfa Romeo", "Audi", "BMW", "Bentley", "Buick", "Cadillac", "Chevrolet", "Chrysler", "Dodge", "Fiat", "Ford", "GMC", "Genesis", "Honda", "Hyundai", "Infiniti", "Jaguar", "Jeep", "Kia", "Land Rover", "Lexus", "Lincoln", "Maserati", "Mazda", "Mercedes-Benz", "Mini", "Mitsubishi", "Nissan", "Polestar", "Porsche", "Ram", "Saab", "Smart", "Subaru", "Tesla", "Toyota", "Volkswagen", "Volvo"}
carModels = []string{"Q3", "Malibu", "Escalade ESV", "Corvette", "RLX", "Silverado 2500 HD Crew Cab", "3 Series", "Pacifica", "Colorado Crew Cab", "X3", "TLX", "Silverado 3500 HD Crew Cab", "7 Series", "Fusion", "Envision", "SQ5", "R8", "Traverse", "MDX", "QX80", "Encore", "Sierra 2500 HD Crew Cab", "Insight", "XT6", "XT5", "XT4", "Enclave", "Q5", "Santa Fe", "EcoSport", "Escape", "Mustang", "Sonata", "Edge", "Camaro", "Kona Electric", "Equinox", "Sierra 3500 HD Crew Cab", "Gladiator", "X7", "CT6-V", "A7", "Blazer", "F150 SuperCrew Cab", "Suburban", "Civic", "Compass", "Escalade", "Voyager", "Accord Hybrid", "Terrain", "Spark", "Sierra 1500 Crew Cab", "NEXO", "Veloster", "Silverado 1500 Crew Cab", "G70", "CT5", "Odyssey", "Elantra GT", "RDX", "Yukon XL", "Ranger SuperCab", "Expedition MAX", "Kona", "QX50", "Durango", "Yukon", "Palisade", "Ridgeline", "Cherokee", "Bolt EV", "Expedition", "Elantra", "Passport", "Charger", "Accord", "QX60", "Venue", "Pilot", "Grand Cherokee", "Tahoe", "Acadia", "Impala", "CR-V", "X5", "Q60", "Ranger SuperCrew", "Trax", "Ioniq Plug-in Hybrid", "E-PACE", "Tucson", "Explorer", "HR-V", "I-PACE", "Q50", "G80", "F-PACE", "Renegade", "Accent"}
carCategories = []string{"SUV", "Sedan", "Coupe", "Convertible", "Hatchback", "Pickup", "Van", "Minivan", "Wagon"}
carFuelTypes = []string{"Bio Gas", "Diesel", "Eletric", "Ethanol", "Hybrid", "Petrol"}
carTransmissionGears = []string{"Automatic", "CVT", "Eletronic", "Manual", "Semi-auto", "Tiptronic"}
carSeries = []string{"KР", "ВI", "ВO", "АA", "EА", "BА", "PЕ", "НA", "IB", "KА", "KK", "OМ", "АM", "TА", "HI", "ОA", "CК", "PВ", "КC", "CА", "TЕ", "XА", "XО", "XМ", "MА", "МK", "MО"}
countryRegions = []string{"АK", "АB", "АC", "AЕ", "AН", "АM", "АO", "АP", "АT", "AА", "АI", "BА", "ВB", "BС", "ВE", "BН", "ВI", "BК", "СH", "ВM", "ВO", "АX", "ВT", "ВX", "CА", "CВ", "СE"}
)

// Car is a faker struct for Car
Expand Down Expand Up @@ -37,3 +41,8 @@ func (c Car) FuelType() string {
func (c Car) TransmissionGear() string {
return c.Faker.RandomStringElement(carTransmissionGears)
}

// Plate will return a random car plate
func (c Car) Plate() string {
return c.Faker.RandomStringElement(countryRegions) + strconv.Itoa(c.Faker.RandomNumber(4)) + c.Faker.RandomStringElement(carSeries)
}
5 changes: 5 additions & 0 deletions car_test.go
Expand Up @@ -28,3 +28,8 @@ func TestCarTransmissionGear(t *testing.T) {
v := New().Car().TransmissionGear()
NotExpect(t, "", v)
}

func TestCarPlate(t *testing.T) {
v := New().Car().Plate()
NotExpect(t, "", v)
}
2 changes: 0 additions & 2 deletions faker.go
Expand Up @@ -545,9 +545,7 @@ func NewWithSeed(src rand.Source) (f Faker) {
return
}


// Blood returns a fake Blood instance for Faker
func (f Faker) Blood() Blood {
return Blood{&f}
}