1 19 20 package org.netbeans.modules.derby; 21 22 import junit.framework.*; 23 24 28 public class SearchUtilTest extends TestCase { 29 30 public SearchUtilTest(String testName) { 31 super(testName); 32 } 33 34 37 public void testCheckForString() { 38 String searchedFor; 39 int searchStart; 40 char[] buf; 41 int bufLen; 42 43 searchedFor = "12345"; 44 searchStart = 0; 45 buf = new char[] {'a', 'b', '1', '2', '3', 'x', 'x'}; 46 bufLen = 5; 47 assertEquals(3, SearchUtil.checkForString(searchedFor, searchStart, buf, bufLen)); 48 49 searchedFor = "12345"; 50 searchStart = 2; 51 buf = new char[] {'3', '4', '5', 'a', 'b', 'x'}; 52 bufLen = 5; 53 assertEquals(SearchUtil.FOUND, SearchUtil.checkForString(searchedFor, searchStart, buf, bufLen)); 54 55 searchedFor = "12345"; 56 searchStart = 0; 57 buf = new char[] {'3', '4', '5', 'a', 'b', 'x'}; 58 bufLen = 5; 59 assertEquals(0, SearchUtil.checkForString(searchedFor, searchStart, buf, bufLen)); 60 61 searchedFor = "12345"; 62 searchStart = 0; 63 buf = new char[] {'a', 'b', 'c', '1', '2', 'x'}; 64 bufLen = 5; 65 assertEquals(2, SearchUtil.checkForString(searchedFor, searchStart, buf, bufLen)); 66 67 } 68 69 72 public void testCheckPosition() { 73 String searchedFor = "12345"; 74 int searchStart = 0; 75 char[] buf = new char[] {'a', 'b', '1', '2', '3', 'x', 'x'}; 76 int bufLen = 5; 77 int bufFrom = 2; 78 assertEquals(3, SearchUtil.checkPosition(searchedFor, searchStart, buf, bufLen, bufFrom)); 79 80 } 81 82 } 83 | Popular Tags |