Skip to content

Commit

Permalink
initial test modifications
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrapyre committed May 3, 2024
1 parent 43a91df commit fc75b5f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ object DynamicValueGen {
case typ: StandardType.ZoneOffsetType.type => gen(typ, JavaTimeGen.anyZoneOffset)
case typ: StandardType.UnitType.type => Gen.const(DynamicValue.Primitive((), typ))
case typ: StandardType.UUIDType.type => gen(typ, Gen.uuid)
case typ: StandardType.CurrencyType.type => gen(typ, Gen.currency)
}
}

Expand Down
5 changes: 3 additions & 2 deletions tests/shared/src/test/scala-2/zio/schema/SchemaGen.scala
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package zio.schema

import scala.collection.immutable.ListMap

import zio.Chunk
import zio.schema.SchemaGen.SchemaTest
import zio.test.{ Gen, Sized }

object SchemaGen {
Expand Down Expand Up @@ -749,7 +749,8 @@ object SchemaGen {
),
SchemaTest("ZoneId", StandardType.ZoneIdType, JavaTimeGen.anyZoneId),
SchemaTest("ZoneOffset", StandardType.ZoneOffsetType, JavaTimeGen.anyZoneOffset),
SchemaTest("UnitType", StandardType.UnitType, Gen.unit)
SchemaTest("UnitType", StandardType.UnitType, Gen.unit),
SchemaTest("Currency", StandardType.CurrencyType, Gen.currency)
)

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ object StandardTypeGen {
(StandardType.YearType),
(StandardType.YearMonthType),
(StandardType.ZonedDateTimeType),
(StandardType.ZoneIdType)
(StandardType.ZoneIdType),
(StandardType.CurrencyType)
)
//FIXME For some reason adding this causes other unrelated tests to break.
// Gen.const(StandardType.ZoneOffset)
Expand Down Expand Up @@ -80,6 +81,7 @@ object StandardTypeGen {
case typ: StandardType.ZonedDateTimeType.type => typ -> JavaTimeGen.anyZonedDateTime
case typ: StandardType.ZoneIdType.type => typ -> JavaTimeGen.anyZoneId
case typ: StandardType.ZoneOffsetType.type => typ -> JavaTimeGen.anyZoneOffset
case typ: StandardType.CurrencyType.type => typ -> Gen.currency
case _ => StandardType.UnitType -> Gen.unit: StandardTypeAndGen[_]
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,19 @@ package zio.schema.codec

import java.time._
import java.util.UUID

import scala.collection.immutable.ListMap
import scala.util.Try

import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.module.scala.DefaultScalaModule
import org.msgpack.core.{ MessagePack, MessagePacker }
import org.msgpack.core.{MessagePack, MessagePacker}
import org.msgpack.jackson.dataformat.MessagePackFactory

import zio.schema.CaseSet.caseOf
import zio.schema.Patch.Currency
import zio.schema._
import zio.stream.{ ZSink, ZStream }
import zio.stream.{ZSink, ZStream}
import zio.test.Assertion._
import zio.test._
import zio.{ Chunk, Console, Scope, Task, ZIO }
import zio.{Chunk, Console, Scope, Task, ZIO}

object MessagePackCodecSpec extends ZIOSpecDefault {

Expand Down Expand Up @@ -221,6 +219,13 @@ object MessagePackCodecSpec extends ZIOSpecDefault {
ed2 <- encodeAndDecodeNS(Schema[UUID], value)
} yield assert(ed)(equalTo(Chunk(value))) && assert(ed2)(equalTo(value))
},
test("currencies") {
val value = java.util.Currency.getInstance(java.util.Locale.getDefault)
for {
ed <- encodeAndDecode(Schema[java.util.Currency], value)
ed2 <- encodeAndDecodeNS(Schema[java.util.Currency], value)
} yield assert(ed)(equalTo(Chunk(value))) && assert(ed2)(equalTo(value))
},
test("day of weeks") {
val value = DayOfWeek.of(3)
for {
Expand Down

0 comments on commit fc75b5f

Please sign in to comment.