#
View Source Vtc.TestUtls.StreamDataVtc (vtc v0.13.15)

`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

framerate_opts()

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

framestamp_opts()

## Functions

framerate(opts \\ [])

Yields Vtc.Framerates, always yields true-frame or NTSC; never a mixture of the two.

framestamp(opts \\ [])

Yields Vtc.Framestamp values.

framestamp_range(opts \\ [])

Yields Vtc.Framestamp.Range values.

rational(opts \\ [])

Yields rational values as %Ratio{} structs.

run_test_rescue_drop_overflow(test_runner)

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

# Link to this section Types

Link to this type

# framerate_opts()

View Source

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

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

Link to this type

# framestamp_opts()

View Source

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

# Link to this section Functions

Link to this function

# framerate(opts \\ [])

View Source

    @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

Link to this function

# framestamp(opts \\ [])

View Source

    @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

Link to this function

# rational(opts \\ [])

View Source

    @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.