Skip to content

Commit

Permalink
Test I forgot to move in 4e5cd76
Browse files Browse the repository at this point in the history
  • Loading branch information
sarxos committed Jun 18, 2014
1 parent 0dd27f3 commit 2f1d3ca
Showing 1 changed file with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.github.sarxos.webcam.util;

import org.junit.Test;

import com.github.sarxos.webcam.util.NixVideoDevUtils;

import java.io.File;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

/**
* @author Dan Rollo
* Date: 3/8/14
* Time: 10:44 PM
*/
public class NixVideoDevUtilsTest {

/**
* Accept method was failing with exception: String index out of range: 5
* This occurs on opensuse 11 where video device files do not all have a suffix. The files are created like so:
* $ ls -l /dev/video*
* /dev/video -> video0
* /dev/video0
*
* In this case, the link name 'video' is less that 6 characters long, so the filter statement:
* Character.isDigit(name.charAt(5))
* causes the exception.
*
* Fix is to also check for length before checking for isDigit().
*/
@Test
public void testAcceptHandlesShortVideoDeviceFilename() {
final NixVideoDevUtils videoDeviceFilenameFilter = new NixVideoDevUtils();
assertFalse(videoDeviceFilenameFilter.accept(new File("/dev"), "video"));
assertTrue(videoDeviceFilenameFilter.accept(new File("/dev"), "video0"));
}
}

0 comments on commit 2f1d3ca

Please sign in to comment.