Added more test cases for the unrestricted option of getRelativeStructuralOffset and getNearestStructuralOffset

Change-Id: I1ab99f1ed050950b40dd4c34abd81a43a4099a49
This commit is contained in:
Trevor Parscal 2012-05-24 10:45:52 -07:00
parent e7cd9e5ef7
commit 8d3044bf60

View file

@ -932,6 +932,13 @@ test( 'getRelativeStructuralOffset', function() {
'distance': 1,
'expected': 5
},
{
'msg': '1 right, unrestricted',
'offset': 5,
'distance': 1,
'unrestricted': true,
'expected': 8
},
{
'msg': '2 right',
'offset': 0,
@ -951,11 +958,25 @@ test( 'getRelativeStructuralOffset', function() {
'distance': -1,
'expected': 56
},
{
'msg': '1 left, unrestricted',
'offset': 8,
'distance': -1,
'unrestricted': true,
'expected': 5
},
{
'msg': '2 left',
'offset': 59,
'distance': -2,
'expected': 53
},
{
'msg': '2 left, unrestricted',
'offset': 8,
'distance': -2,
'unrestricted': true,
'expected': 0
}
];
expect( cases.length );
@ -985,6 +1006,20 @@ test( 'getNearestStructuralOffset', function() {
'direction': 0,
'expected': 5
},
{
'msg': 'unspecified direction results in shortest distance, unrestricted',
'offset': 7,
'direction': 0,
'unrestricted': true,
'expected': 8
},
{
'msg': 'unspecified direction results in shortest distance, unrestricted',
'offset': 6,
'direction': 0,
'unrestricted': true,
'expected': 5
},
{
'msg': 'positive direction results in next valid offset to the right',
'offset': 1,
@ -997,6 +1032,13 @@ test( 'getNearestStructuralOffset', function() {
'direction': 1,
'expected': 5
},
{
'msg': 'positive direction results in next valid offset to the right, unrestricted',
'offset': 6,
'direction': 1,
'unrestricted': true,
'expected': 8
},
{
'msg': 'negative direction results in next valid offset to the left',
'offset': 1,
@ -1008,6 +1050,13 @@ test( 'getNearestStructuralOffset', function() {
'offset': 4,
'direction': -1,
'expected': 0
},
{
'msg': 'negative direction results in next valid offset to the left, unrestricted',
'offset': 7,
'direction': -1,
'unrestricted': true,
'expected': 5
}
];
expect( cases.length );