Skip to content
Merged
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
4 changes: 2 additions & 2 deletions exercises/practice/all-your-base/.meta/Example.vb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ Imports System.Collections.Generic

Public Module AllYourBase
Public Function Rebase(ByVal inputBase As Integer, ByVal inputDigits As Integer(), ByVal outputBase As Integer) As Integer()
If outputBase <= 1 OrElse inputBase <= 1 Then Throw New ArgumentException()
If outputBase <= 1 OrElse inputBase <= 1 Then Throw New ArgumentOutOfRangeException()
Dim inputValue = 0
Dim exponent = 0, place = inputDigits.Length - 1

While exponent < inputDigits.Length
If inputDigits(place) < 0 OrElse inputDigits(place) >= inputBase Then Throw New ArgumentException()
If inputDigits(place) < 0 OrElse inputDigits(place) >= inputBase Then Throw New ArgumentOutOfRangeException()
inputValue += inputDigits(place) * CInt(Math.Pow(inputBase, exponent))
exponent += 1
place -= 1
Expand Down
18 changes: 9 additions & 9 deletions exercises/practice/all-your-base/AllYourBaseTests.vb
Original file line number Diff line number Diff line change
Expand Up @@ -126,70 +126,70 @@ Public Class AllYourBaseTests
Dim inputBase = 1
Dim digits = {0}
Dim outputBase = 10
Assert.Throws(Of ArgumentException)(Function() Rebase(inputBase, digits, outputBase))
Assert.Throws(Of ArgumentOutOfRangeException)(Function() Rebase(inputBase, digits, outputBase))
End Sub

<Fact(Skip:="Remove this Skip property to run this test")>
Public Sub InputBaseIsZero()
Dim inputBase = 0
Dim digits = Array.Empty(Of Integer)()
Dim outputBase = 10
Assert.Throws(Of ArgumentException)(Function() Rebase(inputBase, digits, outputBase))
Assert.Throws(Of ArgumentOutOfRangeException)(Function() Rebase(inputBase, digits, outputBase))
End Sub

<Fact(Skip:="Remove this Skip property to run this test")>
Public Sub InputBaseIsNegative()
Dim inputBase = -2
Dim digits = {1}
Dim outputBase = 10
Assert.Throws(Of ArgumentException)(Function() Rebase(inputBase, digits, outputBase))
Assert.Throws(Of ArgumentOutOfRangeException)(Function() Rebase(inputBase, digits, outputBase))
End Sub

<Fact(Skip:="Remove this Skip property to run this test")>
Public Sub NegativeDigit()
Dim inputBase = 2
Dim digits = {1, -1, 1, 0, 1, 0}
Dim outputBase = 10
Assert.Throws(Of ArgumentException)(Function() Rebase(inputBase, digits, outputBase))
Assert.Throws(Of ArgumentOutOfRangeException)(Function() Rebase(inputBase, digits, outputBase))
End Sub

<Fact(Skip:="Remove this Skip property to run this test")>
Public Sub InvalidPositiveDigit()
Dim inputBase = 2
Dim digits = {1, 2, 1, 0, 1, 0}
Dim outputBase = 10
Assert.Throws(Of ArgumentException)(Function() Rebase(inputBase, digits, outputBase))
Assert.Throws(Of ArgumentOutOfRangeException)(Function() Rebase(inputBase, digits, outputBase))
End Sub

<Fact(Skip:="Remove this Skip property to run this test")>
Public Sub OutputBaseIsOne()
Dim inputBase = 2
Dim digits = {1, 0, 1, 0, 1, 0}
Dim outputBase = 1
Assert.Throws(Of ArgumentException)(Function() Rebase(inputBase, digits, outputBase))
Assert.Throws(Of ArgumentOutOfRangeException)(Function() Rebase(inputBase, digits, outputBase))
End Sub

<Fact(Skip:="Remove this Skip property to run this test")>
Public Sub OutputBaseIsZero()
Dim inputBase = 10
Dim digits = {7}
Dim outputBase = 0
Assert.Throws(Of ArgumentException)(Function() Rebase(inputBase, digits, outputBase))
Assert.Throws(Of ArgumentOutOfRangeException)(Function() Rebase(inputBase, digits, outputBase))
End Sub

<Fact(Skip:="Remove this Skip property to run this test")>
Public Sub OutputBaseIsNegative()
Dim inputBase = 2
Dim digits = {1}
Dim outputBase = -7
Assert.Throws(Of ArgumentException)(Function() Rebase(inputBase, digits, outputBase))
Assert.Throws(Of ArgumentOutOfRangeException)(Function() Rebase(inputBase, digits, outputBase))
End Sub

<Fact(Skip:="Remove this Skip property to run this test")>
Public Sub BothBasesAreNegative()
Dim inputBase = -2
Dim digits = {1}
Dim outputBase = -7
Assert.Throws(Of ArgumentException)(Function() Rebase(inputBase, digits, outputBase))
Assert.Throws(Of ArgumentOutOfRangeException)(Function() Rebase(inputBase, digits, outputBase))
End Sub
End Class
Loading