Skip to content

Commit

Permalink
Merge pull request twitter#510 from twitter/jnievelt/503
Browse files Browse the repository at this point in the history
Using dropRight instead of tail for shortening BytesSpec array
  • Loading branch information
Gabriella439 committed Feb 22, 2016
2 parents 3705820 + 69b6c1e commit 849051c
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class BytesSpec extends WordSpec with Matchers with GeneratorDrivenPropertyCheck

"has a sane equals function" in {
val random = new scala.util.Random
forAll((Gen.choose(1, 4096), "wordLength")) { (wordLength: Int) =>
forAll((Gen.choose(0, 4096), "wordLength")) { (wordLength: Int) =>
// Given two different array instances that have the same content.
val word = random.nextString(wordLength)
val array1 = word.getBytes
Expand Down Expand Up @@ -63,7 +63,7 @@ class BytesSpec extends WordSpec with Matchers with GeneratorDrivenPropertyCheck

"has a sane hashCode function" in {
val random = new scala.util.Random
forAll((Gen.choose(1, 4096), "wordLength")) { (wordLength: Int) =>
forAll((Gen.choose(0, 4096), "wordLength")) { (wordLength: Int) =>
// Given two Bytes instances that are equal.
val word = random.nextString(wordLength)
val array1 = word.getBytes
Expand All @@ -90,7 +90,7 @@ class BytesSpec extends WordSpec with Matchers with GeneratorDrivenPropertyCheck

"provides an Ordering typeclass" in {
val random = new scala.util.Random
forAll((Gen.choose(1, 4096), "wordLength")) { (wordLength: Int) =>
forAll((Gen.choose(0, 4096), "wordLength")) { (wordLength: Int) =>
val word = random.nextString(wordLength)
val array1 = word.getBytes
val array2 = word.getBytes
Expand All @@ -115,8 +115,8 @@ class BytesSpec extends WordSpec with Matchers with GeneratorDrivenPropertyCheck
suffixed should be > bytes1

// 4. a Bytes instances and a "shorter" Bytes instance.
if (bytes1.array.length > 1) {
val shortened = Bytes(bytes1.array.tail)
if (bytes1.array.length > 0) {
val shortened = Bytes(bytes1.array.dropRight(1))
bytes1 should be > shortened
shortened should be < bytes1
}
Expand Down

0 comments on commit 849051c

Please sign in to comment.