01: /*
02: * SearchAndReplaceTest.java
03: *
04: * This file is part of SQL Workbench/J, http://www.sql-workbench.net
05: *
06: * Copyright 2002-2008, Thomas Kellerer
07: * No part of this code maybe reused without the permission of the author
08: *
09: * To contact the author please send an email to: support@sql-workbench.net
10: *
11: */
12: package workbench.gui.editor;
13:
14: /**
15: *
16: * @author support@sql-workbench.net
17: */
18: public class SearchAndReplaceTest extends junit.framework.TestCase {
19:
20: public SearchAndReplaceTest(String testName) {
21: super (testName);
22: }
23:
24: public void testCreateSearchPattern() {
25: String input = "thetext";
26: String expression = SearchAndReplace.getSearchExpression(input,
27: false, false, false);
28: assertEquals("Wrong expression", "(" + input + ")", expression);
29:
30: expression = SearchAndReplace.getSearchExpression(input, false,
31: true, false);
32: assertEquals("Wrong expression", "\\b(" + input + ")\\b",
33: expression);
34:
35: expression = SearchAndReplace.getSearchExpression(input, true,
36: true, false);
37: assertEquals("Wrong expression", "(?i)\\b(" + input + ")\\b",
38: expression);
39:
40: expression = SearchAndReplace.getSearchExpression(input, true,
41: true, true);
42: assertEquals("Wrong expression", "(?i)\\b" + input + "\\b",
43: expression);
44:
45: expression = SearchAndReplace.getSearchExpression(input, true,
46: false, true);
47: assertEquals("Wrong expression", "(?i)" + input, expression);
48:
49: expression = SearchAndReplace.getSearchExpression(input, false,
50: false, true);
51: assertEquals("Wrong expression", input, expression);
52: }
53:
54: }
|