forked from twitter/util
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d21b5b3
commit 4b2e427
Showing
5 changed files
with
67 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
util-thrift/src/test/scala/com/twitter/util/ThriftCodecTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.twitter.util | ||
|
||
import org.junit.runner.RunWith | ||
import org.scalatest.FunSuite | ||
import org.scalatest.junit.JUnitRunner | ||
|
||
@RunWith(classOf[JUnitRunner]) | ||
class ThriftCodecTest extends FunSuite { | ||
|
||
private def roundTrip(codec: ThriftCodec[TestThriftStructure, _]): Unit = { | ||
val struct = new TestThriftStructure("aString", 5) | ||
val encoded: Array[Byte] = codec.encode(struct) | ||
val decoded: TestThriftStructure = codec.decode(encoded) | ||
|
||
assert(decoded === struct) | ||
} | ||
|
||
test("BinaryThriftCodec") { | ||
val codec = new BinaryThriftCodec[TestThriftStructure]() | ||
roundTrip(codec) | ||
} | ||
|
||
test("CompactThriftCodec") { | ||
val codec = new CompactThriftCodec[TestThriftStructure]() | ||
roundTrip(codec) | ||
} | ||
|
||
} |