package org.metaborg.core.test.language;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import org.junit.Test;
import org.metaborg.core.language.LanguageVersion;

public class LanguageVersionTest {
    @Test public void testParse() {
        assertEquals(new LanguageVersion(0, 0, 0, ""), LanguageVersion.parse(""));
        assertEquals(new LanguageVersion(1, 0, 0, ""), LanguageVersion.parse("1"));
        assertEquals(new LanguageVersion(1, 2, 0, ""), LanguageVersion.parse("1.2"));
        assertEquals(new LanguageVersion(1, 2, 3, ""), LanguageVersion.parse("1.2.3"));
        assertEquals(new LanguageVersion(1, 2, 3, "SNAPSHOT"), LanguageVersion.parse("1.2.3-SNAPSHOT"));
        assertEquals(new LanguageVersion(1, 2, 3, "baseline-20150607"),
            LanguageVersion.parse("1.2.3-baseline-20150607"));
    }

    @Test public void testCompare() {
        int result;
        result = new LanguageVersion(1, 0, 0, "").compareTo(new LanguageVersion(1, 0, 0, ""));
        assertTrue(result == 0);
        result = new LanguageVersion(1, 2, 0, "").compareTo(new LanguageVersion(2, 1, 0, ""));
        assertTrue(result < 0);
        result = new LanguageVersion(2, 1, 0, "").compareTo(new LanguageVersion(1, 2, 0, ""));
        assertTrue(result > 0);
        result = new LanguageVersion(1, 2, 0, "SNAPSHOT").compareTo(new LanguageVersion(1, 2, 0, ""));
        assertTrue(result < 0);
        result = new LanguageVersion(1, 2, 0, "SNAPSHOT").compareTo(new LanguageVersion(1, 2, 0, "Z"));
        assertTrue(result < 0);
        result = new LanguageVersion(1, 2, 0, "SNAPSHOT").compareTo(new LanguageVersion(1, 2, 0, "snapshot"));
        assertTrue(result == 0);
    }
}

@@ -1419,33 +1419,33 @@
 sertTrue(result 
-%3C
+%3E
  0);%0A        res
@@ -1535,9 +1535,21 @@
 0, %22
-Z
+baseline-1234
 %22));
@@ -1567,33 +1567,33 @@
 sertTrue(result 
-%3C
+%3E
  0);%0A        res

Fix language version test