diff options
author | vlad <vlad@driver.xyz> | 2017-10-31 11:09:29 -0700 |
---|---|---|
committer | vlad <vlad@driver.xyz> | 2017-10-31 11:09:29 -0700 |
commit | 18c68db6e446c48c5aed0010a1d057368273685c (patch) | |
tree | e31d84c7bfbf62baabab34ef8c6d18b018ada55a /src/test/scala/xyz/driver/core/logging/PhiStringContextTest.scala | |
parent | 0cb06d70bd91e1e6a4ab9d97851ef9db7aaedfd6 (diff) | |
download | driver-core-phi-safe-logging.tar.gz driver-core-phi-safe-logging.tar.bz2 driver-core-phi-safe-logging.zip |
PHI-safe logging from PDS UIphi-safe-logging
Diffstat (limited to 'src/test/scala/xyz/driver/core/logging/PhiStringContextTest.scala')
-rw-r--r-- | src/test/scala/xyz/driver/core/logging/PhiStringContextTest.scala | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/test/scala/xyz/driver/core/logging/PhiStringContextTest.scala b/src/test/scala/xyz/driver/core/logging/PhiStringContextTest.scala new file mode 100644 index 0000000..4ffe7ae --- /dev/null +++ b/src/test/scala/xyz/driver/core/logging/PhiStringContextTest.scala @@ -0,0 +1,32 @@ +package xyz.driver.core.logging + +import org.scalatest.FreeSpecLike +import xyz.driver.core.logging.phi._ + +class PhiStringContextTest extends FreeSpecLike { + + class Foo(x: Int, y: String) { + val z: Boolean = true + } + + case class Bar(y: Boolean) + + implicit def fooToPhiString(foo: Foo): NoPhiString = new NoPhiString(s"Foo(z=${foo.z})") + + "should not compile if there is no PhiString implicit" in assertDoesNotCompile( + """val bar = Bar(true) + |noPhi"bar is $bar"""".stripMargin + ) + + "should compile if there is a PhiString implicit" in assertCompiles( + """val foo = new Foo(1, "test") + |println(noPhi"foo is $foo}")""".stripMargin + ) + + "should not contain private info" in { + val foo = new Foo(42, "test") + val result = noPhi"foo is $foo".text + assert(!result.contains("test")) + assert(!result.contains("42")) + } +} |