package com.github.jsonzou.jmockdata;

import com.github.jsonzou.jmockdata.util.RandomUtils;
import org.junit.Test;

import static org.junit.Assert.assertTrue;

/**
 * @Author: jsonzou
 * @Date: 2018/12/29 13:05
 * @Description:
 */
public class RegexGeneratorTest {
    @Test
    public void should1Email() {
        String regex = "[a-z0-9]{5,15}\\@\\w{3,5}\\.[a-z]{2,3}";
        for (int i = 0; i < 100; i++) {
            String text = RandomUtils.nextStringFromRegex(regex);
            System.out.println(text);
            assertTrue(text.matches(regex));
        }
    }
    @Test
    public void shouldNumber() {
        String regex = "[0-9]{3,5}\\.[0-9]{2}";
        for (int i = 0; i < 100; i++) {
            String text = RandomUtils.nextStringFromRegex(regex);
            System.out.println(text);
            assertTrue(text.matches(regex));
        }
    }

    @Test
    public void shouldNumber2() {
        String regex = "\\d+\\.\\d+";
        for (int i = 0; i < 100; i++) {
            String text =  RandomUtils.nextStringFromRegex(regex);
            System.out.println(text);
            assertTrue(text.matches(regex));
        }
    }

    @Test
    public void shouldGPS() {
        String regex = "([0-9]{3}\\.[0-9]{3}\\,[0-9]{3}\\.[0-9]{3})";
        for (int i = 0; i < 100; i++) {
            String text =  RandomUtils.nextStringFromRegex(regex);
            System.out.println(text);
            assertTrue(text.matches(regex));
        }
    }

    @Test
    public void shouldAllPattern() {
        String regex = "[a-z]{2}-[0-9]{2}-[abc123]{2}-\\w{2}-\\d{2}@\\s{1}-\\S{1}\\.?-.";
        for (int i = 0; i < 100; i++) {
            String text = RandomUtils.nextStringFromRegex(regex);
            System.out.println(text);
            assertTrue(text.matches(regex));
        }
    }

}

@@ -1817,12 +1817,322 @@
  %7D%0A    %7D
+%0A    @Test%0A    public void shouldAllPattern2() %7B%0A        String regex = %22%5Ba-z%5D%7B2%7D%5C%5C.%5B0-9%5D%7B2%7D%5C%5C.%5BA-Z%5D%7B2%7D%22;%0A        for (int i = 0; i %3C 100; i++) %7B%0A            String text = RandomUtils.nextStringFromRegex(regex);%0A            System.out.println(text);%0A            assertTrue(text.matches(regex));%0A        %7D%0A    %7D
 %0A%0A%7D%0A

Add tests of [a-z][0-9][A-Z]