From cd1b635b2ae90d9ac2d8b1779183a1fbd8c5fd5c Mon Sep 17 00:00:00 2001 From: vlad Date: Tue, 13 Jun 2017 16:12:20 -0700 Subject: Adding domain entities --- .../logging/PhiStringContextSuite.scala | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/test/scala/xyz/driver/pdsuicommon/logging/PhiStringContextSuite.scala (limited to 'src/test/scala/xyz/driver/pdsuicommon/logging') diff --git a/src/test/scala/xyz/driver/pdsuicommon/logging/PhiStringContextSuite.scala b/src/test/scala/xyz/driver/pdsuicommon/logging/PhiStringContextSuite.scala new file mode 100644 index 0000000..f623b81 --- /dev/null +++ b/src/test/scala/xyz/driver/pdsuicommon/logging/PhiStringContextSuite.scala @@ -0,0 +1,32 @@ +package xyz.driver.pdsuicommon.logging + +import org.scalatest.FreeSpecLike + +class PhiStringContextSuite extends FreeSpecLike { + + class Foo(x: Int, y: String) { + val z: Boolean = true + } + + case class Bar(y: Boolean) + + implicit def fooToPhiString(foo: Foo): PhiString = new PhiString(s"Foo(z=${foo.z})") + + "should not compile if there is no PhiString implicit" in assertDoesNotCompile( + """val bar = Bar(true) + |phi"bar is $bar"""".stripMargin + ) + + "should compile if there is a PhiString implicit" in assertCompiles( + """val foo = new Foo(1, "test") + |println(phi"foo is $foo}")""".stripMargin + ) + + "should not contain private info" in { + val foo = new Foo(42, "test") + val result = phi"foo is $foo".text + assert(!result.contains("test")) + assert(!result.contains("42")) + } + +} -- cgit v1.2.3