Skip to content

Commit

Permalink
Fixed awful BigInteger readme sample, added meaningful tests for that…
Browse files Browse the repository at this point in the history
… sample
  • Loading branch information
ionspin committed Mar 31, 2019
1 parent 6db9b8c commit 5c3841b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ Sum: Sum: 9223372039002259454

#### Subtraction
```kotlin
val a = BigInteger.fromLong(1L)
val b = BigInteger.fromInt(2L)
val a = BigInteger.fromLong(Long.MIN_VALUE)
val b = BigInteger.fromLong(Long.MAX_VALUE)

val difference = a - b
println("Difference: $difference")
----- Output -----
Difference: 3
Difference: -18446744073709551615
```

#### Multiplication
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,24 @@ class BigIntegerReadmeTest {
fun `Test_readme_addition_sample`() {
val a = BigInteger.fromLong(Long.MAX_VALUE)
val b = BigInteger.fromInt(Int.MAX_VALUE)

val sum = a + b
println("Sum: $sum")

val expectedResult = BigInteger.parseString("9223372039002259454", 10)
assertTrue { sum == expectedResult }

}

@Test
fun `Test_readme_subtraction_sample`() {
val a = BigInteger.fromLong(Long.MIN_VALUE)
val b = BigInteger.fromLong(Long.MIN_VALUE)
val b = BigInteger.fromLong(Long.MAX_VALUE)

val difference = a - b
println("Difference: $difference")

val expectedResult = BigInteger.parseString("-18446744073709551615", 10)
assertTrue { difference == expectedResult }
}

@Test
Expand Down

0 comments on commit 5c3841b

Please sign in to comment.