All Downloads are FREE. Search and download functionalities are using the official Maven repository.

lucuma.core.data.ArbEmailAddress.scala Maven / Gradle / Ivy

// Copyright (c) 2016-2023 Association of Universities for Research in Astronomy, Inc. (AURA)
// For license information see LICENSE or https://opensource.org/licenses/BSD-3-Clause

package lucuma.core.data.arb

import lucuma.core.data.EmailAddress
import org.scalacheck.Arbitrary
import org.scalacheck.Cogen
import org.scalacheck.Gen

trait ArbEmailAddress {

  val samples = List(
    "[email protected]",
    "[email protected]",
    "[email protected]",
    "[email protected]",
    "[email protected]",
    "email@[123.123.123.123]",
    """"email"@example.com""",
    "[email protected]",
    "[email protected]",
    "[email protected]",
    "[email protected]",
    "[email protected]",
    "[email protected]",
    "[email protected]",
    """much.”more\ unusual”@example.com""",
    """very.unusual.”@”[email protected]""",
    """very.”(),:;<>[]”.VERY.”very@\\ "very”[email protected]"""
  )

  given Arbitrary[EmailAddress] =
    Arbitrary {
        Gen.oneOf(samples).map(EmailAddress.unsafeFrom)
    }

  given Cogen[EmailAddress] =
    Cogen[String].contramap(_.value.toString)

}

object ArbEmailAddress extends ArbEmailAddress




© 2015 - 2025 Weber Informatics LLC | Privacy Policy