有没有Java自定义集合实现的测试? [英] Is there a testsuite for Java custom collections implementation?

查看:166
本文介绍了有没有Java自定义集合实现的测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

出于好奇,我写了一个自己的简单实现 Set 一个特殊情况(其中所有可能的条目的集合是固定的,但它不是 enum )。它实际上很容易,但显然,我的实现是不可用的没有很多的测试(也许,甚至那么,但这是另一个主题;它主要是一个练习)。

Out of curiosity, I wrote an own simple implementation of Set for a special case (where the set of all possible entries is fixed, but it's no enum). It was actually quite easy, but obviously, my implementation is unusable without a lot of tests (and maybe even then, but that's another topic; it was mainly an exercise).

推荐答案

使用Guava SetTestSuiteBuilder

https://code.google.com/p/guava-libraries/source/browse/guava-testlib/src /com/google/common/collect/testing/SetTestSuiteBuilder.java

示例:

http://code.google.com/p/guava-libraries/source/browse/guava-testlib/src/com/google/common/collect/testing/TestsForSetsInJavaUtil.java

它在maven central中作为guava-testlib的一部分发布。

It is released as part of "guava-testlib" in maven central.

这篇关于有没有Java自定义集合实现的测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆