-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9076 from lrytz/t12048
- Loading branch information
Showing
5 changed files
with
77 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Scala (https://www.scala-lang.org) | ||
* | ||
* Copyright EPFL and Lightbend, Inc. | ||
* | ||
* Licensed under Apache License 2.0 | ||
* (http://www.apache.org/licenses/LICENSE-2.0). | ||
* | ||
* See the NOTICE file distributed with this work for | ||
* additional information regarding copyright ownership. | ||
*/ | ||
|
||
package scala.collection.immutable | ||
|
||
import org.junit.Assert._ | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.junit.runners.JUnit4 | ||
|
||
import scala.tools.testkit.AssertUtil.{getFieldAccessible => f} | ||
|
||
@RunWith(classOf[JUnit4]) | ||
class IntMapTest { | ||
@Test | ||
def `isEmpty O(1)`(): Unit = { | ||
val m = IntMap(1 -> (), 2 -> (), 3 -> ()) | ||
f[IntMap.Bin[_]]("left").set(m, null) | ||
f[IntMap.Bin[_]]("right").set(m, null) | ||
assertFalse(m.isEmpty) // no NPE, does not access left or right | ||
} | ||
} |
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,32 @@ | ||
/* | ||
* Scala (https://www.scala-lang.org) | ||
* | ||
* Copyright EPFL and Lightbend, Inc. | ||
* | ||
* Licensed under Apache License 2.0 | ||
* (http://www.apache.org/licenses/LICENSE-2.0). | ||
* | ||
* See the NOTICE file distributed with this work for | ||
* additional information regarding copyright ownership. | ||
*/ | ||
|
||
package scala.collection.immutable | ||
|
||
import org.junit.Assert._ | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.junit.runners.JUnit4 | ||
|
||
import scala.tools.testkit.AssertUtil.{getFieldAccessible => f} | ||
|
||
@RunWith(classOf[JUnit4]) | ||
class LongMapTest { | ||
|
||
@Test | ||
def `isEmpty O(1)`(): Unit = { | ||
val m = LongMap(1l -> (), 2l -> (), 3l -> ()) | ||
f[LongMap.Bin[_]]("left").set(m, null) | ||
f[LongMap.Bin[_]]("right").set(m, null) | ||
assertFalse(m.isEmpty) // no NPE, does not access left or right | ||
} | ||
} |