package cn.sagacloud.server.algorithm.test

import org.junit.Test
import java.lang.StringBuilder
import java.util.regex.Pattern

/**
 *
 *
 * @author jxing
 */
class RegexTest {
    val floorNamePattern = "^([F|B][1-9][0-9]{0,4}|RF)(M([1-9][0-9]{0,4})?)?\$"

    @Test
    fun range(){
        val s1 = "B1"
        val s2 = "B1fd"
        val s3 = "B1M"
        val s4 = "N1"
        val s5 = "F10M2"
        val s6 = "F10N2"

        println(Pattern.matches(floorNamePattern, s1))
        println(Pattern.matches(floorNamePattern, s2))
        println(Pattern.matches(floorNamePattern, s3))
        println(Pattern.matches(floorNamePattern, s4))
        println(Pattern.matches(floorNamePattern, s5))
        println(Pattern.matches(floorNamePattern, s6))

    }

    var out : StringBuilder? = null

    @Test
    fun test2(){
        out = StringBuilder()
        if(out == null) {
            return
        }
        out = out!!
        if(out!= null)
            out!!.append("")
    }


    @Test
    fun test1(){
        var inside : StringBuilder? = null
        inside = StringBuilder()
        inside.append("")
        if(inside == null) {
            return
        }
        inside = inside!!
        if(inside!= null)
            inside.append("")
    }


}