WEB-16000 Gulp integration creates invalid run/debug tasks
[idea/community.git] / platform / util / testSrc / com / intellij / util / text / SemVerTest.java
1 /*
2  * Copyright 2000-2014 JetBrains s.r.o.
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 package com.intellij.util.text;
17
18 import junit.framework.TestCase;
19 import org.jetbrains.annotations.NotNull;
20
21 public class SemVerTest extends TestCase {
22   public void testParsing() throws Exception {
23     String version = "0.9.2";
24     assertEquals(new SemVer(version, 0, 9, 2), parseNotNull(version));
25   }
26
27   public void testExtendedVersion() throws Exception {
28     String version = "0.9.2-dart";
29     assertEquals(new SemVer(version, 0, 9, 2), parseNotNull(version));
30   }
31
32   public void testGulp4Alpha() throws Exception {
33     String version = "4.0.0-alpha.1";
34     assertEquals(new SemVer(version, 4, 0, 0), parseNotNull(version));
35   }
36
37   public void testCompare() throws Exception {
38     assertTrue(parseNotNull("1.0.0").compareTo(parseNotNull("0.10.0")) > 0);
39     assertTrue(parseNotNull("1.0.0").compareTo(parseNotNull("2.10.0")) < 0);
40
41     assertTrue(parseNotNull("0.30.0").compareTo(parseNotNull("0.5.1000")) > 0);
42     assertTrue(parseNotNull("0.30.10").compareTo(parseNotNull("0.100.0")) < 0);
43
44     assertTrue(parseNotNull("2.9.123-test").compareTo(parseNotNull("2.9.100")) > 0);
45     assertTrue(parseNotNull("2.9.123-test").compareTo(parseNotNull("2.9.124")) < 0);
46
47     assertTrue(parseNotNull("11.123.0").compareTo(parseNotNull("11.123.0")) == 0);
48   }
49
50   @NotNull
51   private static SemVer parseNotNull(@NotNull String text) {
52     SemVer semVer = SemVer.parseFromText(text);
53     assertNotNull(semVer);
54     return semVer;
55   }
56 }