Search in sources :

Example 6 with Segment

use of org.nutz.lang.segment.Segment in project nutz by nutzam.

the class CharSegmentTest method testTwoSamePoints.

@Test
public void testTwoSamePoints() {
    Segment seg = Segments.create("A${1}B${1}C");
    seg.set("1", "$p1");
    assertEquals("A$p1B$p1C", seg.toString());
    assertEquals(1, seg.keys().size());
    assertEquals(5, seg.values().size());
}
Also used : CharSegment(org.nutz.lang.segment.CharSegment) Segment(org.nutz.lang.segment.Segment) Test(org.junit.Test)

Example 7 with Segment

use of org.nutz.lang.segment.Segment in project nutz by nutzam.

the class CharSegmentTest method testAddPP3.

@Test
public void testAddPP3() {
    Segment seg = Segments.create("-${A}-${B}-");
    Segment sub = Segments.create("[${V}]");
    Segment sub2 = Segments.create("%${V}%");
    seg.add("A", sub);
    seg.add("A", sub2);
    seg.set("B", "***");
    sub.set("V", "#");
    sub2.set("V", "@");
    assertEquals("-[#]%@%-***-", seg.toString());
    seg.set("B", "ZZH");
    assertEquals("-[#]%@%-ZZH-", seg.toString());
}
Also used : CharSegment(org.nutz.lang.segment.CharSegment) Segment(org.nutz.lang.segment.Segment) Test(org.junit.Test)

Example 8 with Segment

use of org.nutz.lang.segment.Segment in project nutz by nutzam.

the class CharSegmentTest method testClearAll.

@Test
public void testClearAll() {
    Segment seg = Segments.create("A${1}B${1}C${2}D");
    seg.set("1", "T1");
    seg.set("2", "T2");
    seg.clearAll();
    assertEquals("ABCD", seg.toString());
}
Also used : CharSegment(org.nutz.lang.segment.CharSegment) Segment(org.nutz.lang.segment.Segment) Test(org.junit.Test)

Example 9 with Segment

use of org.nutz.lang.segment.Segment in project nutz by nutzam.

the class CharSegmentTest method testAtTheEnd.

@Test
public void testAtTheEnd() {
    Segment seg = Segments.create("H${4}");
    seg.set("4", "zzh");
    assertEquals("Hzzh", seg.toString());
    assertEquals(1, seg.keys().size());
    assertEquals(2, seg.values().size());
}
Also used : CharSegment(org.nutz.lang.segment.CharSegment) Segment(org.nutz.lang.segment.Segment) Test(org.junit.Test)

Example 10 with Segment

use of org.nutz.lang.segment.Segment in project nutz by nutzam.

the class CharSegmentTest method testEscapeChar2.

@Test
public void testEscapeChar2() {
    Segment seg = Segments.create("H$$$4}B");
    assertEquals("H$$4}B", seg.toString());
}
Also used : CharSegment(org.nutz.lang.segment.CharSegment) Segment(org.nutz.lang.segment.Segment) Test(org.junit.Test)

Aggregations

CharSegment (org.nutz.lang.segment.CharSegment)22 Segment (org.nutz.lang.segment.Segment)22 Test (org.junit.Test)21