humphd/webvtt — pull request #72 by KyleBarnhart (2012-11-28 21:34:59+00:00)
Title: Review of unit tests

http://kyle.barnhart.ca/2012/11/webvtt-unit-test-review.html

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.