Skip to content

Commit

Permalink
Add more unit tests for FsCell
Browse files Browse the repository at this point in the history
  • Loading branch information
omaus committed Mar 10, 2023
1 parent 3337d57 commit ea32c22
Showing 1 changed file with 68 additions and 8 deletions.
76 changes: 68 additions & 8 deletions tests/FsSpreadsheet.Tests/FsCell.fs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,74 @@ open FsSpreadsheet
[<Tests>]
let dataTypeTests =
testList "DataType" [
testCase "InferCellValue bool = true" <| fun _ ->
testList "InferCellValue bool = true" [
let boolValTrue = true
let resultDt, resultStr = DataType.InferCellValue boolValTrue
Expect.isTrue (resultDt = DataType.Boolean) "is not expected bool"
Expect.isTrue (resultStr = "True") "resulting string is not correct"
testCase "InferCellValue bool = false" <| fun _ ->
let resultDtTrue, resultStrTrue = DataType.InferCellValue boolValTrue
testCase "Correct DataType" <| fun _ ->
Expect.isTrue (resultDtTrue = DataType.Boolean) "is not the expected DataType.Boolean"
testCase "Correct string" <| fun _ ->
Expect.isTrue (resultStrTrue = "True") "resulting string is not correct"
]
testList "InferCellValue bool = false" [
let boolValFalse = false
let resultDt, resultStr = DataType.InferCellValue boolValFalse
Expect.isTrue (resultDt = DataType.Boolean) "is not expected bool"
Expect.isTrue (resultStr = "False") "resulting string is not correct"
let resultDtFalse, resultStrFalse = DataType.InferCellValue boolValFalse
testCase "Correct DataType" <| fun _ ->
Expect.isTrue (resultDtFalse = DataType.Boolean) "is not the expected DataType.Boolean"
testCase "Correct string" <| fun _ ->
Expect.isTrue (resultStrFalse = "False") "resulting string is not correct"
]
testList "InferCellValue string = \"test\"" [
let stringValTest = "test"
let resultDtTest, resultStrTest = DataType.InferCellValue stringValTest
testCase "Correct DataType" <| fun _ ->
Expect.isTrue (resultDtTest = DataType.String) "is not the expected DataType.String"
testCase "Correct string" <| fun _ ->
Expect.isTrue (resultStrTest = "test") "resulting string is not correct"
]
testList "InferCellValue string = \"\"" [
let stringValTest = ""
let resultDtTest, resultStrTest = DataType.InferCellValue stringValTest
testCase "Correct DataType" <| fun _ ->
Expect.isTrue (resultDtTest = DataType.String) "is not the expected DataType.String"
testCase "Correct string" <| fun _ ->
Expect.isTrue (resultStrTest = "") "resulting string is not correct"
]
testList "InferCellValue char = 1" [
let charValTest = '1'
let resultDtTest, resultChrTest = DataType.InferCellValue charValTest
testCase "Correct DataType" <| fun _ ->
Expect.isTrue (resultDtTest = DataType.String) "is not the expected DataType.String"
testCase "Correct string" <| fun _ ->
Expect.isTrue (resultChrTest = "1") "resulting string is not correct"
]
testList "InferCellValue byte = 255uy" [
let byteValTest = 255uy
let resultDtTest, resultBytTest = DataType.InferCellValue byteValTest
testCase "Correct DataType" <| fun _ ->
Expect.isTrue (resultDtTest = DataType.Number) "is not the expected DataType.Number"
testCase "Correct string" <| fun _ ->
Expect.equal "255" resultBytTest "resulting string is not correct"
]
testList "InferCellValue sbyte = -10y" [
let sbyteValTest = -10y
let resultDtTest, resultSbyTest = DataType.InferCellValue sbyteValTest
testCase "Correct DataType" <| fun _ ->
Expect.isTrue (resultDtTest = DataType.Number) "is not the expected DataType.Number"
testCase "Correct string" <| fun _ ->
Expect.equal "-10" resultSbyTest "resulting string is not correct"
]
testList "InferCellValue int = 0" [
let intValTest = 0
let resultDtTest, resultIntTest = DataType.InferCellValue intValTest
testCase "Correct DataType" <| fun _ ->
Expect.isTrue (resultDtTest = DataType.Number) "is not the expected DataType.Number"
testCase "Correct string" <| fun _ ->
Expect.equal "0" resultIntTest "resulting string is not correct"
]
]

[<Tests>]
let fsCellTest =
testList "Constructors" [

]

0 comments on commit ea32c22

Please sign in to comment.