blob: 38983b5a49876220f1519ad62c4a6ba87e09bbf5 (
plain) (
blame)
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
/*******************************************************************************
* Copyright (c) 2009 Cloudsmith Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Cloudsmith Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.equinox.p2.tests.omniVersion;
import org.eclipse.equinox.p2.metadata.Version;
import junit.framework.TestCase;
/**
* Tests format(r)
*
*/
public class FormatRTest extends TestCase {
public void testNumeric() {
Version v = Version.parseVersion("format(r):1");
assertNotNull(v);
assertEquals(Version.parseVersion("raw:1"), v);
}
public void testNegativeNumeric() {
Version v = Version.parseVersion("format(r):-1");
assertNotNull(v);
assertEquals(Version.parseVersion("raw:-1"), v);
}
public void testString() {
Version v = Version.parseVersion("format(r):'a'");
assertNotNull(v);
assertEquals(Version.parseVersion("raw:'a'"), v);
assertNotNull(v = Version.parseVersion("format(r):\"a\""));
assertEquals(Version.parseVersion("raw:'a'"), v);
}
public void testConcatentatedStrings() {
Version v = Version.parseVersion("format(r):'a''b'");
assertNotNull(v);
assertEquals(Version.parseVersion("raw:'ab'"), v);
assertNotNull(v = Version.parseVersion("format(r):'a has a \"hat\" it is '\"a's\""));
assertEquals(Version.parseVersion("raw:'a has a \"hat\" it is '\"a's\""), v);
}
public void testMaxString() {
Version v = Version.parseVersion("format(r):m");
assertNotNull(v);
assertEquals(Version.parseVersion("raw:m"), v);
}
public void testMaxNumeric() {
Version v = Version.parseVersion("format(r):M");
assertNotNull(v);
assertEquals(Version.parseVersion("raw:M"), v);
}
public void testArray() {
Version v = Version.parseVersion("format(r):<1>");
assertNotNull(v);
assertEquals(Version.parseVersion("raw:<1>"), v);
}
public void testNonRElements() {
try {
Version.parseVersion("format(r):aaa");
fail("a is not a valid raw element");
} catch (IllegalArgumentException e) {
assertTrue(true);
}
try {
Version.parseVersion("format(r):1,2");
fail("comma is not a delimiter in raw format");
} catch (IllegalArgumentException e) {
assertTrue(true);
}
}
}
|