Skip to content

Commit 860d429

Browse files
author
Boaz Avital
committed
add VersionHelper unit test
1 parent cd9b68e commit 860d429

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright 20127higherfrequencytrading.com
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
18+
package net.openhft.affinity.impl;
19+
20+
import org.junit.Assert;
21+
import org.junit.Test;
22+
23+
public class VersionHelperTest {
24+
25+
@Test
26+
public void isSameOrNewerTest() {
27+
final VersionHelper v0 = new VersionHelper(0,0,0);
28+
final VersionHelper v2_6 = new VersionHelper(2,6,0);
29+
final VersionHelper v4_1 = new VersionHelper(4,1,1);
30+
final VersionHelper v4_9 = new VersionHelper(4,9,0);
31+
final VersionHelper v9_9 = new VersionHelper(9,9,9);
32+
33+
VersionHelper[] versions = new VersionHelper[] { v0, v2_6, v4_1, v4_9, v9_9 };
34+
35+
for (int i = 0; i < versions.length; i++) {
36+
for (int j = 0; j < versions.length; j++) {
37+
Assert.assertEquals(String.format("expected %s.isSameOrNewer(%s) to be %b", versions[i], versions[j], i >= j),
38+
i >= j, versions[i].isSameOrNewer(versions[j]));
39+
}
40+
}
41+
}
42+
43+
}

0 commit comments

Comments
 (0)