View Source Vtc.TestUtls.StreamDataVtc (vtc v0.13.9)

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 Vtc.Framestamp values.

Yields Vtc.Framestamp.Range values.

Yields rational values as %Ratio{} structs.

Runs a test, but does not fail if the operation causes a drop-frame overflow exception to occur.

Link to this section Types

@type framerate_opts() :: [{:type, :whole | :fractional | :drop | :non_drop}]

Describes the opts that can be passed to framerate/1.

@type framestamp_opts() :: [
  non_negative?: boolean(),
  rate: Vtc.Framerate.t(),
  rate_opts: framerate_opts()
]

Link to this section Functions

@spec framerate(framerate_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 framestamp(framestamp_opts()) :: StreamData.t(Vtc.Framestamp.t())

Yields Vtc.Framestamp values.

options

Options

  • non_negative?: Will only return values greater than or equal to 00: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 to framerate/1 when generating the framerate. Has no effect if rate is set.

examples

Examples

property "returns input of negate/1" do
  check all(positive <- StreamDataVtc.framestamp(non_negative?: true)) do
    negative = Framestamp.minus(positive)
    assert Framestamp.abs(positive) == Framestamp.abs(negative)
  end
end
Link to this function

framestamp_range(opts \\ [])

View Source
@spec framestamp_range(
  rate_opts: framerate_opts(),
  stamp_opts: framestamp_opts(),
  filter_empty?: boolean()
) :: StreamData.t(Vtc.Framestamp.Range.t())

Yields Vtc.Framestamp.Range values.

options

Options

  • rate_opts: The options to pass to the framerate/1 generator for this range.

  • stamp_opts: The options to pass to the framestamp/1 generators for this range.

  • filter_empty?: If true, filters 0-length ranges from the output. Default: false.

examples

Examples

property "returns input of negate/1" do
  check all(positive <- StreamDataVtc.framestamp_range()) 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
Link to this function

run_test_rescue_drop_overflow(test_runner)

View Source
@spec run_test_rescue_drop_overflow((() -> term())) :: term()

Runs a test, but does not fail if the operation causes a drop-frame overflow exception to occur.