1 | /*
|
---|
2 | * Copyright (C) 1997 by Pharos IP Pty Ltd
|
---|
3 | * Confidential. All rights reserved.
|
---|
4 | * $Id: StringOpsTest.java 10737 2005-10-19 03:06:40Z kjdon $
|
---|
5 | * $Source$
|
---|
6 | */
|
---|
7 |
|
---|
8 | package au.com.pharos.util.test;
|
---|
9 |
|
---|
10 | import au.com.pharos.test.Test;
|
---|
11 |
|
---|
12 | import au.com.pharos.util.StringOps;
|
---|
13 |
|
---|
14 | /**
|
---|
15 | * Test harness for <CODE>au.com.pharos.util.StringOps</CODE>
|
---|
16 | *
|
---|
17 | * @author Martin Pool
|
---|
18 | * @version $Revision: 10737 $ $Date: 2005-10-19 03:06:40 +0000 (Wed, 19 Oct 2005) $
|
---|
19 | **/
|
---|
20 | public class StringOpsTest
|
---|
21 | {
|
---|
22 | static public void main(String[] args)
|
---|
23 | {
|
---|
24 | new StringOpsTest().run();
|
---|
25 | }
|
---|
26 |
|
---|
27 | public void run()
|
---|
28 | {
|
---|
29 | try {
|
---|
30 | testCountOccurrences();
|
---|
31 | }
|
---|
32 | finally {
|
---|
33 | Test.summary();
|
---|
34 | }
|
---|
35 | }
|
---|
36 |
|
---|
37 | public void testCountOccurrences()
|
---|
38 | {
|
---|
39 | // Simple tests of countOccurences(String, char)
|
---|
40 | Test.ok(100, ( StringOps.countOccurrences("hello world", 'z') == 0) );
|
---|
41 | Test.ok(110, ( StringOps.countOccurrences("zhello world", 'z') == 1) );
|
---|
42 | Test.ok(120, ( StringOps.countOccurrences("hello worldz", 'z') == 1) );
|
---|
43 | Test.ok(130, ( StringOps.countOccurrences("z", 'z') == 1) );
|
---|
44 | Test.ok(140, ( StringOps.countOccurrences("zzz", 'z') == 3) );
|
---|
45 | Test.ok(150, ( StringOps.countOccurrences("0z0z0z", 'z') == 3) );
|
---|
46 | Test.ok(160, ( StringOps.countOccurrences("\0z\0z\0z", '\0') == 3) );
|
---|
47 | }
|
---|
48 | }
|
---|