• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java IteratorTester类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.google.common.collect.testing.IteratorTester的典型用法代码示例。如果您正苦于以下问题:Java IteratorTester类的具体用法?Java IteratorTester怎么用?Java IteratorTester使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IteratorTester类属于com.google.common.collect.testing包,在下文中一共展示了IteratorTester类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testFilterUsingIteratorTester

import com.google.common.collect.testing.IteratorTester; //导入依赖的package包/类
@GwtIncompatible // unreasonably slow
public void testFilterUsingIteratorTester() {
  final List<Integer> list = asList(1, 2, 3, 4, 5);
  final Predicate<Integer> isEven = new Predicate<Integer>() {
    @Override
    public boolean apply(Integer integer) {
      return integer % 2 == 0;
    }
  };
  new IteratorTester<Integer>(5, UNMODIFIABLE, asList(2, 4),
      IteratorTester.KnownOrder.KNOWN_ORDER) {
    @Override protected Iterator<Integer> newTargetIterator() {
      return Iterators.filter(list.iterator(), isEven);
    }
  }.test();
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:17,代码来源:IteratorsTest.java


示例2: runIterator

import com.google.common.collect.testing.IteratorTester; //导入依赖的package包/类
private <T extends Comparable<T>> void runIterator(
    final List<T> values, int steps) throws Exception {
  IteratorTester<T> tester =
      new IteratorTester<T>(
          steps,
          IteratorFeature.MODIFIABLE,
          Lists.newLinkedList(values),
          IteratorTester.KnownOrder.UNKNOWN_ORDER) {
        private MinMaxPriorityQueue<T> mmHeap;
        @Override protected Iterator<T> newTargetIterator() {
          mmHeap = MinMaxPriorityQueue.create(values);
          return mmHeap.iterator();
        }
        @Override protected void verify(List<T> elements) {
          assertEquals(Sets.newHashSet(elements),
              Sets.newHashSet(mmHeap.iterator()));
          assertTrue("Invalid MinMaxHeap: " + mmHeap, mmHeap.isIntact());
        }
      };
  tester.test();
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:22,代码来源:MinMaxPriorityQueueTest.java


示例3: testAsList1Small

import com.google.common.collect.testing.IteratorTester; //导入依赖的package包/类
public void testAsList1Small() {
  List<String> list = Lists.asList("foo", new String[0]);
  assertThat(list).contains("foo");
  assertEquals(1, list.size());
  assertIndexIsOutOfBounds(list, -1);
  assertEquals("foo", list.get(0));
  assertIndexIsOutOfBounds(list, 1);
  assertTrue(list instanceof RandomAccess);

  new IteratorTester<String>(3, UNMODIFIABLE, singletonList("foo"),
      IteratorTester.KnownOrder.KNOWN_ORDER) {
    @Override protected Iterator<String> newTargetIterator() {
      return Lists.asList("foo", new String[0]).iterator();
    }
  }.test();
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:17,代码来源:ListsTest.java


示例4: testAsList2Small

import com.google.common.collect.testing.IteratorTester; //导入依赖的package包/类
@GwtIncompatible // SerializableTester
public void testAsList2Small() {
  List<String> list = Lists.asList("foo", "bar", new String[0]);
  assertThat(list).containsExactly("foo", "bar").inOrder();
  assertEquals(2, list.size());
  assertIndexIsOutOfBounds(list, -1);
  assertEquals("foo", list.get(0));
  assertEquals("bar", list.get(1));
  assertIndexIsOutOfBounds(list, 2);
  SerializableTester.reserializeAndAssert(list);
  assertTrue(list instanceof RandomAccess);

  new IteratorTester<String>(5, UNMODIFIABLE, asList("foo", "bar"),
      IteratorTester.KnownOrder.KNOWN_ORDER) {
    @Override protected Iterator<String> newTargetIterator() {
      return Lists.asList("foo", "bar", new String[0]).iterator();
    }
  }.test();
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:20,代码来源:ListsTest.java


示例5: testGetIteration

import com.google.common.collect.testing.IteratorTester; //导入依赖的package包/类
@GwtIncompatible // unreasonably slow
public void testGetIteration() {
  new IteratorTester<Integer>(6, MODIFIABLE,
      newLinkedHashSet(asList(2, 3, 4, 7, 8)),
      IteratorTester.KnownOrder.KNOWN_ORDER) {
    private Multimap<String, Integer> multimap;

    @Override protected Iterator<Integer> newTargetIterator() {
      multimap = LinkedHashMultimap.create();
      multimap.putAll("foo", asList(2, 3, 4));
      multimap.putAll("bar", asList(5, 6));
      multimap.putAll("foo", asList(7, 8));
      return multimap.get("foo").iterator();
    }

    @Override protected void verify(List<Integer> elements) {
      assertEquals(newHashSet(elements), multimap.get("foo"));
    }
  }.test();
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:21,代码来源:LinkedHashMultimapTest.java


示例6: testKeysIteration

import com.google.common.collect.testing.IteratorTester; //导入依赖的package包/类
@GwtIncompatible // unreasonably slow
public void testKeysIteration() {
  new IteratorTester<String>(6, MODIFIABLE, newArrayList("foo", "foo", "bar",
      "bar", "foo"), IteratorTester.KnownOrder.KNOWN_ORDER) {
    private Multimap<String, Integer> multimap;

    @Override protected Iterator<String> newTargetIterator() {
      multimap = LinkedHashMultimap.create();
      multimap.putAll("foo", asList(2, 3));
      multimap.putAll("bar", asList(4, 5));
      multimap.putAll("foo", asList(6));
      return multimap.keys().iterator();
    }

    @Override protected void verify(List<String> elements) {
      assertEquals(elements, Lists.newArrayList(multimap.keys()));
    }
  }.test();
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:20,代码来源:LinkedHashMultimapTest.java


示例7: testValuesIteration

import com.google.common.collect.testing.IteratorTester; //导入依赖的package包/类
@GwtIncompatible // unreasonably slow
public void testValuesIteration() {
  new IteratorTester<Integer>(6, MODIFIABLE, newArrayList(2, 3, 4, 5, 6),
      IteratorTester.KnownOrder.KNOWN_ORDER) {
    private Multimap<String, Integer> multimap;

    @Override protected Iterator<Integer> newTargetIterator() {
      multimap = LinkedHashMultimap.create();
      multimap.putAll("foo", asList(2, 3));
      multimap.putAll("bar", asList(4, 5));
      multimap.putAll("foo", asList(6));
      return multimap.values().iterator();
    }

    @Override protected void verify(List<Integer> elements) {
      assertEquals(elements, Lists.newArrayList(multimap.values()));
    }
  }.test();
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:20,代码来源:LinkedHashMultimapTest.java


示例8: testKeySetIteration

import com.google.common.collect.testing.IteratorTester; //导入依赖的package包/类
@GwtIncompatible // unreasonably slow
public void testKeySetIteration() {
  new IteratorTester<String>(6, MODIFIABLE,
      newLinkedHashSet(asList("foo", "bar", "baz", "dog", "cat")),
      IteratorTester.KnownOrder.KNOWN_ORDER) {
    private Multimap<String, Integer> multimap;

    @Override protected Iterator<String> newTargetIterator() {
      multimap = LinkedHashMultimap.create();
      multimap.putAll("foo", asList(2, 3));
      multimap.putAll("bar", asList(4, 5));
      multimap.putAll("foo", asList(6));
      multimap.putAll("baz", asList(7, 8));
      multimap.putAll("dog", asList(9));
      multimap.putAll("bar", asList(10, 11));
      multimap.putAll("cat", asList(12, 13, 14));
      return multimap.keySet().iterator();
    }

    @Override protected void verify(List<String> elements) {
      assertEquals(newHashSet(elements), multimap.keySet());
    }
  }.test();
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:25,代码来源:LinkedHashMultimapTest.java


示例9: testKeysIteration

import com.google.common.collect.testing.IteratorTester; //导入依赖的package包/类
@GwtIncompatible // unreasonably slow
public void testKeysIteration() {
  new IteratorTester<String>(6, MODIFIABLE, newArrayList("foo", "foo", "bar",
      "bar", "foo"), IteratorTester.KnownOrder.KNOWN_ORDER) {
    private Multimap<String, Integer> multimap;

    @Override protected Iterator<String> newTargetIterator() {
      multimap = create();
      multimap.putAll("foo", asList(2, 3));
      multimap.putAll("bar", asList(4, 5));
      multimap.putAll("foo", asList(6));
      return multimap.keys().iterator();
    }

    @Override protected void verify(List<String> elements) {
      assertEquals(elements, Lists.newArrayList(multimap.keys()));
    }
  }.test();
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:20,代码来源:LinkedListMultimapTest.java


示例10: testKeySetIteration

import com.google.common.collect.testing.IteratorTester; //导入依赖的package包/类
@GwtIncompatible // unreasonably slow
public void testKeySetIteration() {
  new IteratorTester<String>(6, MODIFIABLE, newLinkedHashSet(asList(
      "foo", "bar", "baz", "dog", "cat")),
      IteratorTester.KnownOrder.KNOWN_ORDER) {
    private Multimap<String, Integer> multimap;

    @Override protected Iterator<String> newTargetIterator() {
      multimap = create();
      multimap.putAll("foo", asList(2, 3));
      multimap.putAll("bar", asList(4, 5));
      multimap.putAll("foo", asList(6));
      multimap.putAll("baz", asList(7, 8));
      multimap.putAll("dog", asList(9));
      multimap.putAll("bar", asList(10, 11));
      multimap.putAll("cat", asList(12, 13, 14));
      return multimap.keySet().iterator();
    }

    @Override protected void verify(List<String> elements) {
      assertEquals(newHashSet(elements), multimap.keySet());
    }
  }.test();
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:25,代码来源:LinkedListMultimapTest.java


示例11: testForMapGetIteration

import com.google.common.collect.testing.IteratorTester; //导入依赖的package包/类
public void testForMapGetIteration() {
  IteratorTester<Integer> tester =
      new IteratorTester<Integer>(4, MODIFIABLE, newHashSet(1),
          IteratorTester.KnownOrder.KNOWN_ORDER) {
        private Multimap<String, Integer> multimap;

        @Override protected Iterator<Integer> newTargetIterator() {
          Map<String, Integer> map = Maps.newHashMap();
          map.put("foo", 1);
          map.put("bar", 2);
          multimap = Multimaps.forMap(map);
          return multimap.get("foo").iterator();
        }

        @Override protected void verify(List<Integer> elements) {
          assertEquals(newHashSet(elements), multimap.get("foo"));
        }
      };

  tester.test();
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:22,代码来源:MultimapsTest.java


示例12: testPowerSetIteration_iteratorTester

import com.google.common.collect.testing.IteratorTester; //导入依赖的package包/类
@GwtIncompatible // too slow for GWT
public void testPowerSetIteration_iteratorTester() {
  ImmutableSet<Integer> elements = ImmutableSet.of(1, 2);

  Set<Set<Integer>> expected = newLinkedHashSet();
  expected.add(ImmutableSet.<Integer>of());
  expected.add(ImmutableSet.of(1));
  expected.add(ImmutableSet.of(2));
  expected.add(ImmutableSet.of(1, 2));

  final Set<Set<Integer>> powerSet = powerSet(elements);
  new IteratorTester<Set<Integer>>(6, UNMODIFIABLE, expected, KNOWN_ORDER) {
    @Override protected Iterator<Set<Integer>> newTargetIterator() {
      return powerSet.iterator();
    }
  }.test();
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:18,代码来源:SetsTest.java


示例13: testPowerSetIteration_iteratorTester_fast

import com.google.common.collect.testing.IteratorTester; //导入依赖的package包/类
public void testPowerSetIteration_iteratorTester_fast() {
  ImmutableSet<Integer> elements = ImmutableSet.of(1, 2);

  Set<Set<Integer>> expected = newLinkedHashSet();
  expected.add(ImmutableSet.<Integer>of());
  expected.add(ImmutableSet.of(1));
  expected.add(ImmutableSet.of(2));
  expected.add(ImmutableSet.of(1, 2));

  final Set<Set<Integer>> powerSet = powerSet(elements);
  new IteratorTester<Set<Integer>>(4, UNMODIFIABLE, expected, KNOWN_ORDER) {
    @Override protected Iterator<Set<Integer>> newTargetIterator() {
      return powerSet.iterator();
    }
  }.test();
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:17,代码来源:SetsTest.java


示例14: testPowerSetIteration_iteratorTester

import com.google.common.collect.testing.IteratorTester; //导入依赖的package包/类
public void testPowerSetIteration_iteratorTester() {
  ImmutableSet<Integer> elements = ImmutableSet.of(1, 2);

  Set<Set<Integer>> expected = new LinkedHashSet<Set<Integer>>();
  expected.add(ImmutableSet.<Integer>of());
  expected.add(ImmutableSet.of(1));
  expected.add(ImmutableSet.of(2));
  expected.add(ImmutableSet.of(1, 2));

  final Set<Set<Integer>> powerSet = powerSet(elements);
  new IteratorTester<Set<Integer>>(6, UNMODIFIABLE, expected, KNOWN_ORDER) {
    @Override protected Iterator<Set<Integer>> newTargetIterator() {
      return powerSet.iterator();
    }
  }.test();
}
 
开发者ID:ypresto,项目名称:miniguava,代码行数:17,代码来源:SetsTest.java


示例15: testPowerSetIteration_iteratorTester_fast

import com.google.common.collect.testing.IteratorTester; //导入依赖的package包/类
public void testPowerSetIteration_iteratorTester_fast() {
  ImmutableSet<Integer> elements = ImmutableSet.of(1, 2);

  Set<Set<Integer>> expected = new LinkedHashSet<Set<Integer>>();
  expected.add(ImmutableSet.<Integer>of());
  expected.add(ImmutableSet.of(1));
  expected.add(ImmutableSet.of(2));
  expected.add(ImmutableSet.of(1, 2));

  final Set<Set<Integer>> powerSet = powerSet(elements);
  new IteratorTester<Set<Integer>>(4, UNMODIFIABLE, expected, KNOWN_ORDER) {
    @Override protected Iterator<Set<Integer>> newTargetIterator() {
      return powerSet.iterator();
    }
  }.test();
}
 
开发者ID:ypresto,项目名称:miniguava,代码行数:17,代码来源:SetsTest.java


示例16: testFilterUsingIteratorTester

import com.google.common.collect.testing.IteratorTester; //导入依赖的package包/类
@GwtIncompatible("unreasonably slow")
public void testFilterUsingIteratorTester() {
  final List<Integer> list = asList(1, 2, 3, 4, 5);
  final Predicate<Integer> isEven = new Predicate<Integer>() {
    @Override
    public boolean apply(Integer integer) {
      return integer % 2 == 0;
    }
  };
  new IteratorTester<Integer>(5, UNMODIFIABLE, asList(2, 4),
      IteratorTester.KnownOrder.KNOWN_ORDER) {
    @Override protected Iterator<Integer> newTargetIterator() {
      return Iterators.filter(list.iterator(), isEven);
    }
  }.test();
}
 
开发者ID:sander120786,项目名称:guava-libraries,代码行数:17,代码来源:IteratorsTest.java


示例17: testAsList2Small

import com.google.common.collect.testing.IteratorTester; //导入依赖的package包/类
@GwtIncompatible("SerializableTester")
public void testAsList2Small() {
  List<String> list = Lists.asList("foo", "bar", new String[0]);
  assertThat(list).containsExactly("foo", "bar").inOrder();
  assertEquals(2, list.size());
  assertIndexIsOutOfBounds(list, -1);
  assertEquals("foo", list.get(0));
  assertEquals("bar", list.get(1));
  assertIndexIsOutOfBounds(list, 2);
  SerializableTester.reserializeAndAssert(list);
  assertTrue(list instanceof RandomAccess);

  new IteratorTester<String>(5, UNMODIFIABLE, asList("foo", "bar"),
      IteratorTester.KnownOrder.KNOWN_ORDER) {
    @Override protected Iterator<String> newTargetIterator() {
      return Lists.asList("foo", "bar", new String[0]).iterator();
    }
  }.test();
}
 
开发者ID:sander120786,项目名称:guava-libraries,代码行数:20,代码来源:ListsTest.java


示例18: testGetIteration

import com.google.common.collect.testing.IteratorTester; //导入依赖的package包/类
@GwtIncompatible("unreasonably slow")
public void testGetIteration() {
  new IteratorTester<Integer>(6, MODIFIABLE,
      newLinkedHashSet(asList(2, 3, 4, 7, 8)),
      IteratorTester.KnownOrder.KNOWN_ORDER) {
    private Multimap<String, Integer> multimap;

    @Override protected Iterator<Integer> newTargetIterator() {
      multimap = LinkedHashMultimap.create();
      multimap.putAll("foo", asList(2, 3, 4));
      multimap.putAll("bar", asList(5, 6));
      multimap.putAll("foo", asList(7, 8));
      return multimap.get("foo").iterator();
    }

    @Override protected void verify(List<Integer> elements) {
      assertEquals(newHashSet(elements), multimap.get("foo"));
    }
  }.test();
}
 
开发者ID:sander120786,项目名称:guava-libraries,代码行数:21,代码来源:LinkedHashMultimapTest.java


示例19: testKeysIteration

import com.google.common.collect.testing.IteratorTester; //导入依赖的package包/类
@GwtIncompatible("unreasonably slow")
public void testKeysIteration() {
  new IteratorTester<String>(6, MODIFIABLE, newArrayList("foo", "foo", "bar",
      "bar", "foo"), IteratorTester.KnownOrder.KNOWN_ORDER) {
    private Multimap<String, Integer> multimap;

    @Override protected Iterator<String> newTargetIterator() {
      multimap = LinkedHashMultimap.create();
      multimap.putAll("foo", asList(2, 3));
      multimap.putAll("bar", asList(4, 5));
      multimap.putAll("foo", asList(6));
      return multimap.keys().iterator();
    }

    @Override protected void verify(List<String> elements) {
      assertEquals(elements, Lists.newArrayList(multimap.keys()));
    }
  }.test();
}
 
开发者ID:sander120786,项目名称:guava-libraries,代码行数:20,代码来源:LinkedHashMultimapTest.java


示例20: testValuesIteration

import com.google.common.collect.testing.IteratorTester; //导入依赖的package包/类
@GwtIncompatible("unreasonably slow")
public void testValuesIteration() {
  new IteratorTester<Integer>(6, MODIFIABLE, newArrayList(2, 3, 4, 5, 6),
      IteratorTester.KnownOrder.KNOWN_ORDER) {
    private Multimap<String, Integer> multimap;

    @Override protected Iterator<Integer> newTargetIterator() {
      multimap = LinkedHashMultimap.create();
      multimap.putAll("foo", asList(2, 3));
      multimap.putAll("bar", asList(4, 5));
      multimap.putAll("foo", asList(6));
      return multimap.values().iterator();
    }

    @Override protected void verify(List<Integer> elements) {
      assertEquals(elements, Lists.newArrayList(multimap.values()));
    }
  }.test();
}
 
开发者ID:sander120786,项目名称:guava-libraries,代码行数:20,代码来源:LinkedHashMultimapTest.java



注:本文中的com.google.common.collect.testing.IteratorTester类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PBES2Parameters类代码示例发布时间:2022-05-22
下一篇:
Java DataSource类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap