Home | History | Annotate | Download | only in build
      1 /*
      2  * Copyright 2018 The Android Open Source Project
      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 package androidx.build
     18 
     19 import org.junit.Assert.assertEquals
     20 import org.junit.Test
     21 import org.junit.runner.RunWith
     22 import org.junit.runners.JUnit4
     23 
     24 @RunWith(JUnit4::class)
     25 class VersionTest {
     26     @Test
     27     fun testComparisons() {
     28         assert(true > false)
     29 
     30         val version2600 = Version("26.0.0")
     31         val version2610 = Version("26.1.0")
     32         val version2611 = Version("26.1.1")
     33         val version2620 = Version("26.2.0")
     34         val version2621 = Version("26.2.1")
     35         val version2700 = Version("27.0.0")
     36         val version2700SNAPSHOT = Version("27.0.0-SNAPSHOT")
     37         val version2700TNAPSHOT = Version("27.0.0-TNAPSHOT")
     38 
     39         assertEquals(version2600, version2600)
     40 
     41         assert(version2600 < version2700)
     42 
     43         assert(version2600 < version2700)
     44 
     45         assert(version2610 < version2611)
     46         assert(version2610 < version2620)
     47         assert(version2610 < version2621)
     48         assert(version2610 < version2700)
     49 
     50         assert(version2611 < version2620)
     51         assert(version2611 < version2621)
     52         assert(version2611 < version2700)
     53 
     54         assert(version2700 > version2600)
     55         assert(version2700 > version2700SNAPSHOT)
     56         assert(version2700SNAPSHOT < version2700)
     57 
     58         assert(version2700TNAPSHOT > version2700SNAPSHOT)
     59         assert(version2700SNAPSHOT < version2700TNAPSHOT)
     60     }
     61 }