01: /*
02: Copyright 2004-2007 Paul R. Holser, Jr. All rights reserved.
03: Licensed under the Academic Free License version 3.0
04: */
05:
06: package joptsimple;
07:
08: import junit.framework.TestCase;
09:
10: /**
11: * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a>
12: * @version $Id: KeyValuePairTest.java,v 1.10 2007/04/10 20:06:27 pholser Exp $
13: */
14: public class KeyValuePairTest extends TestCase {
15: public void testNull() {
16: try {
17: KeyValuePair.parse(null);
18: fail();
19: } catch (NullPointerException expected) {
20: assertTrue(expected.getMessage(), true);
21: }
22: }
23:
24: public void testEmpty() {
25: KeyValuePair pair = KeyValuePair.parse("");
26: assertEquals("", pair.key);
27: assertEquals("", pair.value);
28: }
29:
30: public void testNoEqualsSign() {
31: KeyValuePair pair = KeyValuePair.parse("aString");
32: assertEquals("aString", pair.key);
33: assertEquals("", pair.value);
34: }
35:
36: public void testEqualsSignAtEnd() {
37: KeyValuePair pair = KeyValuePair.parse("aKey=");
38: assertEquals("aKey", pair.key);
39: assertEquals("", pair.value);
40: }
41:
42: public void testEqualsSignAtStart() {
43: KeyValuePair pair = KeyValuePair.parse("=aValue");
44: assertEquals("", pair.key);
45: assertEquals("aValue", pair.value);
46: }
47:
48: public void testTypical() {
49: KeyValuePair pair = KeyValuePair.parse("aKey=aValue");
50: assertEquals("aKey", pair.key);
51: assertEquals("aValue", pair.value);
52: }
53:
54: public void testMultipleEqualsSignsDoNotMatter() {
55: KeyValuePair pair = KeyValuePair.parse("aKey=1=2=3=4");
56: assertEquals("aKey", pair.key);
57: assertEquals("1=2=3=4", pair.value);
58: }
59: }
|