Skip to content

Commit

Permalink
Tests: Add a missing nil test case for validateString
Browse files Browse the repository at this point in the history
Not that it matters much, but I did run into a silly bug recently that had me question my sanity for a bit...

I then created this test case, only to find out I swapped a parameter, so the validation always worked. Can't hurt to keep the test, though, given that not having one left open the possibility of a bug in the validation - however unlikely.
  • Loading branch information
rdw-software committed Sep 4, 2024
1 parent 5eadd75 commit 14b6280
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Tests/SmokeTests/validation-library/test-validate-string.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ local ffi = require("ffi")
local validation = require("validation")
local validateString = validation.validateString

local function testNilValueCase()
local nothing = nil
validateString(nil, "nothing")
assertThrows(function()
validateString(nothing, "nothing")
end, "Expected argument nothing to be a string value, but received a nil value instead")
end

local function testStringValueCase()
local str = "hello"
assertDoesNotThrow(function()
Expand Down Expand Up @@ -53,6 +61,7 @@ local function testStructCase()
end

local function testValidateString()
testNilValueCase()
testStringValueCase()
testNumberValueCase()
testBooleanValueCase()
Expand Down

0 comments on commit 14b6280

Please sign in to comment.