01: /*
02: * FirstWordFormatterTest.java
03: *
04: * Copyright (C) 2005 Anupam Sengupta (anupamsg@users.sourceforge.net)
05: *
06: * This program is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU General Public License
08: * as published by the Free Software Foundation; either version 2
09: * of the License, or (at your option) any later version.
10: *
11: * This program is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14: * GNU General Public License for more details.
15: *
16: * You should have received a copy of the GNU General Public License
17: * along with this program; if not, write to the Free Software
18: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19: *
20: * Version: $Revision: 1.1 $
21: */
22: package net.sf.anupam.csv.formatters;
23:
24: import junit.framework.TestCase;
25:
26: /**
27: * LastWordFormatterTest.
28: *
29: * @author Anupam Sengupta
30: * @version $Revision: 1.1 $
31: */
32: public class LastWordFormatterTest extends TestCase {
33:
34: /**
35: * Constructor for LastWordFormatterTest.
36: *
37: * @param name
38: * name of the test
39: */
40: public LastWordFormatterTest(final String name) {
41: super (name);
42: }
43:
44: /**
45: * Main method to perform the tests.
46: *
47: * @param args
48: * Program arguments
49: */
50: public static void main(final String[] args) {
51: junit.textui.TestRunner.run(LastWordFormatterTest.class);
52: }
53:
54: /**
55: * Test method for
56: * 'com.tcs.mis.csv.utilities.FirstWordFormatter.format(String)'.
57: */
58: public void testFormat() {
59: final String name = "Anupam B Sengupta";
60: final CSVFieldFormatter formatter = new LastWordFormatter();
61: assertNotNull(formatter);
62: final String result = formatter.format(name);
63: assertEquals("Sengupta", result);
64: }
65:
66: /**
67: * Test method for
68: * 'com.tcs.mis.csv.utilities.FirstWordFormatter.format(String)'.
69: */
70: public void testFormatWhenNull() {
71: final CSVFieldFormatter formatter = new LastWordFormatter();
72: assertNotNull(formatter);
73:
74: final String nullResult = formatter.format(null);
75: assertNull(nullResult);
76:
77: }
78:
79: /**
80: * Test method for
81: * 'com.tcs.mis.csv.utilities.FirstWordFormatter.format(String)'.
82: */
83: public void testFormatWhenEmpty() {
84: final CSVFieldFormatter formatter = new LastWordFormatter();
85: assertNotNull(formatter);
86:
87: final String emptyResult = formatter.format("");
88: assertEquals("", emptyResult);
89:
90: }
91: }
|