summaryrefslogtreecommitdiffstats
path: root/args4j/args4j/test/org/kohsuke/args4j/NativeTypesTest.java
blob: 9d2f280024f7ff69152424c174838db2bcd9d69a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package org.kohsuke.args4j;

public class NativeTypesTest extends Args4JTestBase<NativeTypes> {

	@Override
	public NativeTypes getTestObject() {
		return new NativeTypes();
	}
	
	public void testBooleanTrue() throws CmdLineException  {
		args = new String[]{"-boolean"};
		parser.parseArgument(args);
		assertTrue(testObject._boolean);
	}
	
	public void testBooleanFalse() throws CmdLineException {
		args = new String[]{};
		parser.parseArgument(args);
		assertFalse(testObject._boolean);
	}
	
	public void testByte() throws CmdLineException {
		args = new String[]{"-byte", "42"};
		parser.parseArgument(args);
		assertEquals(42, testObject._byte);
	}
	
	public void testChar() throws CmdLineException {
		args = new String[]{"-char", "a"};
		parser.parseArgument(args);
		assertEquals('a', testObject._char);
	}
	
	public void testDouble() throws CmdLineException {
		args = new String[]{"-double", "42"};
		parser.parseArgument(args);
		assertEquals(42, testObject._double, 0);
	}
	
	public void testFloat() throws CmdLineException {
		args = new String[]{"-float", "42"};
		parser.parseArgument(args);
		assertEquals(42, testObject._float, 0);
	}
	
	public void testInt() throws CmdLineException {
		args = new String[]{"-int", "42"};
		parser.parseArgument(args);
		assertEquals(42, testObject._int);
	}
	
	public void testLong() throws CmdLineException {
		args = new String[]{"-long", "42"};
		parser.parseArgument(args);
		assertEquals(42, testObject._long);
	}
	
	public void testShort() throws CmdLineException {
		args = new String[]{"-short", "42"};
		parser.parseArgument(args);
		assertEquals(42, testObject._short);
	}
}