Search in sources :

Example 16 with Segment

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

the class CharSegmentTest method testTwoPoints.

@Test
public void testTwoPoints() {
    Segment seg = Segments.create("A${1}B${2}C");
    seg.set("1", "$p1");
    seg.set("2", "$p2");
    assertEquals("A$p1B$p2C", seg.toString());
    assertEquals(2, 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 17 with Segment

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

the class CharSegmentTest method testAddPP1.

@Test
public void testAddPP1() {
    Segment seg = Segments.create("-${A}-");
    seg.add("A", "A");
    seg.add("A", "B");
    seg.add("A", "C");
    assertEquals("-ABC-", seg.toString());
    seg.set("A", "HH");
    assertEquals("-HH-", seg.toString());
}
Also used : CharSegment(org.nutz.lang.segment.CharSegment) Segment(org.nutz.lang.segment.Segment) Test(org.junit.Test)

Example 18 with Segment

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

the class CharSegmentTest method testKeys.

@Test
public void testKeys() {
    Segment seg = Segments.create("-${A}-${B}-${A}-${B}-");
    assertEquals(2, seg.keys().size());
    seg.set("A", "[a]");
    seg.set("B", "[b]");
    assertEquals("-[a]-[b]-[a]-[b]-", seg.toString());
}
Also used : CharSegment(org.nutz.lang.segment.CharSegment) Segment(org.nutz.lang.segment.Segment) Test(org.junit.Test)

Example 19 with Segment

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

the class CharSegmentTest method testBorn.

@Test
public void testBorn() {
    Segment seg = Segments.create("A${a}B");
    seg.set("a", "A");
    assertEquals("AAB", seg.toString());
    Segment seg2 = (CharSegment) seg.born();
    assertEquals("AB", seg2.toString());
    assertEquals("AAB", 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 20 with Segment

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

the class CharSegmentTest method testTrueFalse.

@Test
public void testTrueFalse() {
    Segment seg = Segments.create("true:[${true}]\tfalse:[${false}]");
    seg.set("true", true);
    seg.set("false", false);
    assertEquals("true:[true]\tfalse:[false]", 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