jellyfin-roku/test-app/source/tests/utils/misc/isValid.spec.bs
2023-04-22 09:03:44 -04:00

188 lines
8.8 KiB
Plaintext

namespace tests
@suite("isValid functions")
class isValidTests extends tests.BaseTestSuite
protected override function setup()
super.setup()
m.myArray = CreateObject("roArray", 3, true)
m.myAssArray = { one: invalid, two: "invalid", three: 123.456 }
m.myEmptyArray = CreateObject("roArray", 0, false)
m.myEmptyList = CreateObject("roList")
m.myList = CreateObject("roList")
m.myList.AddTail("string")
end function
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@describe("isValid()")
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@it("works with booleans")
@params(true, true)
@params(false, true)
function _(value, expectedassertResult)
m.assertEqual(isValid(value), expectedassertResult)
end function
@it("works with integers")
@params(-1234567890, true)
@params(0, true)
@params(1234567890, true)
@params(1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890, true)
function _(value, expectedassertResult)
m.assertEqual(isValid(value), expectedassertResult)
end function
@it("works with floats")
@params(-12.3456789, true)
@params(12.3456789, true)
@params(1.23456E+30, true)
@params(12.3456789!, true)
@params(123456789012345678901234567890123456789012345678901234567890.123456789012345678901234567890123456789012345678901234567890, true)
function _(value, expectedassertResult)
m.assertEqual(isValid(value), expectedassertResult)
end function
@it("works with strings")
@params("", true)
@params(" ", true)
@params("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Augue neque gravida in fermentum et. Eget lorem dolor sed viverra ipsum nunc. At quis risus sed vulputate odio ut enim. Ultricies integer quis auctor elit sed. Egestas congue quisque egestas diam in. Aliquam sem fringilla ut morbi tincidunt. Malesuada bibendum arcu vitae elementum curabitur. Aliquet sagittis id consectetur purus ut faucibus pulvinar. Eget gravida cum sociis natoque. Sollicitudin aliquam ultrices sagittis orci. Ut etiam sit amet nisl purus. Luctus venenatis lectus magna fringilla urna porttitor rhoncus dolor purus. Vitae ultricies leo integer malesuada nunc. Vitae ultricies leo integer malesuada nunc vel risus commodo. Luctus accumsan tortor posuere ac ut. Urna cursus eget nunc scelerisque viverra mauris in. Accumsan sit amet nulla facilisi morbi tempus iaculis urna id. Mauris vitae ultricies leo integer malesuada nunc vel risus commodo. Morbi tincidunt augue interdum velit euismod in pellentesque.", true)
@params("~!@#$%^&*()_-+=`\|]}';:.,/?", true)
@params("true", true)
@params("false", true)
@params("invalid", true)
function _(value, expectedassertResult)
m.assertEqual(isValid(value), expectedassertResult)
end function
@it("works with arrays")
@params([0, 1, 2, 3, 4, 5], true)
@params(["invalid", "one", "two", "three", "four", "five"], true)
@params([invalid, invalid, invalid], true)
function _(value, expectedassertResult)
m.assertEqual(isValid(value), expectedassertResult)
end function
@it("works with associative arrays")
@params({ myInteger: 1, myString: "one", myInvalid: invalid, myEmptyString: "" }, true)
function _(value, expectedassertResult)
m.assertEqual(isValid(value), expectedassertResult)
end function
@it("works with an array of associative arrays")
@params(
[
{
Title: "The Notebook",
releaseDate: "2000"
},
{
Title: "Caddyshack",
releaseDate: "1976"
}
], true)
function _(value, expectedassertResult)
m.assertEqual(isValid(value), expectedassertResult)
end function
@it("works when accessing arrays")
function _()
m.assertEqual(isValid(m.myAssArray.one), false)
m.assertEqual(isValid(m.myAssArray.two), true)
end function
@it("works when accessing an invalid array index")
function _()
m.assertEqual(isValid(m.myAssArray.zero), false)
end function
@it("works with invalid")
@params(invalid, false)
function _(value, expectedassertResult)
m.assertEqual(isValid(value), expectedassertResult)
end function
@it("works with nodes")
@params("#RBSNode", true)
@params("#RBSNode|Group", true)
@params("#RBSNode|Label", true)
@params("#RBSNode|ScrollingLabel", true)
@params("#RBSNode|Poster", true)
@params("#RBSNode|Rectangle", true)
@params("#RBSNode|Font", true)
@params("#RBSNode|Button", true)
@params("#RBSNode|Rectangle", true)
@params("#RBSNode|Overhang", true)
@params("#RBSNode|Audio", true)
@params("#RBSNode|Video", true)
function _(value, expectedassertResult)
m.assertEqual(isValid(value), expectedassertResult)
end function
@it("works with objects")
function _()
myList = CreateObject("roList")
myLongInteger = CreateObject("roLongInteger")
myDouble = CreateObject("roDouble")
myFloat = CreateObject("roFloat")
myInvalid = CreateObject("roInvalid")
m.assertEqual(isValid(myList), true)
m.assertEqual(isValid(myLongInteger), true)
m.assertEqual(isValid(myDouble), true)
m.assertEqual(isValid(myFloat), true)
m.assertEqual(isValid(myInvalid), false)
end function
@it("works with functions")
function _()
myfunc = function(a, b)
return a + b
end function
m.assertEqual(isValid(myfunc(0, 1)), true)
end function
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@describe("isValidAndNotEmpty()")
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@it("works with invalid")
@params(invalid, false)
function _(value, expectedassertResult)
m.assertEqual(isValidAndNotEmpty(value), expectedassertResult)
end function
@it("works with strings")
@params("", false)
@params(" ", false)
@params("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Augue neque gravida in fermentum et. Eget lorem dolor sed viverra ipsum nunc. At quis risus sed vulputate odio ut enim. Ultricies integer quis auctor elit sed. Egestas congue quisque egestas diam in. Aliquam sem fringilla ut morbi tincidunt. Malesuada bibendum arcu vitae elementum curabitur. Aliquet sagittis id consectetur purus ut faucibus pulvinar. Eget gravida cum sociis natoque. Sollicitudin aliquam ultrices sagittis orci. Ut etiam sit amet nisl purus. Luctus venenatis lectus magna fringilla urna porttitor rhoncus dolor purus. Vitae ultricies leo integer malesuada nunc. Vitae ultricies leo integer malesuada nunc vel risus commodo. Luctus accumsan tortor posuere ac ut. Urna cursus eget nunc scelerisque viverra mauris in. Accumsan sit amet nulla facilisi morbi tempus iaculis urna id. Mauris vitae ultricies leo integer malesuada nunc vel risus commodo. Morbi tincidunt augue interdum velit euismod in pellentesque.", true)
@params("~!@#$%^&*()_-+=`\|]}';:.,/?", true)
@params("true", true)
@params("false", true)
@params("invalid", true)
function _(value, expectedassertResult)
m.assertEqual(isValidAndNotEmpty(value), expectedassertResult)
end function
@it("works with arrays")
function _()
m.assertEqual(isValidAndNotEmpty(m.myEmptyArray), false)
m.assertEqual(isValidAndNotEmpty(m.myArray), false)
m.myArray.Push("string")
m.assertEqual(isValidAndNotEmpty(m.myArray), true)
m.myArray.Clear()
m.assertEqual(isValidAndNotEmpty(m.myArray), false)
end function
@it("works with associative arrays")
function _()
m.assertEqual(isValidAndNotEmpty(m.myEmptyArray), false)
m.assertEqual(isValidAndNotEmpty(m.myAssArray), true)
end function
@it("works with lists")
function _()
m.assertEqual(isValidAndNotEmpty(m.myEmptyList), false)
m.assertEqual(isValidAndNotEmpty(m.myList), true)
end function
end class
end namespace