Package org.nutz.lang.segment

Examples of org.nutz.lang.segment.Segment.keys()


  public void testNormal() {
    Segment seg = Segments.create("H${4}B");
    seg.set("4", "zzh");
    assertEquals("H${4}B", seg.getOrginalString());
    assertEquals("HzzhB", seg.toString());
    assertEquals(1, seg.keys().size());
    assertEquals(3, seg.values().size());
  }

  @Test
  public void testWrongPPname() {
View Full Code Here


    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());
  }

  @Test(expected = RuntimeException.class)
  public void testLackRightBracket() {
View Full Code Here

  @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());
  }

  @Test
  public void testEscapeChar() {
View Full Code Here

  @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());
  }

  @Test
  public void testEscapeChar2() {
View Full Code Here

  @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());
  }

  @Test
  public void testAtTheBegin() {
View Full Code Here

  @Test
  public void testAtTheBegin() {
    Segment seg = Segments.create("${4}B");
    seg.set("4", "zzh");
    assertEquals("zzhB", seg.toString());
    assertEquals(1, seg.keys().size());
    assertEquals(2, seg.values().size());
  }

  @Test
  public void testTwoPoints() {
View Full Code Here

  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());
  }

  @Test
  public void testTwoSamePoints() {
View Full Code Here

  @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());
  }

  @Test
  public void testThreePoints() {
View Full Code Here

  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());
  }

  @Test
  public void testClearAll() {
View Full Code Here

  }

  @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());
  }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.