View Source Vtc.TestUtls.StreamDataVtc (vtc v0.10.1)
StreamData generators for use in tests that involve custom Ecto types. For use in
property tests.
This module is only available in :test and :dev envs.
Link to this section Summary
Types
Describes the opts that can be passed to framerate/1.
Functions
Yields Vtc.Framerates, always yields true-frame or NTSC; never a mixture of the two.
Yields rational values as %Ratio{} structs.
Yields Vtc.Timecode values, always yields true-frame or NTSC; never a mixture of the two.
Link to this section Types
@type rate_opts() :: [{:type, :whole | :fractional | :drop | :non_drop}]
Describes the opts that can be passed to framerate/1.
Link to this section Functions
@spec framerate(rate_opts()) :: StreamData.t(Vtc.Framerate.t())
Yields Vtc.Framerates, always yields true-frame or NTSC; never a mixture of the two.
options
Options
type: The ntsc value all framerates should be generated with. Can be any of the following::whole: All yielded framerates will be non-ntsc, whole-frame rates. Ex: 24/1 fps.:fractional: All yielded framerates will be a random non-drop rate.:non_drop: All yielded framerates will be NTSC, non-drop values.:drop: All yielded framerates will be NTSC, drop-frame values.
A list of the above options may be passed and each value yielded from this generator will pick randomly from them.
Defaults to
[:whole, :fractional, :non_drop, :drop]
examples
Examples
property "prop test" do
check all(framerate <- StreamDataVtc.framerate()) do
...
end
end
@spec rational(numerator: integer(), denominator: pos_integer(), positive?: boolean()) :: StreamData.t(Ratio.t())
Yields rational values as %Ratio{} structs.
options
Options
numerator: A static value to use for the numerator of all genrated rationals. Default: nil.denominator: A static value to use for the denominator of all genrated rationals. Default: nil.positive?: If true, only positive values (greater than 0) are generated. Default:false.
examples
Examples
property "prop test" do
check all(fraction <- StreamDataVtc.rational()) do
...
end
end
@spec timecode( non_negative?: boolean(), rate: Vtc.Framerate.t(), rate_opts: rate_opts() ) :: StreamData.t(Vtc.Timecode.t())
Yields Vtc.Timecode values, always yields true-frame or NTSC; never a mixture of the two.
options
Options
non_negative?: Will only return values greater than or equal to00:00:00:00.rate: A framerate to use for this test. If one is not provided, a random one will be used.rate_opts: Opts that should be passed toframerate/1when generating the framerate. Has no effect ifrateis set.
examples
Examples
property "returns input of negate/1" do
check all(positive <- StreamDataVtc.timecode(non_negative?: true)) do
negative = Timecode.minus(positive)
assert Timecode.abs(positive) == Timecode.abs(negative)
end
end