Wednesday, 28 November 2012

WebVTT Unit Test Review

The C++ wrapper did not have a function to check if the cue setting line was set to "auto". I added it.
isLinePositionAuto()

I changed almost all the comments for the unit tests. They references the syntax rules of the specifications and should be referencing the parser rules.

If a malformed setting is encountered it is ignored. If a setting is used more than once the right most setting (last in the token list) will be used.

I thought for a while that certain tests which actually have to do with the parsing rules before it reaches the matching keyword algorithm would be generic and just make sure nothing gets changed. However this would mean asserting many things in the test, so I thought it better to divide them up and only test one thing at a time.

Cue Generic Settings (csgeneric_unittest.cpp)

Changes

  • MultipleCueSettings2Mixed
    • Used "cue-settings/2-cue-settings-0x20.vtt".
    • Changed to "cue-settings/2-cue-settings-mixed.vtt".
  • SameCueSetting
    • It does not throw an error (WEBVTT_VERTICAL_ALREADY_SET).
    • The settings are parsed in order so that the right most (last in the list) one is used.
    • Vertical will be right to left.
  • BadDelimiter
    • It does not throw an error (WEBVTT_EXPECTED_WHITESPACE).
    • WEBVTT_EXPECTED_WHITESPACE is wrong anyway, it should have been WEBVTT_VERTICAL_BAD_VALUE because the parser takes everything to the right of the first colon in a setting.
    • The parser should try to use "vertical" as keyword and "lr;line:50%" as value.
    • It should skip the malformed setting.
  • BadDelimiter2
    • It does not throw an error (WEBVTT_EXPECTED_WHITESPACE).
    • The parser does not require a spacing character between cue end time timestamp and settings. However there cannot be four digits in a row after the cue end time timestamp decimal.
    • It should skip the malformed setting ("^line").
    • Line should be "auto" because that is default.
  • NoDelimiter
    • It does not throw an error (WEBVTT_EXPECTED_WHITESPACE).
    • The parser does not require a spacing character between cue end time timestamp and settings.
    • It should parse the line setting normally.

Added

  • DigitDelimiter
    • Essentially the same as making sure the fractions of a second in a timestamp does not have 4 digits.
    • Since parser does note require a delimiter between cue end time timestamp and settings, a possible malformed setting could have a keyword that starts with a digit.
    • This should throw the error WEBVTT_MALFORMED_TIMESTAMP.

Cue Setting Align (csalign_unittest.cpp)

The default value for align is middle. If a malformed setting is encountered it is ignored. If a setting is used more than once the right most setting (last in the token list) will be used.

Changed

  • NoKeyword
    • It does not throw an error (WEBVTT_INVALID_CUESETTING).
    • It should skip the malformed setting.
    • Align should be middle because that is default.
  • BadValue
    • It does not throw an error (WEBVTT_ALIGN_BAD_VALUE).
    • It should skip the malformed setting.
    • Align should be middle because that is default.
  • BadDelimiter
    • It does not throw an error (WEBVTT_ALIGN_BAD_VALUE).
    • It should skip the malformed setting.
    • Align should be middle because that is default.
  • NoValue
    • It does not throw an error (WEBVTT_INVALID_CUESETTING).
    • It should skip the malformed setting.
    • Align should be middle because that is default.
  • NoDelimiter
    • It does not throw an error (WEBVTT_INVALID_CUESETTING).
    • It should skip the malformed setting.
    • Align should be middle because that is default.

Added

  • UppercaseKeyword
    • Setting keywords are case-sensitive and must be lowercase.
    • Align should be middle because that is default.
  • UppercaseValue
    • Setting values are case-sensitive and must be lowercase.
    • Align should be middle because that is default.
  • BadKeyword
    • Make sure align is "middle" when no valid align setting.

Cue Setting Line (csline_unittest.cpp)

The setting position affect two thing: the line position and the snap-to-lines flag. The default value for line position is the string "auto". The default value for snap-to-lines is true.

I made sure error count was 0 for all tests that should pass.

Changed

  • SingleDigitNegativeLowBoundary
    • Negative zero equals zero so zero is used.
  • DoubleDigitNegativeLowBoundary
    • Negative zero equals zero so zero is used.
  • BadValue
    • It does not throw an error (WEBVTT_LINE_BAD_VALUE).
    • It should skip the malformed setting.
    • Line should be "auto" and snap-to-lines should be true because that is default.
  • BadDelimiter
    • It does not throw an error (WEBVTT_INVALID_CUESETTING).
    • It should skip the malformed setting.
    • Line should be "auto" and snap-to-lines should be true because that is default.
  • BadKeyword
    • It does not throw an error (WEBVTT_INVALID_CUESETTING).
    • It should skip the malformed setting.
    • Line should be "auto" and snap-to-lines should be true because that is default.
  • BadValueSuffix
    • Actually test two settings.
    • It does not throw an error (WEBVTT_LINE_BAD_VALUE).
    • It should skip the malformed settings.
    • Line should be "auto" and snap-to-lines should be true because that is default.
  • WhitespaceDelimiter
    • Actually test two settings.
    • It does not throw an error (WEBVTT_INVALID_CUESETTING).
    • It should skip the malformed settings.
    • Line should be "auto" and snap-to-lines should be true because that is default.
  • BadWhitespaceBeforeDelimiter
    • Actually test two settings.
    • It does not throw an error (WEBVTT_INVALID_CUESETTING).
    • It should skip the malformed settings.
    • Line should be "auto" and snap-to-lines should be true because that is default.
  • BadWhitespaceAfterDelimiter
    • Actually test two settings.
    • It does not throw an error (WEBVTT_INVALID_CUESETTING).
    • It should skip the malformed settings.
    • Line should be "auto" and snap-to-lines should be true because that is default.

Added

  • ManyDigit
    • More than two digits is allowed.
  • ManyDigitHighBoundary
    • More than two digits is allowed.
    • Max on an int is at least 32767.
  • ManyDigitLowBoundary
    • More than two digits is  allowed.
    • 00000
  • ManyDigitNegative
    • More than two digits is allowed.
  • ManyDigitNegativeHighBoundary
    • More than two digits is allowed.
    • Min on an int is at least -32767.
  • ManyDigitNegativeLowBoundary
    • More than two digits is allowed.
    • 00000
  • ManyDigitPercentage
    • More than two digits are allowed.
    • 055%
  • ManyDigitPercentageHighBoundary
    • More than two digits are allowed.
    • 100%
  • ManyDigitPercentageLowBoundary
    • More than two digits are allowed.
    • 000%
  • NoKeyword
    • It should skip the malformed setting.
    • Line should be "auto" and snap-to-lines should be true because that is default.
  • NoValue
    • It should skip the malformed setting.
    • Line should be "auto" and snap-to-lines should be true because that is default.
  • UppercaseKeyword
    • Setting keywords are case-sensitive and must be lowercase.
    • Align should be middle because that is default.
  • NoDelimiter
    • It should skip the malformed setting.
    • Line should be "auto" and snap-to-lines should be true because that is default.
  • PercentNegative
    • It should skip the malformed setting.
    • Position should be 50 because that is default.
  • PercentOver100
    • It should skip the malformed setting.
    • Position should be 50 because that is default.

Cue Setting Position (csposition_unittest.cpp)

The default value for text position is 50%. The max is 100%. The min is 0%.

Changed

  • TripleDigitPercentage
    • Max value is 100%.
    • Changed value to 055%.
  • TripleDigitPercentageHighBoundary
    • Max value is 100%.
    • Changed value to 100%.
  • DoubleDigitPercentageLowBoundary
    • 00 is same as 0, so 0 is used.
  • TripleDigitPercentageLowBoundary
    • 000 is same as 0, so 0 is used.
  • NoDelimiter
    • It does not throw an error (WEBVTT_INVALID_CUESETTING).
    • It should skip the malformed setting.
    • Position should be 50 because that is default.
  • NoKeyword
    • It does not throw an error (WEBVTT_INVALID_CUESETTING).
    • It should skip the malformed setting.
    • Position should be 50 because that is default.
  • NoPercentSign
    • It does not throw an error (WEBVTT_POSITION_BAD_VALUE).
    • It should skip the malformed setting.
    • Position should be 50 because that is default.
  • BadDelimiter
    • It does not throw an error (WEBVTT_INVALID_CUESETTING).
    • It should skip the malformed setting.
    • Position should be 50 because that is default.
  • AsciiDigitBeyondHighBoundary
    • It does not throw an error (WEBVTT_POSITION_BAD_VALUE).
    • It should skip the malformed setting.
    • Position should be 50 because that is default.
  • AsciiDigitBeyondLowBoundary
    • It does not throw an error (WEBVTT_POSITION_BAD_VALUE).
    • It should skip the malformed setting.
    • Position should be 50 because that is default.

Added

  • NoValue
    • It should skip the malformed setting.
    • Position should be 50 because that is default.
  • PercentNegative
    • It should skip the malformed setting.
    • Position should be 50 because that is default.
  • PercentOver100
    • It should skip the malformed setting.
    • Position should be 50 because that is default.
  • UppercaseKeyword
    • Setting keywords are case-sensitive and must be lowercase.
    • Position should be 50 because that is default.
  • BadKeyword
    • It does not throw an error (WEBVTT_INVALID_CUESETTING).
    • It should skip the malformed setting.
    • Position should be 50 because that is default.

Removed

  • tc4015-cue_settings_line_08_bad.test
    • Not used.

Cue Setting Size (cssize_unittest.cpp)

The default size is 100%. The max is 100% and the min is 0%.

The tests are identical to the cue setting position test, so I copied those tests and edited as needed. Most of it  has changed and the changes are similar to the cue setting position changes and additions.

Cue Setting Vertical (csvertical_unittest.cpp)

The default writing direction is horizontal.

Changed


  • BadKeyword
    • It does not throw an error (WEBVTT_INVALID_CUESETTING).
    • It should skip the malformed setting.
    • Writing direction should be horizontal because that is default.
  • BadDelimiter
    • It does not throw an error (WEBVTT_INVALID_CUESETTING).
    • It should skip the malformed setting.
    • Writing direction should be horizontal because that is default.
  • BadWhitespaceBeforeDelimiter
    • Actually test two settings.
    • It does not throw an error (WEBVTT_INVALID_CUESETTING).
    • It should skip the malformed settings.
    • Writing direction should be horizontal because that is default.
  • BadWhitespaceAfterDelimiter
    • Actually test two settings.
    • It does not throw an error (WEBVTT_INVALID_CUESETTING).
    • It should skip the malformed settings.
    • Writing direction should be horizontal because that is default.

Added


  • UppercaseKeyword
    • Setting keywords are case-sensitive and must be lowercase.
    • Writing direction should be horizontal because that is default.
  • UppercaseValue
    • Setting values are case-sensitive and must be lowercase.
    • Writing direction should be horizontal because that is default.
  • NoValue
    • It should skip the malformed setting.
    • Writing direction should be horizontal because that is default.
  • NoKeyword
    • It should skip the malformed setting.
    • Writing direction should be horizontal because that is default.
  • NoDelimiter
    • It should skip the malformed setting.
    • Writing direction should be horizontal because that is default.

Failing Tests

[  FAILED  ] CueSettingSize.NoDelimiter
[  FAILED  ] CueSettingSize.NoKeyword
[  FAILED  ] CueSettingSize.NoValue
[  FAILED  ] CueSettingSize.NoPercentSign
[  FAILED  ] CueSettingSize.BadDelimiter
[  FAILED  ] CueSettingSize.BadKeyword
[  FAILED  ] CueSettingSize.AsciiDigitBeyondHighBoundary
[  FAILED  ] CueSettingSize.AsciiDigitBeyondLowBoundary
[  FAILED  ] CueSettingSize.PercentNegative
[  FAILED  ] CueSettingSize.PercentOver100
[  FAILED  ] CueSettingSize.UppercaseKeyword

[  FAILED  ] CueSettingPosition.NoDelimiter
[  FAILED  ] CueSettingPosition.NoKeyword
[  FAILED  ] CueSettingPosition.NoValue
[  FAILED  ] CueSettingPosition.NoPercentSign
[  FAILED  ] CueSettingPosition.BadDelimiter
[  FAILED  ] CueSettingPosition.BadKeyword
[  FAILED  ] CueSettingPosition.AsciiDigitBeyondHighBoundary
[  FAILED  ] CueSettingPosition.AsciiDigitBeyondLowBoundary
[  FAILED  ] CueSettingPosition.PercentNegative
[  FAILED  ] CueSettingPosition.PercentOver100
[  FAILED  ] CueSettingPosition.UppercaseKeyword

[  FAILED  ] CueSettingVertical.BadKeyword
[  FAILED  ] CueSettingVertical.BadDelimiter
[  FAILED  ] CueSettingVertical.BadValue
[  FAILED  ] CueSettingVertical.BadWhitespaceBeforeDelimiter
[  FAILED  ] CueSettingVertical.BadWhitespaceAfterDelimiter
[  FAILED  ] CueSettingVertical.NoKeyword
[  FAILED  ] CueSettingVertical.NoValue
[  FAILED  ] CueSettingVertical.NoDelimiter
[  FAILED  ] CueSettingVertical.UppercaseKeyword
[  FAILED  ] CueSettingVertical.UppercaseValue

[  FAILED  ] CueSettingAlign.Left
[  FAILED  ] CueSettingAlign.Right
[  FAILED  ] CueSettingAlign.BadKeyword
[  FAILED  ] CueSettingAlign.NoKeyword
[  FAILED  ] CueSettingAlign.BadValue
[  FAILED  ] CueSettingAlign.NoValue
[  FAILED  ] CueSettingAlign.BadDelimiter
[  FAILED  ] CueSettingAlign.NoDelimiter
[  FAILED  ] CueSettingAlign.UppercaseKeyword
[  FAILED  ] CueSettingAlign.UppercaseValue

[  FAILED  ] CueSettingLine.ManyDigitLowBoundary
[  FAILED  ] CueSettingLine.ManyDigitPercentage
[  FAILED  ] CueSettingLine.ManyDigitPercentageHighBoundary
[  FAILED  ] CueSettingLine.ManyDigitPercentageLowBoundary
[  FAILED  ] CueSettingLine.DoubleDigitPercentage
[  FAILED  ] CueSettingLine.DoubleDigitPercentageHighBoundary
[  FAILED  ] CueSettingLine.DoubleDigitPercentageLowBoundary
[  FAILED  ] CueSettingLine.SingleDigitPercentage
[  FAILED  ] CueSettingLine.SingleDigitPercentageHighBoundary
[  FAILED  ] CueSettingLine.SingleDigitPercentageLowBoundary
[  FAILED  ] CueSettingLine.BadKeyword
[  FAILED  ] CueSettingLine.NoKeyword
[  FAILED  ] CueSettingLine.NoDelimiter
[  FAILED  ] CueSettingLine.BadDelimiter
[  FAILED  ] CueSettingLine.BadValue
[  FAILED  ] CueSettingLine.NoValue
[  FAILED  ] CueSettingLine.BadValueSuffix
[  FAILED  ] CueSettingLine.WhitespaceDelimiter
[  FAILED  ] CueSettingLine.BadWhitespaceBeforeDelimiter
[  FAILED  ] CueSettingLine.BadWhitespaceAfterDelimiter
[  FAILED  ] CueSettingLine.UppercaseKeyword
[  FAILED  ] CueSettingLine.PercentNegative
[  FAILED  ] CueSettingLine.PercentOver100

[  FAILED  ] CueSetting.SameCueSetting
[  FAILED  ] CueSetting.BadDelimiter
[  FAILED  ] CueSetting.BadDelimiter2
[  FAILED  ] CueSetting.NoDelimiter
[  FAILED  ] CueSetting.DigitDelimiter

No comments:

Post a Comment