Coder Social home page Coder Social logo

wojciechmazur / coregex Goto Github PK

View Code? Open in Web Editor NEW

This project forked from simy4/coregex

0.0 0.0 0.0 372 KB

A handy utility for generating strings that match given regular expression criteria.

License: Apache License 2.0

Java 60.94% Scala 39.06%

coregex's Introduction

coregex

Build Status License

Maven Central Javadocs

A handy utility for generating strings that match given regular expression criteria.

Supported generators

Usage

Jqwik

Include the following dependency into your project:

testImplementation "com.github.simy4.coregex:coregex-jqwik"

Use the provided Regex annotation to generate a string that would match the regular expression predicate:

class MyTest {
  @Property
  void myProperty(@ForAll @Regex("[a-zA-Z]{3}") String str) {
    assertThat(str).hasLength(3);
  }
}

JUnit Quickcheck

Include the following dependency into your project:

testImplementation "com.github.simy4.coregex:coregex-junit-quickcheck"

Use the provided Regex annotation to generate a string that would match the regular expression predicate:

@RunWith(JUnitQuickcheck.class)
public class MyTest {
  @Property
  public void myProperty(@Regex("[a-zA-Z]{3}") String str) {
    assertThat(str).hasLength(3);
  }
}

Kotest

Include the following dependency into your project:

testImplementation "com.github.simy4.coregex:coregex-kotest"

Use the provided CoregexArbirary class to generate a string that would match the regular expression predicate:

class MyTest : DescribeSpec({
  describe("my property") {
    it("should hold") {
      checkAll(CoregexArbitrary.of("[a-zA-Z]{3}")) { str ->
        str.length shouldBe 3
      }
    }
  }
})

scalacheck

Include the following dependency into your project:

libraryDependencies ++= Seq("com.github.simy4.coregex" %% "coregex-scalacheck" % Test)

Use the provided CoregexInstances trait to constrain string arbitraries:

object MySpecification extends Properties("MySpecification") with CoregexInstances {
  property("my property") = forAll { (str: String Matching "[a-zA-Z]{3}") =>
    3 == str.length  
  }
}

vavr test

Include the following dependency into your project:

testImplementation "com.github.simy4.coregex:coregex-vavr-test"

Use the provided CoregexArbirary class to generate a string that would match the regular expression predicate:

class MyTest {
  @Test
  void myProperty() {
    Property.def("my property")
        .forAll(CoregexArbitrary.of("[a-zA-Z]{3}"))
        .suchThat(str -> 3 == str.length())
        .check();
  }
}

coregex's People

Contributors

simy4 avatar github-actions[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.