Search in sources :

Example 11 with Segment

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

the class CharSegmentTest method testThreePoints.

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

Example 12 with Segment

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

the class CharSegmentTest method testClone.

@Test
public void testClone() {
    Segment seg = Segments.create("A${a}B");
    seg.set("a", "A");
    assertEquals("AAB", seg.toString());
    Segment seg2 = (CharSegment) seg.clone();
    seg.set("a", "FF");
    assertEquals("AAB", seg2.toString());
    assertEquals("AFFB", seg.toString());
}
Also used : CharSegment(org.nutz.lang.segment.CharSegment) CharSegment(org.nutz.lang.segment.CharSegment) Segment(org.nutz.lang.segment.Segment) Test(org.junit.Test)

Example 13 with Segment

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

the class CharSegmentTest method testLackLeftBracket.

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

Example 14 with Segment

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

the class CharSegmentTest method testCloseDynamicMark_E1.

@Test
public void testCloseDynamicMark_E1() {
    Segment seg = Segments.create("A${1}}}B");
    seg.set("1", "T1");
    assertEquals("AT1}}B", seg.toString());
}
Also used : CharSegment(org.nutz.lang.segment.CharSegment) Segment(org.nutz.lang.segment.Segment) Test(org.junit.Test)

Example 15 with Segment

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

the class CharSegmentTest method testEscapeChar.

@Test
public void testEscapeChar() {
    Segment seg = Segments.create("H$$4}B");
    assertEquals("H$4}B", seg.toString());
    assertEquals(0, seg.keys().size());
    assertEquals(1, seg.values().size());
}
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