Search in sources :

Example 1 with Segment

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

the class CharSegmentTest method testWrongPPname.

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

Example 2 with Segment

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

the class CharSegmentTest method testAddPP2.

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

Example 3 with Segment

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

the class CharSegmentTest method testChineseChar.

@Test
public void testChineseChar() {
    String s = new StringBuilder().append((char) Integer.parseInt("6211", 16)).toString();
    Segment seg = Segments.create(s);
    assertTrue(s.equals(seg.toString()));
}
Also used : CharSegment(org.nutz.lang.segment.CharSegment) Segment(org.nutz.lang.segment.Segment) Test(org.junit.Test)

Example 4 with Segment

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

the class CharSegmentTest method testEscapeChar3.

@Test
public void testEscapeChar3() {
    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)

Example 5 with Segment

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

the class CharSegmentTest method test_blankKeys.

public void test_blankKeys() {
    Segment seg = Segments.create("1${A}2${B}3${C}4${D}5");
    // assertEquals(4, seg.blankKeys().size());
    seg.set("A", 34);
    seg.set("D", "GG");
// assertEquals(2, seg.blankKeys().size());
}
Also used : CharSegment(org.nutz.lang.segment.CharSegment) Segment(org.nutz.lang.segment.Segment)

Aggregations

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