Swiftpack.co - SirWellington/AlchemyGenerator as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by SirWellington.
SirWellington/AlchemyGenerator v1.2
Random Data Generator for Swift
⭐️ 1
🕓 3 years ago
.package(url: "https://github.com/SirWellington/AlchemyGenerator.git", from: "v1.2")

Alchemy Generator

"More Data => Better tests"

Carthage compatible Build Status

Purpose

Part of the Alchemy Series, this library makes it easier to test your code by providing generators for common Objects and Data.

Introducing randomized data to tests helps improve test quality by assuring that your code can work over a wide range of data values, and not just what you hard-code in. It also increases confidence that code will work in a variety of circumstances.

Download

To use, simply add the following Carthage dependency

Release

github "SirWellington/alchemy-generator-swift" "develop"

API

import AlchemyGenerator

Numbers

Integers

//A number in the range [-50, 50)
let anInteger: Int = AlchemyGenerator.integers(from: -50, to: 50)

Longs

//Get any positive long
let somePositiveNumber: Long = AlchemyGenerator.positiveLong()

//alternative way using computed properties
somePositiveNumber = AlchemyGenerator.Longs.positive

Doubles

//A double in the range [0.1, 1999.0]

let double = AlchemyGenerator.doubles(from: 0.1, to: 1999.0)

Strings

Randomized strings can be conveniently accessed using computed properties in the AlchemyGenerator.Strings class.

Alphabetical

Uses the Latin Alphabet, a-z | A-Z

let alphabetical: String = AlchemyGenerator.alphabeticalString(ofSize: 10)

Alphanumeric

Uses the Latin Alphabet, and numbers 0-9.

let alphanumeric = AlchemyGenerator.alphanumericString()

Numeric

Creates strings composed of the digits 0-9.

let zipCode = AlchemyGenerator.numericString(ofSize: 5)

Hexadecimal

let hex = AlchemyGenerator.hexadecimalString(ofSize: 10)

//Uses a computed property
let anotherRandomHex = AlchemyGenerator.Strings.hex

Any String

These strings may have unicode characters as well. These are great for testing against international character sets as well.

let anyString = AlchemyGenerator.Strings.anyString
let anyStringSized = AlchemyGenerator.anyString(ofSize: 13)

UUIDs

Guaranteed unique strings

//coming soon

From Fixed Set

Strings can be generated from a preselected set of String values.

let stringFromList = AlchemyGenerator.stringFrom(list: ["admit", "learn", "let in", "hear", "listen", "obey"])

Binary

Bytes

Coming soon

Collections

Coming Soon

Dates and Times

Coming Soon

Enums

Coming Soon

People

Our code very often works people, and information about them tech.sirwellington.alchemy.generator.PeopleGenerators

String name = names().get();
int age = one(adultAges());
String phoneNumber = one(phoneNumberStrings());
String email = one(emails());

POSOs

POSOs (plain old swift objects) are dumb data objects, that is they tend to contain no functionality other than getters/setters and value methods like equals(), hashCode(), and description(). Alchemy Generator provides Automatic Generation of POJOs.

Let's say you have a class like

Requirements

  • Swift 3
  • XCode 8
  • Carthage

Feature Requests

Feature Requests are definitely welcomed! Please drop a note in Issues.

Release Notes

1.0

  • Initial Public Release

License

This Software is licensed under the Apache 2.0 License

http://www.apache.org/licenses/LICENSE-2.0

GitHub

link
Stars: 1
Last commit: 3 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

v1.2
4 years ago

Updates to Swift 5

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics