-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
87d6505
commit dd1b4c5
Showing
4 changed files
with
172 additions
and
17 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
79 changes: 79 additions & 0 deletions
79
tests/FPinFSharp.Exercises.UnitTests/Chapter_02/Section_02_12_Tests.fs
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,79 @@ | ||
namespace FPinFSharp.Exercises.UnitTests.Chapter_02 | ||
|
||
open System | ||
open FPinFSharp.Exercises.Chapter_02.Section_02_12 | ||
open Shouldly | ||
open Xunit | ||
|
||
module Section_02_12_Tests = | ||
|
||
[<Theory>] | ||
[<InlineData(Char.MinValue, Char.MinValue)>] | ||
[<InlineData(Char.MaxValue, Char.MaxValue)>] | ||
[<InlineData(65, 'A')>] | ||
let ``GIVEN int WHEN convertIntToChar THEN result as expected`` (x:int) (expectedResult:char) = | ||
let actualResult = convertIntToChar x | ||
actualResult.ShouldBe(expectedResult) | ||
|
||
[<Theory>] | ||
[<InlineData(Int32.MinValue)>] | ||
[<InlineData(-1)>] | ||
let ``GIVEN invalid int WHEN convertIntToChar THEN OverflowException thrown`` (x:int) = | ||
let action = fun () -> convertIntToChar x |> ignore | ||
action |> ShouldThrowExtensions.ShouldThrow<OverflowException> | ||
|
||
[<Theory>] | ||
[<InlineData(true, Byte.MinValue, Byte.MaxValue)>] | ||
[<InlineData(false, Byte.MinValue, Byte.MaxValue)>] | ||
let ``GIVEN isHex WHEN getMinMaxByte THEN result as expected`` (isHex:bool) (expectedResult: byte * byte) = | ||
let actualResult = getMinMaxByte isHex | ||
actualResult.ShouldBe(expectedResult) | ||
|
||
[<Theory>] | ||
[<InlineData(true, "0x00", "0xFF")>] | ||
[<InlineData(false, "0", "255")>] | ||
let ``GIVEN isHex WHEN getMinMaxByteInString THEN result as expected`` (isHex:bool) (expectedResult: string * string) = | ||
let actualResult = getMinMaxByteInString isHex | ||
actualResult.ShouldBe(expectedResult); | ||
|
||
[<Theory>] | ||
[<InlineData(true, SByte.MinValue, SByte.MaxValue)>] | ||
[<InlineData(false, SByte.MinValue, SByte.MaxValue)>] | ||
let ``GIVEN isHex WHEN getMinMaxSByte THEN result as expected`` (isHex:bool) (expectedResult: sbyte * sbyte) = | ||
let actualResult = getMinMaxSByte isHex | ||
actualResult.ShouldBe(expectedResult) | ||
|
||
[<Theory>] | ||
[<InlineData(true, "0x80", "0x7F")>] | ||
[<InlineData(false, "-128", "127")>] | ||
let ``GIVEN isHex WHEN getMinMaxSByteInString THEN result as expected`` (isHex:bool) (expectedResult: string * string) = | ||
let actualResult = getMinMaxSByteInString isHex | ||
actualResult.ShouldBe(expectedResult) | ||
|
||
[<Theory>] | ||
[<InlineData(true, Int16.MinValue, Int16.MaxValue)>] | ||
[<InlineData(false, Int16.MinValue, Int16.MaxValue)>] | ||
let ``GIVEN isHex WHEN getMinMaxInt16 THEN result as expected`` (isHex:bool) (expectedResult: int16 * int16) = | ||
let actualResult = getMinMaxInt16 isHex | ||
actualResult.ShouldBe(expectedResult) | ||
|
||
[<Theory>] | ||
[<InlineData(true, "0x8000", "0x7FFF")>] | ||
[<InlineData(false, "-32768", "32767")>] | ||
let ``GIVEN isHex WHEN getMinMaxInt16InString THEN result as expected`` (isHex:bool) (expectedResult: string * string) = | ||
let actualResult = getMinMaxInt16InString isHex | ||
actualResult.ShouldBe(expectedResult) | ||
|
||
[<Theory>] | ||
[<InlineData(true, UInt16.MinValue, UInt16.MaxValue)>] | ||
[<InlineData(false, UInt16.MinValue, UInt16.MaxValue)>] | ||
let ``GIVEN isHex WHEN getMinMaxUInt16 THEN result as expected`` (isHex:bool) (expectedResult: uint16 * uint16) = | ||
let actualResult = getMinMaxUInt16 isHex | ||
expectedResult.ShouldBe(expectedResult) | ||
|
||
[<Theory>] | ||
[<InlineData(true, "0x00", "0xFFFF")>] | ||
[<InlineData(false, "0", "65535")>] | ||
let ``GIVEN isHex WHEN getMinMaxUInt16InString THEN result as expected`` (isHex:bool) (expectedResult: string * string) = | ||
let actualResult = getMinMaxUInt16InString isHex | ||
actualResult.ShouldBe(expectedResult) | ||
Check warning on line 79 in tests/FPinFSharp.Exercises.UnitTests/Chapter_02/Section_02_12_Tests.fs GitHub Actions / build
|
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