Giter Site home page Giter Site logo

47degrees / scalacheck-toolbox Goto Github PK

View Code? Open in Web Editor NEW
119.0 48.0 7.0 3.69 MB

A helping hand for generating sensible data with ScalaCheck

Home Page: https://47degrees.github.io/scalacheck-toolbox/

License: Apache License 2.0

Scala 100.00%
scalacheck functional-programming jdk8 joda date-time scala

scalacheck-toolbox's Introduction

codecov.io Maven Central License Latest version GitHub Issues

scalacheck-toolbox

Installation

Add the following lines to your build.sbt file:

libraryDependencies += "com.47deg" %% "scalacheck-toolbox-datetime"    % "0.7.0" % Test
libraryDependencies += "com.47deg" %% "scalacheck-toolbox-magic"       % "0.7.0" % Test
libraryDependencies += "com.47deg" %% "scalacheck-toolbox-combinators" % "0.7.0" % Test

A helping hand for generating sensible data with ScalaCheck

The ScalaCheck Toolbox is intended to be a set of libraries that can help rein in the power of ScalaCheck in a sensible way, while not impeding your tests. There are three libraries to help you:

  • datetime: Limit the test data to a certain range of times, and constrain generation to a certain level of precision.
  • magic: Enhance the provided generators with some values that are often used to signal danger, or perhaps something more sinister, such as the Strings "null", "False" or "Robert'); DROP TABLE Students;--".
  • combinators: Provide some useful combinators of generators, such as the pairing of a map and a list of values that are present in the map.

View the documentation for more tips on how to get the best from these tools.

scalacheck-toolbox in the wild not found

If you wish to add your library here please consider a PR to include it in the list below.

Copyright

scalacheck-toolbox is designed and developed by 47 Degrees

Copyright (C) 2016-2020 47 Degrees. http://47deg.com

scalacheck-toolbox's People

Contributors

47degdev avatar 47erbot avatar alejandrohdezma avatar antoniomateogomez avatar benfradet avatar cb372 avatar davesmith00047 avatar fedefernandez avatar franciscodr avatar github-actions[bot] avatar israelperezglez avatar juanpedromoreno avatar maureenelsberry avatar noelmarkham avatar raulraja avatar sbrunk avatar scala-steward avatar sloshy avatar sullivan- avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

scalacheck-toolbox's Issues

TimeZone support

I often have use cases where I need to test dates within a specific time zone. It's probably fairly simple to adapt scalacheck-datetime's Gen instances to my need - just map into it and set the desired timezone - but then I need to make sure this still falls within the expected date boundaries.

Would it be possible to, say, add a new time zone parameter to genDateTimeWithinRange? Might be implicit (probably not a great idea), might have a default value of UTC if you don't want to break backwards compatibility...

Library Logo

Create a logo for the library, prior to releaes

ThreetenBP support for dates

Currently, we have JDK 8 time and Joda Time for the Date generators. Are there any plans to support ThreetenBP?

Release for Scala3

We're using the library in tapir, would be great to enable also these tests for Scala3. Thanks!

Fixes microsite theme

After updating sbt-microsites version up to 1.1.2 the microsite configuration for sbt-microsites should include the micrositeTheme := "pattern" setting to keep the style given when the website was redesign.

Got a random test failure in Travis for Scala 2.12

Log message:

[info] ! Java 8 Generators.arbitrary generation with a granularity generates appropriate ZonedDateTimes: Falsified after 58167 passed tests.
[info] > Labels of failing property: 
[info] Hours: +45746443-09-27T04:00+13:45[NZ-CHAT]
[info] > ARG_0: (com.fortysevendeg.scalacheck.datetime.jdk8.granularity.package$$anon$3@2c86bf85,com.fortysevendeg.scalacheck.datetime.jdk8.GenJdk8Properties$$$Lambda$2144/1142872265@35fcbed8)
[info] > ARG_1: +45746443-09-27T04:00+13:45[NZ-CHAT]

"Illegal instant due to time zone offset transition"

Hi, first of all thanks for saving us the trouble to deal with random date generation.

From time to time we run into an 'Illegal instant due to time zone offset transition' exception due to generating a date which happens to "not exist".

Should be easy to reproduce like this:

import com.fortysevendeg.scalacheck.datetime.joda.ArbitraryJoda._
import org.scalacheck.Arbitrary.arbitrary
import org.joda.time.DateTime

(1 to 10000).map(_ => arbitrary[DateTime].sample)

sometimes results in e.g.

org.joda.time.IllegalInstantException: Illegal instant due to time zone offset transition (daylight savings time 'gap'): 173829578-03-26T02:52:52.521 (Europe/Berlin)
  at org.joda.time.chrono.ZonedChronology.localToUTC(ZonedChronology.java:157)
  at org.joda.time.chrono.ZonedChronology.getDateTimeMillis(ZonedChronology.java:122)
  at org.joda.time.chrono.AssembledChronology.getDateTimeMillis(AssembledChronology.java:133)
  at org.joda.time.base.BaseDateTime.<init>(BaseDateTime.java:257)
  at org.joda.time.base.BaseDateTime.<init>(BaseDateTime.java:198)
  at org.joda.time.DateTime.<init>(DateTime.java:476)
[....]

The link above has more details on the cause and some ideas on mitigating it, though I am not sure what steps would be appropriate in this case to still have completely random dates. Thanks!

Filter is failing with ZonedDateTime generator

genZonedDateTime has very big space for year which is preventing strict date formatting like yyyyMMdd.

year <- Gen.choose(-292278994, 292278994)

With above range below filter mostly fails

year <- Gen.choose(-292278994, 292278994) suchThat{r => r.getYear()>1970 && r.getYear()<3000}

I know the range is due to

TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
Timestamp t1 = new Timestamp(Long.MIN_VALUE);
assertEquals("292278994-08-17 07:12:55.192", t1.toString());

However, it is better if library can provide some way to constraint year range for rational generator

Add Cogen instances

These shouldn't be hard to implement - all we need is a conversion to some concrete representation. For example, for LocalDate we can use Cogen[Long].contramap(_.toEpochDay).

As for the motivation, cats makes extensive use of Cogens in cats-laws.

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.