Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ library for Python. Examples in this readme are taken from [here](https://netadd
## Usage
Add the following to your build.sbt:

`libraryDependencies += "com.risksense" % "ipaddr_2.12" % "1.0.2"`
`libraryDependencies += "com.risksense" % "ipaddr_2.12" % "1.0.3"`

## Tutorial
* [IpAddress](#ipaddress)
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ lazy val root = (project in file("."))
.settings(
name := "ipaddr",
organization := "com.risksense",
version := "1.0.2",
version := "1.0.3",
scalaVersion := "2.12.6",
scalacOptions ++= Seq(
"-feature",
Expand Down
3 changes: 1 addition & 2 deletions src/main/scala/com/risksense/ipaddr/IpNetwork.scala
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,7 @@ class IpNetwork private[ipaddr](
if (prefix < 0 || prefix > this.ipAddr.width || prefix < this.mask) {
Nil
} else {
val maxSubnets = scala.math.pow(2, this.ipAddr.width - this.mask).toInt /
scala.math.pow(2, this.ipAddr.width - prefix).toInt
val maxSubnets = scala.math.pow(2, prefix - this.mask).toInt
val countNew = count match {
case 0 => maxSubnets
case _ => count
Expand Down
6 changes: 6 additions & 0 deletions src/test/scala/com/risksense/ipaddr/IpNetworkTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ class IpNetworkTest extends UnitSpec {
net1.subnet(26).size should be(4) // scalastyle:ignore
net1.subnet(26).size should be(4)
net1.subnet(33) should be(Nil)

val largeAmountOfSubnets = net6.subnet(17, 100000)

largeAmountOfSubnets.size should be (100000)
largeAmountOfSubnets.forall(s => s.mask == 17) should be(true)

}

it should "perform next operation" in {
Expand Down