Small Fixes to doc and Useless Imports
This commit is contained in:
parent
4dd3a4a6e8
commit
ed9ce60af4
|
@ -1,270 +1,270 @@
|
|||
package speiger.src.builder;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.StringJoiner;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import speiger.src.builder.modules.AsyncModule;
|
||||
import speiger.src.builder.modules.BaseModule;
|
||||
import speiger.src.builder.modules.CollectionModule;
|
||||
import speiger.src.builder.modules.FunctionModule;
|
||||
import speiger.src.builder.modules.JavaModule;
|
||||
import speiger.src.builder.modules.ListModule;
|
||||
import speiger.src.builder.modules.MapModule;
|
||||
import speiger.src.builder.modules.PairModule;
|
||||
import speiger.src.builder.modules.PrioQueueModule;
|
||||
import speiger.src.builder.modules.SetModule;
|
||||
import speiger.src.builder.processor.TemplateProcess;
|
||||
import speiger.src.builder.processor.TemplateProcessor;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public class PrimitiveCollectionsBuilder extends TemplateProcessor
|
||||
{
|
||||
private static final int SPECIAL = 0x1; //Detects if the Builder is generating tests
|
||||
private static final int LOAD = 0x2; //If Configs should be loaded
|
||||
private static final int ANTI_SAVE = SPECIAL | LOAD; //If save should be disabled since load/save shouldn't happen at the same time.
|
||||
private static final int SAVE = 0x4; //if the configuration should be created
|
||||
Set<String> globalFlags = new HashSet<>();
|
||||
List<ModulePackage> simplePackages = new ArrayList<>();
|
||||
List<ModulePackage> biPackages = new ArrayList<>();
|
||||
List<ModulePackage> enumPackages = new ArrayList<>();
|
||||
Map<String, RequiredType> requirements = new HashMap<>();
|
||||
SettingsManager manager = new SettingsManager();
|
||||
int flags;
|
||||
|
||||
public PrimitiveCollectionsBuilder()
|
||||
{
|
||||
this(false);
|
||||
}
|
||||
|
||||
public PrimitiveCollectionsBuilder(boolean silencedSuccess)
|
||||
{
|
||||
super(silencedSuccess, Paths.get("src/builder/resources/speiger/assets/collections/templates/"), Paths.get("src/main/java/speiger/src/collections/"), Paths.get("src/builder/resources/speiger/assets/collections/"));
|
||||
}
|
||||
|
||||
public PrimitiveCollectionsBuilder(Path sourceFolder, Path outputFolder, Path dataFolder)
|
||||
{
|
||||
this(false, sourceFolder, outputFolder, dataFolder);
|
||||
}
|
||||
|
||||
public PrimitiveCollectionsBuilder(boolean silencedSuccess, Path sourceFolder, Path outputFolder, Path dataFolder)
|
||||
{
|
||||
super(silencedSuccess, sourceFolder, outputFolder, dataFolder);
|
||||
}
|
||||
|
||||
private PrimitiveCollectionsBuilder setFlags(int flags) {
|
||||
this.flags = flags;
|
||||
if((flags & ANTI_SAVE) != 0) {
|
||||
this.flags &= ~SAVE;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
private static PrimitiveCollectionsBuilder createTests(boolean silent, int flags) {
|
||||
return new PrimitiveCollectionsBuilder(silent,
|
||||
Paths.get("src/builder/resources/speiger/assets/tests/templates/"),
|
||||
Paths.get("src/test/java/speiger/src/tests/"),
|
||||
Paths.get("src/builder/resources/speiger/assets/tests/")).setFlags(flags | SPECIAL);
|
||||
}
|
||||
|
||||
private static PrimitiveCollectionsBuilder createTesters(boolean silent, int flags) {
|
||||
return new PrimitiveCollectionsBuilder(silent,
|
||||
Paths.get("src/builder/resources/speiger/assets/testers/templates/"),
|
||||
Paths.get("src/test/java/speiger/src/testers/"),
|
||||
Paths.get("src/builder/resources/speiger/assets/testers/")).setFlags(flags | SPECIAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isFileValid(Path fileName)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean relativePackages()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean debugUnusedMappers()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void afterFinish()
|
||||
{
|
||||
if((flags & SPECIAL) == 0 && getVersion() > 8)
|
||||
{
|
||||
Path basePath = Paths.get("src/main/java");
|
||||
try(BufferedWriter writer = Files.newBufferedWriter(basePath.resolve("module-info.java")))
|
||||
{
|
||||
writer.write(getModuleInfo(basePath));
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<BaseModule> createModules()
|
||||
{
|
||||
List<BaseModule> modules = new ArrayList<>();
|
||||
modules.add(JavaModule.INSTANCE);
|
||||
modules.add(FunctionModule.INSTANCE);
|
||||
modules.add(CollectionModule.INSTANCE);
|
||||
modules.add(PrioQueueModule.INSTANCE);
|
||||
modules.add(ListModule.INSTANCE);
|
||||
modules.add(SetModule.INSTANCE);
|
||||
modules.add(MapModule.INSTANCE);
|
||||
modules.add(PairModule.INSTANCE);
|
||||
modules.add(AsyncModule.INSTANCE);
|
||||
return modules;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void init()
|
||||
{
|
||||
prepPackages();
|
||||
//Init Modules here
|
||||
addModules(createModules());
|
||||
finishPackages();
|
||||
}
|
||||
|
||||
public void addModules(List<BaseModule> modules)
|
||||
{
|
||||
for(int i = 0,m=modules.size();i<m;i++) {
|
||||
modules.get(i).setManager(manager);
|
||||
}
|
||||
for(int i = 0,m=modules.size();i<m;i++) {
|
||||
biPackages.forEach(modules.get(i)::init);
|
||||
}
|
||||
for(int i = 0,m=modules.size();i<m;i++) {
|
||||
modules.get(i).cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
private void finishPackages()
|
||||
{
|
||||
biPackages.forEach(ModulePackage::finish);
|
||||
if((flags & SAVE) != 0) manager.save();
|
||||
}
|
||||
|
||||
private void prepPackages()
|
||||
{
|
||||
if((flags & LOAD) != 0) manager.load();
|
||||
for(ModulePackage entry : ModulePackage.createPackages(globalFlags))
|
||||
{
|
||||
entry.setRequirements(requirements::put);
|
||||
biPackages.add(entry);
|
||||
if(entry.isSame()) simplePackages.add(entry);
|
||||
if(entry.isEnumValid()) enumPackages.add(entry);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createProcesses(String fileName, Consumer<TemplateProcess> process)
|
||||
{
|
||||
List<ModulePackage> packages = getPackagesByRequirement(requirements.get(fileName));
|
||||
for(int i = 0,m=packages.size();i<m;i++)
|
||||
{
|
||||
packages.get(i).process(fileName, process);
|
||||
}
|
||||
}
|
||||
|
||||
protected List<ModulePackage> getPackagesByRequirement(RequiredType type) {
|
||||
if(type == null) return simplePackages;
|
||||
if(type == RequiredType.BI_CLASS) return biPackages;
|
||||
if(type == RequiredType.ENUM) return enumPackages;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
private String getModuleInfo(Path basePath) {
|
||||
StringJoiner joiner = new StringJoiner("\n", "", "\n");
|
||||
try(Stream<Path> stream = Files.walk(getOutputFolder()))
|
||||
{
|
||||
stream.filter(Files::isDirectory)
|
||||
.filter(this::containsFiles)
|
||||
.map(basePath::relativize)
|
||||
.map(Path::toString)
|
||||
.map(this::sanitize)
|
||||
.forEach(T -> joiner.add("\texports "+T+";"));
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("/** @author Speiger */\n");
|
||||
builder.append("module ").append(sanitize(basePath.relativize(getOutputFolder()).toString())).append(" {\n");
|
||||
builder.append(joiner.toString()).append("}");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
private String sanitize(String input)
|
||||
{
|
||||
return input.replace("\\", ".").replace("/", ".");
|
||||
}
|
||||
|
||||
private boolean containsFiles(Path path)
|
||||
{
|
||||
try(Stream<Path> stream = Files.walk(path, 1))
|
||||
{
|
||||
return stream.filter(Files::isRegularFile).findFirst().isPresent();
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private int getVersion()
|
||||
{
|
||||
String version = System.getProperty("java.version");
|
||||
if(version.startsWith("1.")) return Integer.parseInt(version.substring(2, 3));
|
||||
int dot = version.indexOf(".");
|
||||
return Integer.parseInt(dot != -1 ? version.substring(0, dot) : version);
|
||||
}
|
||||
|
||||
public static void main(String...args)
|
||||
{
|
||||
try
|
||||
{
|
||||
Set<String> flags = new HashSet<>(Arrays.asList(args));
|
||||
boolean silent = flags.contains("silent");
|
||||
boolean force = flags.contains("force");
|
||||
boolean tests = flags.contains("tests");
|
||||
boolean forceTests = flags.contains("force-tests");
|
||||
boolean load = flags.contains("load");
|
||||
boolean save = flags.contains("save");
|
||||
int flag = (load ? LOAD : 0) | (save ? SAVE : 0);
|
||||
new PrimitiveCollectionsBuilder(silent).setFlags(flag).process(force);
|
||||
if(tests) {
|
||||
createTests(silent, flag).process(force || forceTests);
|
||||
createTesters(silent, flag).process(force || forceTests);
|
||||
}
|
||||
}
|
||||
catch(InterruptedException | IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
package speiger.src.builder;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.StringJoiner;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import speiger.src.builder.modules.AsyncModule;
|
||||
import speiger.src.builder.modules.BaseModule;
|
||||
import speiger.src.builder.modules.CollectionModule;
|
||||
import speiger.src.builder.modules.FunctionModule;
|
||||
import speiger.src.builder.modules.JavaModule;
|
||||
import speiger.src.builder.modules.ListModule;
|
||||
import speiger.src.builder.modules.MapModule;
|
||||
import speiger.src.builder.modules.PairModule;
|
||||
import speiger.src.builder.modules.PrioQueueModule;
|
||||
import speiger.src.builder.modules.SetModule;
|
||||
import speiger.src.builder.processor.TemplateProcess;
|
||||
import speiger.src.builder.processor.TemplateProcessor;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public class PrimitiveCollectionsBuilder extends TemplateProcessor
|
||||
{
|
||||
private static final int SPECIAL = 0x1; //Detects if the Builder is generating tests
|
||||
private static final int LOAD = 0x2; //If Configs should be loaded
|
||||
private static final int ANTI_SAVE = SPECIAL | LOAD; //If save should be disabled since load/save shouldn't happen at the same time.
|
||||
private static final int SAVE = 0x4; //if the configuration should be created
|
||||
Set<String> globalFlags = new HashSet<>();
|
||||
List<ModulePackage> simplePackages = new ArrayList<>();
|
||||
List<ModulePackage> biPackages = new ArrayList<>();
|
||||
List<ModulePackage> enumPackages = new ArrayList<>();
|
||||
Map<String, RequiredType> requirements = new HashMap<>();
|
||||
SettingsManager manager = new SettingsManager();
|
||||
int flags;
|
||||
|
||||
public PrimitiveCollectionsBuilder()
|
||||
{
|
||||
this(false);
|
||||
}
|
||||
|
||||
public PrimitiveCollectionsBuilder(boolean silencedSuccess)
|
||||
{
|
||||
super(silencedSuccess, Paths.get("src/builder/resources/speiger/assets/collections/templates/"), Paths.get("src/main/java/speiger/src/collections/"), Paths.get("src/builder/resources/speiger/assets/collections/"));
|
||||
}
|
||||
|
||||
public PrimitiveCollectionsBuilder(Path sourceFolder, Path outputFolder, Path dataFolder)
|
||||
{
|
||||
this(false, sourceFolder, outputFolder, dataFolder);
|
||||
}
|
||||
|
||||
public PrimitiveCollectionsBuilder(boolean silencedSuccess, Path sourceFolder, Path outputFolder, Path dataFolder)
|
||||
{
|
||||
super(silencedSuccess, sourceFolder, outputFolder, dataFolder);
|
||||
}
|
||||
|
||||
private PrimitiveCollectionsBuilder setFlags(int flags) {
|
||||
this.flags = flags;
|
||||
if((flags & ANTI_SAVE) != 0) {
|
||||
this.flags &= ~SAVE;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
private static PrimitiveCollectionsBuilder createTests(boolean silent, int flags) {
|
||||
return new PrimitiveCollectionsBuilder(silent,
|
||||
Paths.get("src/builder/resources/speiger/assets/tests/templates/"),
|
||||
Paths.get("src/test/java/speiger/src/tests/"),
|
||||
Paths.get("src/builder/resources/speiger/assets/tests/")).setFlags(flags | SPECIAL);
|
||||
}
|
||||
|
||||
private static PrimitiveCollectionsBuilder createTesters(boolean silent, int flags) {
|
||||
return new PrimitiveCollectionsBuilder(silent,
|
||||
Paths.get("src/builder/resources/speiger/assets/testers/templates/"),
|
||||
Paths.get("src/test/java/speiger/src/testers/"),
|
||||
Paths.get("src/builder/resources/speiger/assets/testers/")).setFlags(flags | SPECIAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isFileValid(Path fileName)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean relativePackages()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean debugUnusedMappers()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void afterFinish()
|
||||
{
|
||||
if((flags & SPECIAL) == 0 && getVersion() > 8)
|
||||
{
|
||||
Path basePath = Paths.get("src/main/java");
|
||||
try(BufferedWriter writer = Files.newBufferedWriter(basePath.resolve("module-info.java")))
|
||||
{
|
||||
writer.write(getModuleInfo(basePath));
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<BaseModule> createModules()
|
||||
{
|
||||
List<BaseModule> modules = new ArrayList<>();
|
||||
modules.add(JavaModule.INSTANCE);
|
||||
modules.add(FunctionModule.INSTANCE);
|
||||
modules.add(CollectionModule.INSTANCE);
|
||||
modules.add(PrioQueueModule.INSTANCE);
|
||||
modules.add(ListModule.INSTANCE);
|
||||
modules.add(SetModule.INSTANCE);
|
||||
modules.add(MapModule.INSTANCE);
|
||||
modules.add(PairModule.INSTANCE);
|
||||
modules.add(AsyncModule.INSTANCE);
|
||||
return modules;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void init()
|
||||
{
|
||||
prepPackages();
|
||||
//Init Modules here
|
||||
addModules(createModules());
|
||||
finishPackages();
|
||||
}
|
||||
|
||||
public void addModules(List<BaseModule> modules)
|
||||
{
|
||||
for(int i = 0,m=modules.size();i<m;i++) {
|
||||
modules.get(i).setManager(manager);
|
||||
}
|
||||
for(int i = 0,m=modules.size();i<m;i++) {
|
||||
biPackages.forEach(modules.get(i)::init);
|
||||
}
|
||||
for(int i = 0,m=modules.size();i<m;i++) {
|
||||
modules.get(i).cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
private void finishPackages()
|
||||
{
|
||||
biPackages.forEach(ModulePackage::finish);
|
||||
if((flags & SAVE) != 0) manager.save();
|
||||
}
|
||||
|
||||
private void prepPackages()
|
||||
{
|
||||
if((flags & LOAD) != 0) manager.load();
|
||||
for(ModulePackage entry : ModulePackage.createPackages(globalFlags))
|
||||
{
|
||||
entry.setRequirements(requirements::put);
|
||||
biPackages.add(entry);
|
||||
if(entry.isSame()) simplePackages.add(entry);
|
||||
if(entry.isEnumValid()) enumPackages.add(entry);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createProcesses(String fileName, Consumer<TemplateProcess> process)
|
||||
{
|
||||
List<ModulePackage> packages = getPackagesByRequirement(requirements.get(fileName));
|
||||
for(int i = 0,m=packages.size();i<m;i++)
|
||||
{
|
||||
packages.get(i).process(fileName, process);
|
||||
}
|
||||
}
|
||||
|
||||
protected List<ModulePackage> getPackagesByRequirement(RequiredType type) {
|
||||
if(type == null) return simplePackages;
|
||||
if(type == RequiredType.BI_CLASS) return biPackages;
|
||||
if(type == RequiredType.ENUM) return enumPackages;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
private String getModuleInfo(Path basePath) {
|
||||
StringJoiner joiner = new StringJoiner("\n", "", "\n");
|
||||
try(Stream<Path> stream = Files.walk(getOutputFolder()))
|
||||
{
|
||||
stream.filter(Files::isDirectory)
|
||||
.filter(this::containsFiles)
|
||||
.map(basePath::relativize)
|
||||
.map(Path::toString)
|
||||
.map(this::sanitize)
|
||||
.forEach(T -> joiner.add("\texports "+T+";"));
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("/** @author Speiger */\n");
|
||||
builder.append("module ").append(sanitize(basePath.relativize(getOutputFolder()).toString())).append(" {\n");
|
||||
builder.append(joiner.toString()).append("}");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
private String sanitize(String input)
|
||||
{
|
||||
return input.replace("\\", ".").replace("/", ".");
|
||||
}
|
||||
|
||||
private boolean containsFiles(Path path)
|
||||
{
|
||||
try(Stream<Path> stream = Files.walk(path, 1))
|
||||
{
|
||||
return stream.filter(Files::isRegularFile).findFirst().isPresent();
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private int getVersion()
|
||||
{
|
||||
String version = System.getProperty("java.version");
|
||||
if(version.startsWith("1.")) return Integer.parseInt(version.substring(2, 3));
|
||||
int dot = version.indexOf(".");
|
||||
return Integer.parseInt(dot != -1 ? version.substring(0, dot) : version);
|
||||
}
|
||||
|
||||
public static void main(String...args)
|
||||
{
|
||||
try
|
||||
{
|
||||
Set<String> flags = new HashSet<>(Arrays.asList(args));
|
||||
boolean silent = flags.contains("silent");
|
||||
boolean force = flags.contains("force");
|
||||
boolean tests = flags.contains("tests");
|
||||
boolean forceTests = flags.contains("force-tests");
|
||||
boolean load = flags.contains("load");
|
||||
boolean save = flags.contains("save");
|
||||
int flag = (load ? LOAD : 0) | (save ? SAVE : 0);
|
||||
new PrimitiveCollectionsBuilder(silent).setFlags(flag).process(force);
|
||||
if(tests) {
|
||||
createTests(silent, flag).process(force || forceTests);
|
||||
createTesters(silent, flag).process(force || forceTests);
|
||||
}
|
||||
}
|
||||
catch(InterruptedException | IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,281 +1,281 @@
|
|||
package speiger.src.builder.modules;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import speiger.src.builder.ClassType;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public class MapModule extends BaseModule
|
||||
{
|
||||
public static final BaseModule INSTANCE = new MapModule();
|
||||
|
||||
@Override
|
||||
public String getModuleName() { return "Map"; }
|
||||
@Override
|
||||
public boolean isBiModule() { return true; }
|
||||
@Override
|
||||
protected void loadVariables() {}
|
||||
@Override
|
||||
public boolean isModuleValid(ClassType keyType, ClassType valueType) { return keyType != ClassType.BOOLEAN; }
|
||||
@Override
|
||||
public boolean areDependenciesLoaded() { return isDependencyLoaded(SetModule.INSTANCE) && isDependencyLoaded(CollectionModule.INSTANCE, false); }
|
||||
|
||||
@Override
|
||||
public Set<String> getModuleKeys(ClassType keyType, ClassType valueType) {
|
||||
Set<String> sets = new TreeSet<>();
|
||||
sets.addAll(Arrays.asList("Wrappers", "Implementations"));
|
||||
sets.addAll(Arrays.asList("OrderedMap", "SortedMap"));
|
||||
sets.addAll(Arrays.asList("ArrayMap", "ConcurrentMap", "ImmutableMap"));
|
||||
sets.addAll(Arrays.asList("HashMap", "LinkedHashMap"));
|
||||
sets.addAll(Arrays.asList("CustomHashMap", "LinkedCustomHashMap"));
|
||||
sets.addAll(Arrays.asList("EnumMap", "LinkedEnumMap"));
|
||||
sets.addAll(Arrays.asList("AVLTreeMap", "RBTreeMap"));
|
||||
return sets;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadFlags()
|
||||
{
|
||||
if(isModuleEnabled()) addFlag("MAP_MODULE");
|
||||
if(isModuleEnabled("Wrappers")) addFlag("MAPS_FEATURE");
|
||||
boolean implementations = isModuleEnabled("Implementations");
|
||||
boolean hashMap = implementations && isModuleEnabled("HashMap");
|
||||
boolean customHashMap = implementations && isModuleEnabled("CustomHashMap");
|
||||
boolean enumMap = implementations && isModuleEnabled("EnumMap");
|
||||
|
||||
if(isModuleEnabled("OrderedMap")) {
|
||||
addFlag("ORDERED_MAP_FEATURE");
|
||||
if(isModuleEnabled("ArrayMap")) addFlag("ARRAY_MAP_FEATURE");
|
||||
if(hashMap && isModuleEnabled("LinkedHashMap")) addFlag("LINKED_MAP_FEATURE");
|
||||
if(customHashMap && isModuleEnabled("LinkedCustomHashMap")) addFlag("LINKED_CUSTOM_MAP_FEATURE");
|
||||
if(enumMap && isModuleEnabled("LinkedEnumMap")) addFlag("LINKED_ENUM_MAP_FEATURE");
|
||||
}
|
||||
if(isModuleEnabled("SortedMap")) {
|
||||
addFlag("SORTED_MAP_FEATURE");
|
||||
if(implementations && isModuleEnabled("AVLTreeMap")) addFlag("AVL_TREE_MAP_FEATURE");
|
||||
if(implementations && isModuleEnabled("RBTreeMap")) addFlag("RB_TREE_MAP_FEATURE");
|
||||
}
|
||||
if(implementations && isModuleEnabled("ConcurrentMap")) addFlag("CONCURRENT_MAP_FEATURE");
|
||||
if(implementations && isModuleEnabled("ImmutableMap")) addFlag("IMMUTABLE_MAP_FEATURE");
|
||||
if(hashMap) addFlag("MAP_FEATURE");
|
||||
if(customHashMap) addFlag("CUSTOM_MAP_FEATURE");
|
||||
if(enumMap) addFlag("ENUM_MAP_FEATURE");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadBlockades()
|
||||
{
|
||||
if(!isModuleEnabled()) addBlockedFiles("Map", "AbstractMap");
|
||||
if(!isModuleEnabled("Wrappers")) addBlockedFiles("Maps");
|
||||
boolean implementations = !isModuleEnabled("Implementations");
|
||||
if(implementations || !isModuleEnabled("ImmutableMap")) addBlockedFiles("ImmutableOpenHashMap");
|
||||
if(implementations || !isModuleEnabled("ConcurrentMap")) addBlockedFiles("ConcurrentMap", "ConcurrentOpenHashMap");
|
||||
|
||||
boolean ordered = !isModuleEnabled("OrderedMap");
|
||||
if(ordered) addBlockedFiles("OrderedMap");
|
||||
boolean hashMap = implementations || !isModuleEnabled("HashMap");
|
||||
if(hashMap) addBlockedFiles("OpenHashMap");
|
||||
if(hashMap || ordered || !isModuleEnabled("LinkedHashMap")) addBlockedFiles("LinkedOpenHashMap");
|
||||
|
||||
boolean customHashMap = implementations || !isModuleEnabled("CustomHashMap");
|
||||
if(customHashMap) addBlockedFiles("OpenCustomHashMap");
|
||||
if(customHashMap || ordered || !isModuleEnabled("LinkedCustomHashMap")) addBlockedFiles("LinkedOpenCustomHashMap");
|
||||
|
||||
boolean enumMap = implementations || !isModuleEnabled("EnumMap");
|
||||
if(enumMap) addBlockedFiles("EnumMap");
|
||||
if(enumMap || ordered || !isModuleEnabled("LinkedEnumMap")) addBlockedFiles("LinkedEnumMap");
|
||||
|
||||
if(ordered || !isModuleEnabled("ArrayMap")) addBlockedFiles("ArrayMap");
|
||||
|
||||
boolean sorted = !isModuleEnabled("SortedMap");
|
||||
if(sorted) addBlockedFiles("SortedMap", "NavigableMap");
|
||||
if(implementations || sorted || !isModuleEnabled("AVLTreeMap")) addBlockedFiles("AVLTreeMap");
|
||||
if(implementations || sorted || !isModuleEnabled("RBTreeMap")) addBlockedFiles("RBTreeMap");
|
||||
|
||||
if(keyType == ClassType.BOOLEAN)
|
||||
{
|
||||
//Main Classes
|
||||
addBlockedFiles("SortedMap", "NavigableMap", "RBTreeMap", "AVLTreeMap");
|
||||
addBlockedFiles("OrderedMap", "ArrayMap", "LinkedOpenHashMap", "LinkedOpenCustomHashMap");
|
||||
addBlockedFiles("ConcurrentMap", "ConcurrentOpenHashMap");
|
||||
addBlockedFiles("Map", "Maps", "AbstractMap", "ImmutableOpenHashMap", "OpenHashMap", "OpenCustomHashMap");
|
||||
|
||||
//Test Classes
|
||||
addBlockedFiles("TestMap", "MapTests", "MapTestSuiteBuilder", "MapConstructorTests", "TestMapGenerator", "SimpleMapTestGenerator", "DerivedMapGenerators", "AbstractMapTester");
|
||||
addBlockedFiles("TestSortedMapGenerator", "OrderedMapTestSuiteBuilder", "NavigableMapTestSuiteBuilder", "SortedMapTestSuiteBuilder");
|
||||
addBlockedFiles("TestOrderedMapGenerator");
|
||||
addBlockedFilter(T -> T.endsWith("Tester") && (T.startsWith("Map") || T.startsWith("OrderedMap") || T.startsWith("SortedMap") || T.startsWith("NavigableMap")));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadRemappers()
|
||||
{
|
||||
//Main Classes
|
||||
addBiRequirement("Map");
|
||||
addBiRequirement("SortedMap");
|
||||
addBiRequirement("OrderedMap");
|
||||
addBiRequirement("NavigableMap");
|
||||
addBiRequirement("ConcurrentMap");
|
||||
addBiRequirement("AbstractMap");
|
||||
addEnumRequirement("EnumMap");
|
||||
addEnumRequirement("LinkedEnumMap");
|
||||
addBiRequirement("ConcurrentOpenHashMap");
|
||||
addBiRequirement("ImmutableOpenHashMap");
|
||||
addBiRequirement("OpenHashMap");
|
||||
addBiRequirement("LinkedOpenHashMap");
|
||||
addBiRequirement("OpenCustomHashMap");
|
||||
addBiRequirement("LinkedOpenCustomHashMap");
|
||||
addBiRequirement("ArrayMap");
|
||||
addBiRequirement("RBTreeMap");
|
||||
addBiRequirement("AVLTreeMap");
|
||||
addBiRequirement("Maps");
|
||||
|
||||
addRemapper("AbstractMap", "Abstract%sMap");
|
||||
addRemapper("EnumMap", "Enum2%sMap");
|
||||
addRemapper("LinkedEnumMap", "LinkedEnum2%sMap");
|
||||
addRemapper("ImmutableOpenHashMap", "Immutable%sOpenHashMap");
|
||||
|
||||
//Test Classes
|
||||
addBiRequirement("TestMapGenerator");
|
||||
addBiRequirement("TestSortedMapGenerator");
|
||||
addBiRequirement("TestOrderedMapGenerator");
|
||||
addBiRequirement("SimpleMapTestGenerator");
|
||||
addBiRequirement("DerivedMapGenerators");
|
||||
addBiRequirement("AbstractMapTester");
|
||||
addBiRequirement("MapTestSuiteBuilder");
|
||||
addBiRequirement("SortedMapTestSuiteBuilder");
|
||||
addBiRequirement("NavigableMapTestSuiteBuilder");
|
||||
addBiRequirement("OrderedMapTestSuiteBuilder");
|
||||
addBiRequirement("MapTests");
|
||||
addBiRequirement("MapConstructorTests");
|
||||
addBiRequirement("TestMap");
|
||||
addBiRequirement("MapAddToTester");
|
||||
addBiRequirement("MapSubFromTester");
|
||||
addBiRequirement("MapClearTester");
|
||||
addBiRequirement("MapComputeIfAbsentTester");
|
||||
addBiRequirement("MapComputeIfPresentTester");
|
||||
addBiRequirement("MapComputeTester");
|
||||
addBiRequirement("MapCopyTester");
|
||||
addBiRequirement("MapContainsTester");
|
||||
addBiRequirement("MapContainsKeyTester");
|
||||
addBiRequirement("MapContainsValueTester");
|
||||
addBiRequirement("MapCreatorTester");
|
||||
addBiRequirement("MapEntrySetTester");
|
||||
addBiRequirement("MapEqualsTester");
|
||||
addBiRequirement("MapForEachTester");
|
||||
addBiRequirement("MapGetOrDefaultTester");
|
||||
addBiRequirement("MapGetTester");
|
||||
addBiRequirement("MapHashCodeTester");
|
||||
addBiRequirement("MapIsEmptyTester");
|
||||
addBiRequirement("MapMergeTester");
|
||||
addBiRequirement("MapMergeBulkTester");
|
||||
addBiRequirement("MapPutAllArrayTester");
|
||||
addBiRequirement("MapPutAllTester");
|
||||
addBiRequirement("MapPutIfAbsentTester");
|
||||
addBiRequirement("MapPutTester");
|
||||
addBiRequirement("MapRemoveEntryTester");
|
||||
addBiRequirement("MapRemoveOrDefaultTester");
|
||||
addBiRequirement("MapRemoveTester");
|
||||
addBiRequirement("MapReplaceAllTester");
|
||||
addBiRequirement("MapReplaceEntryTester");
|
||||
addBiRequirement("MapReplaceTester");
|
||||
addBiRequirement("MapSizeTester");
|
||||
addBiRequirement("MapSupplyIfAbsentTester");
|
||||
addBiRequirement("MapToStringTester");
|
||||
addBiRequirement("NavigableMapNavigationTester");
|
||||
addBiRequirement("SortedMapNavigationTester");
|
||||
addBiRequirement("OrderedMapNavigationTester");
|
||||
addBiRequirement("OrderedMapMoveTester");
|
||||
addBiRequirement("MapConstructorTester");
|
||||
|
||||
addRemapper("TestMapGenerator", "Test%sMapGenerator");
|
||||
addRemapper("TestSortedMapGenerator", "Test%sSortedMapGenerator");
|
||||
addRemapper("TestOrderedMapGenerator", "Test%sOrderedMapGenerator");
|
||||
addRemapper("SimpleMapTestGenerator", "Simple%sMapTestGenerator");
|
||||
addRemapper("DerivedMapGenerators", "Derived%sMapGenerators");
|
||||
addRemapper("AbstractMapTester", "Abstract%sMapTester");
|
||||
addRemapper("TestMap", "Test%sMap");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadFunctions()
|
||||
{
|
||||
addFunctionValueMapper("BULK_MERGE", "mergeAll");
|
||||
addFunctionValueMappers("COMPUTE_IF_ABSENT", "compute%sIfAbsent");
|
||||
addFunctionValueMappers("COMPUTE_IF_PRESENT", "compute%sIfPresent");
|
||||
addFunctionValueMapper("COMPUTE", "compute");
|
||||
addFunctionMapper("DEQUEUE_LAST", "dequeueLast");
|
||||
addFunctionMapper("DEQUEUE", "dequeue");
|
||||
addSimpleMapper("ENTRY_SET", keyType.getFileType().toLowerCase()+"2"+valueType.getFileType()+"EntrySet");
|
||||
addFunctionMappers("FIRST_ENTRY_KEY", "first%sKey");
|
||||
addFunctionValueMappers("FIRST_ENTRY_VALUE", "first%sValue");
|
||||
if(keyType.isObject()) addFunctionValueMapper("GET_VALUE", valueType.isObject() ? "getObject" : "get");
|
||||
else addSimpleMapper("GET_VALUE", "get");
|
||||
addFunctionMappers("LAST_ENTRY_KEY", "last%sKey");
|
||||
addFunctionValueMappers("LAST_ENTRY_VALUE", "last%sValue");
|
||||
addFunctionValueMapper("MERGE", "merge");
|
||||
addFunctionMappers("POLL_FIRST_ENTRY_KEY", "pollFirst%sKey");
|
||||
addFunctionMappers("POLL_LAST_ENTRY_KEY", "pollLast%sKey");
|
||||
if(keyType.isObject()) addFunctionMapper("REMOVE_VALUE", "rem");
|
||||
else addSimpleMapper("REMOVE_VALUE", "remove");
|
||||
addFunctionMapper("REMOVE", "remove");
|
||||
addFunctionValueMappers("REPLACE_VALUES", valueType.isObject() ? "replaceObjects" : "replace%ss");
|
||||
addFunctionValueMappers("SUPPLY_IF_ABSENT", "supply%sIfAbsent");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadClasses()
|
||||
{
|
||||
//Implementation Classes
|
||||
addAbstractBiMapper("IMMUTABLE_HASH_MAP", "Immutable%sOpenHashMap", "2");
|
||||
addBiClassMapper("LINKED_CUSTOM_HASH_MAP", "LinkedOpenCustomHashMap", "2");
|
||||
addBiClassMapper("LINKED_HASH_MAP", "LinkedOpenHashMap", "2");
|
||||
addBiClassMapper("CUSTOM_HASH_MAP", "OpenCustomHashMap", "2");
|
||||
addBiClassMapper("CONCURRENT_HASH_MAP", "ConcurrentOpenHashMap", "2");
|
||||
addBiClassMapper("AVL_TREE_MAP", "AVLTreeMap", "2");
|
||||
addBiClassMapper("RB_TREE_MAP", "RBTreeMap", "2");
|
||||
addFunctionValueMappers("LINKED_ENUM_MAP", valueType.isObject() ? "LinkedEnum2ObjectMap" : "LinkedEnum2%sMap");
|
||||
addFunctionValueMappers("ENUM_MAP", valueType.isObject() ? "Enum2ObjectMap" : "Enum2%sMap");
|
||||
addBiClassMapper("HASH_MAP", "OpenHashMap", "2");
|
||||
addBiClassMapper("ARRAY_MAP", "ArrayMap", "2");
|
||||
|
||||
//Abstract Classes
|
||||
addAbstractBiMapper("ABSTRACT_MAP", "Abstract%sMap", "2");
|
||||
|
||||
//Helper Classes
|
||||
addBiClassMapper("MAPS", "Maps", "2");
|
||||
|
||||
//Interfaces
|
||||
addBiClassMapper("NAVIGABLE_MAP", "NavigableMap", "2");
|
||||
addBiClassMapper("ORDERED_MAP", "OrderedMap", "2");
|
||||
addBiClassMapper("SORTED_MAP", "SortedMap", "2");
|
||||
addBiClassMapper("CONCURRENT_MAP", "ConcurrentMap", "2");
|
||||
addBiClassMapper("MAP", "Map", "2");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadTestClasses()
|
||||
{
|
||||
//Implementation Classes
|
||||
addAbstractBiMapper("SIMPLE_TEST_MAP", "Test%sMap", "2");
|
||||
addBiClassMapper("MAP_TESTS", "MapTests", "2");
|
||||
addAbstractBiMapper("NAVIGABLE_MAP_TEST_BUILDER", "%sNavigableMapTestSuiteBuilder", "2");
|
||||
addAbstractBiMapper("SORTED_MAP_TEST_BUILDER", "%sSortedMapTestSuiteBuilder", "2");
|
||||
addAbstractBiMapper("ORDERED_MAP_TEST_BUILDER", "%sOrderedMapTestSuiteBuilder", "2");
|
||||
addAbstractBiMapper("MAP_TEST_BUILDER", "%sMapTestSuiteBuilder", "2");
|
||||
|
||||
//Abstract Classes
|
||||
addAbstractBiMapper("ABSTRACT_MAP_TESTER", "Abstract%sMapTester", "2");
|
||||
|
||||
//Helper Classes
|
||||
addAbstractBiMapper("MAP_CONSTRUCTOR_TESTS", "%sMapConstructorTests", "2");
|
||||
addAbstractBiMapper("SIMPLE_MAP_TEST_GENERATOR", "Simple%sMapTestGenerator", "2");
|
||||
addAbstractBiMapper("DERIVED_MAP_GENERATORS", "Derived%sMapGenerators", "2");
|
||||
addAbstractBiMapper("TEST_ORDERED_MAP_GENERATOR", "Test%sOrderedMapGenerator", "2");
|
||||
addAbstractBiMapper("TEST_SORTED_MAP_GENERATOR", "Test%sSortedMapGenerator", "2");
|
||||
addAbstractBiMapper("TEST_MAP_GENERATOR", "Test%sMapGenerator", "2");
|
||||
}
|
||||
package speiger.src.builder.modules;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import speiger.src.builder.ClassType;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public class MapModule extends BaseModule
|
||||
{
|
||||
public static final BaseModule INSTANCE = new MapModule();
|
||||
|
||||
@Override
|
||||
public String getModuleName() { return "Map"; }
|
||||
@Override
|
||||
public boolean isBiModule() { return true; }
|
||||
@Override
|
||||
protected void loadVariables() {}
|
||||
@Override
|
||||
public boolean isModuleValid(ClassType keyType, ClassType valueType) { return keyType != ClassType.BOOLEAN; }
|
||||
@Override
|
||||
public boolean areDependenciesLoaded() { return isDependencyLoaded(SetModule.INSTANCE) && isDependencyLoaded(CollectionModule.INSTANCE, false); }
|
||||
|
||||
@Override
|
||||
public Set<String> getModuleKeys(ClassType keyType, ClassType valueType) {
|
||||
Set<String> sets = new TreeSet<>();
|
||||
sets.addAll(Arrays.asList("Wrappers", "Implementations"));
|
||||
sets.addAll(Arrays.asList("OrderedMap", "SortedMap"));
|
||||
sets.addAll(Arrays.asList("ArrayMap", "ConcurrentMap", "ImmutableMap"));
|
||||
sets.addAll(Arrays.asList("HashMap", "LinkedHashMap"));
|
||||
sets.addAll(Arrays.asList("CustomHashMap", "LinkedCustomHashMap"));
|
||||
sets.addAll(Arrays.asList("EnumMap", "LinkedEnumMap"));
|
||||
sets.addAll(Arrays.asList("AVLTreeMap", "RBTreeMap"));
|
||||
return sets;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadFlags()
|
||||
{
|
||||
if(isModuleEnabled()) addFlag("MAP_MODULE");
|
||||
if(isModuleEnabled("Wrappers")) addFlag("MAPS_FEATURE");
|
||||
boolean implementations = isModuleEnabled("Implementations");
|
||||
boolean hashMap = implementations && isModuleEnabled("HashMap");
|
||||
boolean customHashMap = implementations && isModuleEnabled("CustomHashMap");
|
||||
boolean enumMap = implementations && isModuleEnabled("EnumMap");
|
||||
|
||||
if(isModuleEnabled("OrderedMap")) {
|
||||
addFlag("ORDERED_MAP_FEATURE");
|
||||
if(isModuleEnabled("ArrayMap")) addFlag("ARRAY_MAP_FEATURE");
|
||||
if(hashMap && isModuleEnabled("LinkedHashMap")) addFlag("LINKED_MAP_FEATURE");
|
||||
if(customHashMap && isModuleEnabled("LinkedCustomHashMap")) addFlag("LINKED_CUSTOM_MAP_FEATURE");
|
||||
if(enumMap && isModuleEnabled("LinkedEnumMap")) addFlag("LINKED_ENUM_MAP_FEATURE");
|
||||
}
|
||||
if(isModuleEnabled("SortedMap")) {
|
||||
addFlag("SORTED_MAP_FEATURE");
|
||||
if(implementations && isModuleEnabled("AVLTreeMap")) addFlag("AVL_TREE_MAP_FEATURE");
|
||||
if(implementations && isModuleEnabled("RBTreeMap")) addFlag("RB_TREE_MAP_FEATURE");
|
||||
}
|
||||
if(implementations && isModuleEnabled("ConcurrentMap")) addFlag("CONCURRENT_MAP_FEATURE");
|
||||
if(implementations && isModuleEnabled("ImmutableMap")) addFlag("IMMUTABLE_MAP_FEATURE");
|
||||
if(hashMap) addFlag("MAP_FEATURE");
|
||||
if(customHashMap) addFlag("CUSTOM_MAP_FEATURE");
|
||||
if(enumMap) addFlag("ENUM_MAP_FEATURE");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadBlockades()
|
||||
{
|
||||
if(!isModuleEnabled()) addBlockedFiles("Map", "AbstractMap");
|
||||
if(!isModuleEnabled("Wrappers")) addBlockedFiles("Maps");
|
||||
boolean implementations = !isModuleEnabled("Implementations");
|
||||
if(implementations || !isModuleEnabled("ImmutableMap")) addBlockedFiles("ImmutableOpenHashMap");
|
||||
if(implementations || !isModuleEnabled("ConcurrentMap")) addBlockedFiles("ConcurrentMap", "ConcurrentOpenHashMap");
|
||||
|
||||
boolean ordered = !isModuleEnabled("OrderedMap");
|
||||
if(ordered) addBlockedFiles("OrderedMap");
|
||||
boolean hashMap = implementations || !isModuleEnabled("HashMap");
|
||||
if(hashMap) addBlockedFiles("OpenHashMap");
|
||||
if(hashMap || ordered || !isModuleEnabled("LinkedHashMap")) addBlockedFiles("LinkedOpenHashMap");
|
||||
|
||||
boolean customHashMap = implementations || !isModuleEnabled("CustomHashMap");
|
||||
if(customHashMap) addBlockedFiles("OpenCustomHashMap");
|
||||
if(customHashMap || ordered || !isModuleEnabled("LinkedCustomHashMap")) addBlockedFiles("LinkedOpenCustomHashMap");
|
||||
|
||||
boolean enumMap = implementations || !isModuleEnabled("EnumMap");
|
||||
if(enumMap) addBlockedFiles("EnumMap");
|
||||
if(enumMap || ordered || !isModuleEnabled("LinkedEnumMap")) addBlockedFiles("LinkedEnumMap");
|
||||
|
||||
if(ordered || !isModuleEnabled("ArrayMap")) addBlockedFiles("ArrayMap");
|
||||
|
||||
boolean sorted = !isModuleEnabled("SortedMap");
|
||||
if(sorted) addBlockedFiles("SortedMap", "NavigableMap");
|
||||
if(implementations || sorted || !isModuleEnabled("AVLTreeMap")) addBlockedFiles("AVLTreeMap");
|
||||
if(implementations || sorted || !isModuleEnabled("RBTreeMap")) addBlockedFiles("RBTreeMap");
|
||||
|
||||
if(keyType == ClassType.BOOLEAN)
|
||||
{
|
||||
//Main Classes
|
||||
addBlockedFiles("SortedMap", "NavigableMap", "RBTreeMap", "AVLTreeMap");
|
||||
addBlockedFiles("OrderedMap", "ArrayMap", "LinkedOpenHashMap", "LinkedOpenCustomHashMap");
|
||||
addBlockedFiles("ConcurrentMap", "ConcurrentOpenHashMap");
|
||||
addBlockedFiles("Map", "Maps", "AbstractMap", "ImmutableOpenHashMap", "OpenHashMap", "OpenCustomHashMap");
|
||||
|
||||
//Test Classes
|
||||
addBlockedFiles("TestMap", "MapTests", "MapTestSuiteBuilder", "MapConstructorTests", "TestMapGenerator", "SimpleMapTestGenerator", "DerivedMapGenerators", "AbstractMapTester");
|
||||
addBlockedFiles("TestSortedMapGenerator", "OrderedMapTestSuiteBuilder", "NavigableMapTestSuiteBuilder", "SortedMapTestSuiteBuilder");
|
||||
addBlockedFiles("TestOrderedMapGenerator");
|
||||
addBlockedFilter(T -> T.endsWith("Tester") && (T.startsWith("Map") || T.startsWith("OrderedMap") || T.startsWith("SortedMap") || T.startsWith("NavigableMap")));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadRemappers()
|
||||
{
|
||||
//Main Classes
|
||||
addBiRequirement("Map");
|
||||
addBiRequirement("SortedMap");
|
||||
addBiRequirement("OrderedMap");
|
||||
addBiRequirement("NavigableMap");
|
||||
addBiRequirement("ConcurrentMap");
|
||||
addBiRequirement("AbstractMap");
|
||||
addEnumRequirement("EnumMap");
|
||||
addEnumRequirement("LinkedEnumMap");
|
||||
addBiRequirement("ConcurrentOpenHashMap");
|
||||
addBiRequirement("ImmutableOpenHashMap");
|
||||
addBiRequirement("OpenHashMap");
|
||||
addBiRequirement("LinkedOpenHashMap");
|
||||
addBiRequirement("OpenCustomHashMap");
|
||||
addBiRequirement("LinkedOpenCustomHashMap");
|
||||
addBiRequirement("ArrayMap");
|
||||
addBiRequirement("RBTreeMap");
|
||||
addBiRequirement("AVLTreeMap");
|
||||
addBiRequirement("Maps");
|
||||
|
||||
addRemapper("AbstractMap", "Abstract%sMap");
|
||||
addRemapper("EnumMap", "Enum2%sMap");
|
||||
addRemapper("LinkedEnumMap", "LinkedEnum2%sMap");
|
||||
addRemapper("ImmutableOpenHashMap", "Immutable%sOpenHashMap");
|
||||
|
||||
//Test Classes
|
||||
addBiRequirement("TestMapGenerator");
|
||||
addBiRequirement("TestSortedMapGenerator");
|
||||
addBiRequirement("TestOrderedMapGenerator");
|
||||
addBiRequirement("SimpleMapTestGenerator");
|
||||
addBiRequirement("DerivedMapGenerators");
|
||||
addBiRequirement("AbstractMapTester");
|
||||
addBiRequirement("MapTestSuiteBuilder");
|
||||
addBiRequirement("SortedMapTestSuiteBuilder");
|
||||
addBiRequirement("NavigableMapTestSuiteBuilder");
|
||||
addBiRequirement("OrderedMapTestSuiteBuilder");
|
||||
addBiRequirement("MapTests");
|
||||
addBiRequirement("MapConstructorTests");
|
||||
addBiRequirement("TestMap");
|
||||
addBiRequirement("MapAddToTester");
|
||||
addBiRequirement("MapSubFromTester");
|
||||
addBiRequirement("MapClearTester");
|
||||
addBiRequirement("MapComputeIfAbsentTester");
|
||||
addBiRequirement("MapComputeIfPresentTester");
|
||||
addBiRequirement("MapComputeTester");
|
||||
addBiRequirement("MapCopyTester");
|
||||
addBiRequirement("MapContainsTester");
|
||||
addBiRequirement("MapContainsKeyTester");
|
||||
addBiRequirement("MapContainsValueTester");
|
||||
addBiRequirement("MapCreatorTester");
|
||||
addBiRequirement("MapEntrySetTester");
|
||||
addBiRequirement("MapEqualsTester");
|
||||
addBiRequirement("MapForEachTester");
|
||||
addBiRequirement("MapGetOrDefaultTester");
|
||||
addBiRequirement("MapGetTester");
|
||||
addBiRequirement("MapHashCodeTester");
|
||||
addBiRequirement("MapIsEmptyTester");
|
||||
addBiRequirement("MapMergeTester");
|
||||
addBiRequirement("MapMergeBulkTester");
|
||||
addBiRequirement("MapPutAllArrayTester");
|
||||
addBiRequirement("MapPutAllTester");
|
||||
addBiRequirement("MapPutIfAbsentTester");
|
||||
addBiRequirement("MapPutTester");
|
||||
addBiRequirement("MapRemoveEntryTester");
|
||||
addBiRequirement("MapRemoveOrDefaultTester");
|
||||
addBiRequirement("MapRemoveTester");
|
||||
addBiRequirement("MapReplaceAllTester");
|
||||
addBiRequirement("MapReplaceEntryTester");
|
||||
addBiRequirement("MapReplaceTester");
|
||||
addBiRequirement("MapSizeTester");
|
||||
addBiRequirement("MapSupplyIfAbsentTester");
|
||||
addBiRequirement("MapToStringTester");
|
||||
addBiRequirement("NavigableMapNavigationTester");
|
||||
addBiRequirement("SortedMapNavigationTester");
|
||||
addBiRequirement("OrderedMapNavigationTester");
|
||||
addBiRequirement("OrderedMapMoveTester");
|
||||
addBiRequirement("MapConstructorTester");
|
||||
|
||||
addRemapper("TestMapGenerator", "Test%sMapGenerator");
|
||||
addRemapper("TestSortedMapGenerator", "Test%sSortedMapGenerator");
|
||||
addRemapper("TestOrderedMapGenerator", "Test%sOrderedMapGenerator");
|
||||
addRemapper("SimpleMapTestGenerator", "Simple%sMapTestGenerator");
|
||||
addRemapper("DerivedMapGenerators", "Derived%sMapGenerators");
|
||||
addRemapper("AbstractMapTester", "Abstract%sMapTester");
|
||||
addRemapper("TestMap", "Test%sMap");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadFunctions()
|
||||
{
|
||||
addFunctionValueMapper("BULK_MERGE", "mergeAll");
|
||||
addFunctionValueMappers("COMPUTE_IF_ABSENT", "compute%sIfAbsent");
|
||||
addFunctionValueMappers("COMPUTE_IF_PRESENT", "compute%sIfPresent");
|
||||
addFunctionValueMapper("COMPUTE", "compute");
|
||||
addFunctionMapper("DEQUEUE_LAST", "dequeueLast");
|
||||
addFunctionMapper("DEQUEUE", "dequeue");
|
||||
addSimpleMapper("ENTRY_SET", keyType.getFileType().toLowerCase()+"2"+valueType.getFileType()+"EntrySet");
|
||||
addFunctionMappers("FIRST_ENTRY_KEY", "first%sKey");
|
||||
addFunctionValueMappers("FIRST_ENTRY_VALUE", "first%sValue");
|
||||
if(keyType.isObject()) addFunctionValueMapper("GET_VALUE", valueType.isObject() ? "getObject" : "get");
|
||||
else addSimpleMapper("GET_VALUE", "get");
|
||||
addFunctionMappers("LAST_ENTRY_KEY", "last%sKey");
|
||||
addFunctionValueMappers("LAST_ENTRY_VALUE", "last%sValue");
|
||||
addFunctionValueMapper("MERGE", "merge");
|
||||
addFunctionMappers("POLL_FIRST_ENTRY_KEY", "pollFirst%sKey");
|
||||
addFunctionMappers("POLL_LAST_ENTRY_KEY", "pollLast%sKey");
|
||||
if(keyType.isObject()) addFunctionMapper("REMOVE_VALUE", "rem");
|
||||
else addSimpleMapper("REMOVE_VALUE", "remove");
|
||||
addFunctionMapper("REMOVE", "remove");
|
||||
addFunctionValueMappers("REPLACE_VALUES", valueType.isObject() ? "replaceObjects" : "replace%ss");
|
||||
addFunctionValueMappers("SUPPLY_IF_ABSENT", "supply%sIfAbsent");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadClasses()
|
||||
{
|
||||
//Implementation Classes
|
||||
addAbstractBiMapper("IMMUTABLE_HASH_MAP", "Immutable%sOpenHashMap", "2");
|
||||
addBiClassMapper("LINKED_CUSTOM_HASH_MAP", "LinkedOpenCustomHashMap", "2");
|
||||
addBiClassMapper("LINKED_HASH_MAP", "LinkedOpenHashMap", "2");
|
||||
addBiClassMapper("CUSTOM_HASH_MAP", "OpenCustomHashMap", "2");
|
||||
addBiClassMapper("CONCURRENT_HASH_MAP", "ConcurrentOpenHashMap", "2");
|
||||
addBiClassMapper("AVL_TREE_MAP", "AVLTreeMap", "2");
|
||||
addBiClassMapper("RB_TREE_MAP", "RBTreeMap", "2");
|
||||
addFunctionValueMappers("LINKED_ENUM_MAP", valueType.isObject() ? "LinkedEnum2ObjectMap" : "LinkedEnum2%sMap");
|
||||
addFunctionValueMappers("ENUM_MAP", valueType.isObject() ? "Enum2ObjectMap" : "Enum2%sMap");
|
||||
addBiClassMapper("HASH_MAP", "OpenHashMap", "2");
|
||||
addBiClassMapper("ARRAY_MAP", "ArrayMap", "2");
|
||||
|
||||
//Abstract Classes
|
||||
addAbstractBiMapper("ABSTRACT_MAP", "Abstract%sMap", "2");
|
||||
|
||||
//Helper Classes
|
||||
addBiClassMapper("MAPS", "Maps", "2");
|
||||
|
||||
//Interfaces
|
||||
addBiClassMapper("NAVIGABLE_MAP", "NavigableMap", "2");
|
||||
addBiClassMapper("ORDERED_MAP", "OrderedMap", "2");
|
||||
addBiClassMapper("SORTED_MAP", "SortedMap", "2");
|
||||
addBiClassMapper("CONCURRENT_MAP", "ConcurrentMap", "2");
|
||||
addBiClassMapper("MAP", "Map", "2");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadTestClasses()
|
||||
{
|
||||
//Implementation Classes
|
||||
addAbstractBiMapper("SIMPLE_TEST_MAP", "Test%sMap", "2");
|
||||
addBiClassMapper("MAP_TESTS", "MapTests", "2");
|
||||
addAbstractBiMapper("NAVIGABLE_MAP_TEST_BUILDER", "%sNavigableMapTestSuiteBuilder", "2");
|
||||
addAbstractBiMapper("SORTED_MAP_TEST_BUILDER", "%sSortedMapTestSuiteBuilder", "2");
|
||||
addAbstractBiMapper("ORDERED_MAP_TEST_BUILDER", "%sOrderedMapTestSuiteBuilder", "2");
|
||||
addAbstractBiMapper("MAP_TEST_BUILDER", "%sMapTestSuiteBuilder", "2");
|
||||
|
||||
//Abstract Classes
|
||||
addAbstractBiMapper("ABSTRACT_MAP_TESTER", "Abstract%sMapTester", "2");
|
||||
|
||||
//Helper Classes
|
||||
addAbstractBiMapper("MAP_CONSTRUCTOR_TESTS", "%sMapConstructorTests", "2");
|
||||
addAbstractBiMapper("SIMPLE_MAP_TEST_GENERATOR", "Simple%sMapTestGenerator", "2");
|
||||
addAbstractBiMapper("DERIVED_MAP_GENERATORS", "Derived%sMapGenerators", "2");
|
||||
addAbstractBiMapper("TEST_ORDERED_MAP_GENERATOR", "Test%sOrderedMapGenerator", "2");
|
||||
addAbstractBiMapper("TEST_SORTED_MAP_GENERATOR", "Test%sSortedMapGenerator", "2");
|
||||
addAbstractBiMapper("TEST_MAP_GENERATOR", "Test%sMapGenerator", "2");
|
||||
}
|
||||
}
|
|
@ -1,266 +1,266 @@
|
|||
package speiger.src.collections.PACKAGE.collections;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Objects;
|
||||
import java.util.AbstractCollection;
|
||||
#if TYPE_OBJECT
|
||||
import java.util.function.Consumer;
|
||||
#endif
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
||||
#endif
|
||||
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
||||
|
||||
/**
|
||||
* Abstract Type Specific Collection that reduces boxing/unboxing
|
||||
* @Type(T)
|
||||
*/
|
||||
public abstract class ABSTRACT_COLLECTION KEY_GENERIC_TYPE extends AbstractCollection<CLASS_TYPE> implements COLLECTION KEY_GENERIC_TYPE
|
||||
{
|
||||
@Override
|
||||
public abstract ITERATOR KEY_GENERIC_TYPE iterator();
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
/** {@inheritDoc}
|
||||
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||
* @deprecated Please use the corresponding type-specific function instead.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean add(CLASS_TYPE e) { return COLLECTION.super.add(e); }
|
||||
|
||||
#endif
|
||||
@Override
|
||||
public boolean addAll(COLLECTION KEY_GENERIC_TYPE c) {
|
||||
boolean modified = false;
|
||||
for(ITERATOR KEY_GENERIC_TYPE iter = c.iterator();iter.hasNext();modified |= add(iter.NEXT()));
|
||||
return modified;
|
||||
}
|
||||
|
||||
@Override
|
||||
public COLLECTION KEY_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); }
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
/** {@inheritDoc}
|
||||
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||
* @deprecated Please use the corresponding type-specific function instead.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean contains(Object e) { return COLLECTION.super.contains(e); }
|
||||
|
||||
/**
|
||||
* A Type-Specific implementation of contains. This implementation iterates over the elements and returns true if the value match.
|
||||
* @param e the element that should be searched for.
|
||||
* @return true if the value was found.
|
||||
*/
|
||||
@Override
|
||||
public boolean contains(KEY_TYPE e) {
|
||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) { if(KEY_EQUALS(iter.NEXT(), e)) return true; }
|
||||
return false;
|
||||
}
|
||||
|
||||
/** {@inheritDoc}
|
||||
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||
* @deprecated Please use the corresponding type-specific function instead.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean addAll(Collection<? extends CLASS_TYPE> c)
|
||||
{
|
||||
return c instanceof COLLECTION ? addAll((COLLECTION KEY_GENERIC_TYPE)c) : super.addAll(c);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* A Type-Specific implementation of containsAll. This implementation iterates over all elements and checks all elements are present in the other collection.
|
||||
* @param c the collection that should be checked if it contains all elements.
|
||||
* @return true if all elements were found in the collection
|
||||
* @throws java.lang.NullPointerException if the collection is null
|
||||
*/
|
||||
@Override
|
||||
public boolean containsAll(COLLECTION KEY_GENERIC_TYPE c) {
|
||||
Objects.requireNonNull(c);
|
||||
if(c.isEmpty()) return true;
|
||||
for(ITERATOR KEY_GENERIC_TYPE iter = c.iterator();iter.hasNext();)
|
||||
if(!contains(iter.NEXT()))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsAll(Collection<?> c) {
|
||||
Objects.requireNonNull(c);
|
||||
return c instanceof COLLECTION ? containsAll((COLLECTION KEY_GENERIC_TYPE)c) : super.containsAll(c);
|
||||
}
|
||||
|
||||
/**
|
||||
* This implementation iterates over the elements of the collection and checks if they are stored in this collection
|
||||
* @param c the elements that should be checked for
|
||||
* @return true if any element is in this collection
|
||||
* @throws java.lang.NullPointerException if the collection is null
|
||||
*/
|
||||
@Override
|
||||
@Primitive
|
||||
public boolean containsAny(Collection<?> c) {
|
||||
Objects.requireNonNull(c);
|
||||
if(c.isEmpty()) return false;
|
||||
for(Object e : c)
|
||||
if(contains(e))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* This implementation iterates over the elements of the collection and checks if they are stored in this collection.
|
||||
* @param c the elements that should be checked for
|
||||
* @return true if any element is in this collection
|
||||
* @throws java.lang.NullPointerException if the collection is null
|
||||
*/
|
||||
@Override
|
||||
public boolean containsAny(COLLECTION KEY_GENERIC_TYPE c) {
|
||||
Objects.requireNonNull(c);
|
||||
if(c.isEmpty()) return false;
|
||||
for(ITERATOR KEY_GENERIC_TYPE iter = c.iterator();iter.hasNext();)
|
||||
if(contains(iter.NEXT()))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
/** {@inheritDoc}
|
||||
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||
* @deprecated Please use the corresponding type-specific function instead.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean remove(Object e) { return COLLECTION.super.remove(e); }
|
||||
|
||||
/**
|
||||
* A Type-Specific implementation of remove. This implementation iterates over the elements until it finds the element that is searched for or it runs out of elements.
|
||||
* It stops after finding the first element
|
||||
* @param e the element that is searched for
|
||||
* @return true if the element was found and removed.
|
||||
*/
|
||||
@Override
|
||||
public boolean REMOVE_KEY(KEY_TYPE e) {
|
||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||
if(KEY_EQUALS(iter.NEXT(), e)) {
|
||||
iter.remove();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
/**
|
||||
* A Type-Specific implementation of removeAll. This Implementation iterates over all elements and removes them as they were found in the other collection.
|
||||
* @param c the elements that should be deleted
|
||||
* @return true if the collection was modified.
|
||||
* @throws java.lang.NullPointerException if the collection is null
|
||||
*/
|
||||
@Override
|
||||
public boolean removeAll(COLLECTION KEY_GENERIC_TYPE c) {
|
||||
Objects.requireNonNull(c);
|
||||
if(c.isEmpty()) return false;
|
||||
boolean modified = false;
|
||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||
if(c.contains(iter.NEXT())) {
|
||||
iter.remove();
|
||||
modified = true;
|
||||
}
|
||||
}
|
||||
return modified;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeAll(COLLECTION KEY_GENERIC_TYPE c, CONSUMER KEY_GENERIC_TYPE r) {
|
||||
Objects.requireNonNull(c);
|
||||
if(c.isEmpty()) return false;
|
||||
Objects.requireNonNull(r);
|
||||
boolean modified = false;
|
||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||
KEY_TYPE e = iter.NEXT();
|
||||
if(c.contains(e)) {
|
||||
r.accept(e);
|
||||
iter.remove();
|
||||
modified = true;
|
||||
}
|
||||
}
|
||||
return modified;
|
||||
}
|
||||
|
||||
/**
|
||||
* A Type-Specific implementation of retainAll. This Implementation iterates over all elements and removes them as they were not found in the other collection.
|
||||
* @param c the elements that should be kept
|
||||
* @return true if the collection was modified.
|
||||
* @throws java.lang.NullPointerException if the collection is null
|
||||
*/
|
||||
@Override
|
||||
public boolean retainAll(COLLECTION KEY_GENERIC_TYPE c) {
|
||||
Objects.requireNonNull(c);
|
||||
if(c.isEmpty()) {
|
||||
boolean modified = !isEmpty();
|
||||
clear();
|
||||
return modified;
|
||||
}
|
||||
boolean modified = false;
|
||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||
if(!c.contains(iter.NEXT())) {
|
||||
iter.remove();
|
||||
modified = true;
|
||||
}
|
||||
}
|
||||
return modified;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean retainAll(COLLECTION KEY_GENERIC_TYPE c, CONSUMER KEY_GENERIC_TYPE r) {
|
||||
Objects.requireNonNull(c);
|
||||
Objects.requireNonNull(r);
|
||||
if(c.isEmpty()) {
|
||||
boolean modified = !isEmpty();
|
||||
forEach(r);
|
||||
clear();
|
||||
return modified;
|
||||
}
|
||||
boolean modified = false;
|
||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||
KEY_TYPE e = iter.NEXT();
|
||||
if(!c.contains(e)) {
|
||||
r.accept(e);
|
||||
iter.remove();
|
||||
modified = true;
|
||||
}
|
||||
}
|
||||
return modified;
|
||||
}
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
/**
|
||||
* A Type-Specific implementation of toArray that links to {@link #TO_ARRAY(KEY_TYPE[])} with a newly created array.
|
||||
* @return an array containing all of the elements in this collection
|
||||
*/
|
||||
@Override
|
||||
public KEY_TYPE[] TO_ARRAY() {
|
||||
if(isEmpty()) return ARRAYS.EMPTY_ARRAY;
|
||||
return TO_ARRAY(new KEY_TYPE[size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* A Type-Specific implementation of toArray. This implementation iterates over all elements and unwraps them into primitive type.
|
||||
* @param a array that the elements should be injected to. If null or to small a new array with the right size is created
|
||||
* @return an array containing all of the elements in this collection
|
||||
*/
|
||||
@Override
|
||||
public KEY_TYPE[] TO_ARRAY(KEY_TYPE[] a) {
|
||||
if(a == null || a.length < size()) a = new KEY_TYPE[size()];
|
||||
ITERATORS.unwrap(a, iterator());
|
||||
if (a.length > size()) a[size()] = EMPTY_KEY_VALUE;
|
||||
return a;
|
||||
}
|
||||
#endif
|
||||
package speiger.src.collections.PACKAGE.collections;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Objects;
|
||||
import java.util.AbstractCollection;
|
||||
#if TYPE_OBJECT
|
||||
import java.util.function.Consumer;
|
||||
#endif
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
||||
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Abstract Type Specific Collection that reduces boxing/unboxing
|
||||
* @Type(T)
|
||||
*/
|
||||
public abstract class ABSTRACT_COLLECTION KEY_GENERIC_TYPE extends AbstractCollection<CLASS_TYPE> implements COLLECTION KEY_GENERIC_TYPE
|
||||
{
|
||||
@Override
|
||||
public abstract ITERATOR KEY_GENERIC_TYPE iterator();
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
/** {@inheritDoc}
|
||||
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||
* @deprecated Please use the corresponding type-specific function instead.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean add(CLASS_TYPE e) { return COLLECTION.super.add(e); }
|
||||
|
||||
#endif
|
||||
@Override
|
||||
public boolean addAll(COLLECTION KEY_GENERIC_TYPE c) {
|
||||
boolean modified = false;
|
||||
for(ITERATOR KEY_GENERIC_TYPE iter = c.iterator();iter.hasNext();modified |= add(iter.NEXT()));
|
||||
return modified;
|
||||
}
|
||||
|
||||
@Override
|
||||
public COLLECTION KEY_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); }
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
/** {@inheritDoc}
|
||||
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||
* @deprecated Please use the corresponding type-specific function instead.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean contains(Object e) { return COLLECTION.super.contains(e); }
|
||||
|
||||
/**
|
||||
* A Type-Specific implementation of contains. This implementation iterates over the elements and returns true if the value match.
|
||||
* @param e the element that should be searched for.
|
||||
* @return true if the value was found.
|
||||
*/
|
||||
@Override
|
||||
public boolean contains(KEY_TYPE e) {
|
||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) { if(KEY_EQUALS(iter.NEXT(), e)) return true; }
|
||||
return false;
|
||||
}
|
||||
|
||||
/** {@inheritDoc}
|
||||
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||
* @deprecated Please use the corresponding type-specific function instead.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean addAll(Collection<? extends CLASS_TYPE> c)
|
||||
{
|
||||
return c instanceof COLLECTION ? addAll((COLLECTION KEY_GENERIC_TYPE)c) : super.addAll(c);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* A Type-Specific implementation of containsAll. This implementation iterates over all elements and checks all elements are present in the other collection.
|
||||
* @param c the collection that should be checked if it contains all elements.
|
||||
* @return true if all elements were found in the collection
|
||||
* @throws java.lang.NullPointerException if the collection is null
|
||||
*/
|
||||
@Override
|
||||
public boolean containsAll(COLLECTION KEY_GENERIC_TYPE c) {
|
||||
Objects.requireNonNull(c);
|
||||
if(c.isEmpty()) return true;
|
||||
for(ITERATOR KEY_GENERIC_TYPE iter = c.iterator();iter.hasNext();)
|
||||
if(!contains(iter.NEXT()))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsAll(Collection<?> c) {
|
||||
Objects.requireNonNull(c);
|
||||
return c instanceof COLLECTION ? containsAll((COLLECTION KEY_GENERIC_TYPE)c) : super.containsAll(c);
|
||||
}
|
||||
|
||||
/**
|
||||
* This implementation iterates over the elements of the collection and checks if they are stored in this collection
|
||||
* @param c the elements that should be checked for
|
||||
* @return true if any element is in this collection
|
||||
* @throws java.lang.NullPointerException if the collection is null
|
||||
*/
|
||||
@Override
|
||||
@Primitive
|
||||
public boolean containsAny(Collection<?> c) {
|
||||
Objects.requireNonNull(c);
|
||||
if(c.isEmpty()) return false;
|
||||
for(Object e : c)
|
||||
if(contains(e))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* This implementation iterates over the elements of the collection and checks if they are stored in this collection.
|
||||
* @param c the elements that should be checked for
|
||||
* @return true if any element is in this collection
|
||||
* @throws java.lang.NullPointerException if the collection is null
|
||||
*/
|
||||
@Override
|
||||
public boolean containsAny(COLLECTION KEY_GENERIC_TYPE c) {
|
||||
Objects.requireNonNull(c);
|
||||
if(c.isEmpty()) return false;
|
||||
for(ITERATOR KEY_GENERIC_TYPE iter = c.iterator();iter.hasNext();)
|
||||
if(contains(iter.NEXT()))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
/** {@inheritDoc}
|
||||
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||
* @deprecated Please use the corresponding type-specific function instead.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean remove(Object e) { return COLLECTION.super.remove(e); }
|
||||
|
||||
/**
|
||||
* A Type-Specific implementation of remove. This implementation iterates over the elements until it finds the element that is searched for or it runs out of elements.
|
||||
* It stops after finding the first element
|
||||
* @param e the element that is searched for
|
||||
* @return true if the element was found and removed.
|
||||
*/
|
||||
@Override
|
||||
public boolean REMOVE_KEY(KEY_TYPE e) {
|
||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||
if(KEY_EQUALS(iter.NEXT(), e)) {
|
||||
iter.remove();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
/**
|
||||
* A Type-Specific implementation of removeAll. This Implementation iterates over all elements and removes them as they were found in the other collection.
|
||||
* @param c the elements that should be deleted
|
||||
* @return true if the collection was modified.
|
||||
* @throws java.lang.NullPointerException if the collection is null
|
||||
*/
|
||||
@Override
|
||||
public boolean removeAll(COLLECTION KEY_GENERIC_TYPE c) {
|
||||
Objects.requireNonNull(c);
|
||||
if(c.isEmpty()) return false;
|
||||
boolean modified = false;
|
||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||
if(c.contains(iter.NEXT())) {
|
||||
iter.remove();
|
||||
modified = true;
|
||||
}
|
||||
}
|
||||
return modified;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeAll(COLLECTION KEY_GENERIC_TYPE c, CONSUMER KEY_GENERIC_TYPE r) {
|
||||
Objects.requireNonNull(c);
|
||||
if(c.isEmpty()) return false;
|
||||
Objects.requireNonNull(r);
|
||||
boolean modified = false;
|
||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||
KEY_TYPE e = iter.NEXT();
|
||||
if(c.contains(e)) {
|
||||
r.accept(e);
|
||||
iter.remove();
|
||||
modified = true;
|
||||
}
|
||||
}
|
||||
return modified;
|
||||
}
|
||||
|
||||
/**
|
||||
* A Type-Specific implementation of retainAll. This Implementation iterates over all elements and removes them as they were not found in the other collection.
|
||||
* @param c the elements that should be kept
|
||||
* @return true if the collection was modified.
|
||||
* @throws java.lang.NullPointerException if the collection is null
|
||||
*/
|
||||
@Override
|
||||
public boolean retainAll(COLLECTION KEY_GENERIC_TYPE c) {
|
||||
Objects.requireNonNull(c);
|
||||
if(c.isEmpty()) {
|
||||
boolean modified = !isEmpty();
|
||||
clear();
|
||||
return modified;
|
||||
}
|
||||
boolean modified = false;
|
||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||
if(!c.contains(iter.NEXT())) {
|
||||
iter.remove();
|
||||
modified = true;
|
||||
}
|
||||
}
|
||||
return modified;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean retainAll(COLLECTION KEY_GENERIC_TYPE c, CONSUMER KEY_GENERIC_TYPE r) {
|
||||
Objects.requireNonNull(c);
|
||||
Objects.requireNonNull(r);
|
||||
if(c.isEmpty()) {
|
||||
boolean modified = !isEmpty();
|
||||
forEach(r);
|
||||
clear();
|
||||
return modified;
|
||||
}
|
||||
boolean modified = false;
|
||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||
KEY_TYPE e = iter.NEXT();
|
||||
if(!c.contains(e)) {
|
||||
r.accept(e);
|
||||
iter.remove();
|
||||
modified = true;
|
||||
}
|
||||
}
|
||||
return modified;
|
||||
}
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
/**
|
||||
* A Type-Specific implementation of toArray that links to {@link #TO_ARRAY(KEY_TYPE[])} with a newly created array.
|
||||
* @return an array containing all of the elements in this collection
|
||||
*/
|
||||
@Override
|
||||
public KEY_TYPE[] TO_ARRAY() {
|
||||
if(isEmpty()) return ARRAYS.EMPTY_ARRAY;
|
||||
return TO_ARRAY(new KEY_TYPE[size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* A Type-Specific implementation of toArray. This implementation iterates over all elements and unwraps them into primitive type.
|
||||
* @param a array that the elements should be injected to. If null or to small a new array with the right size is created
|
||||
* @return an array containing all of the elements in this collection
|
||||
*/
|
||||
@Override
|
||||
public KEY_TYPE[] TO_ARRAY(KEY_TYPE[] a) {
|
||||
if(a == null || a.length < size()) a = new KEY_TYPE[size()];
|
||||
ITERATORS.unwrap(a, iterator());
|
||||
if (a.length > size()) a[size()] = EMPTY_KEY_VALUE;
|
||||
return a;
|
||||
}
|
||||
#endif
|
||||
}
|
|
@ -1,322 +1,323 @@
|
|||
package speiger.src.collections.PACKAGE.collections;
|
||||
|
||||
import java.util.Collection;
|
||||
#if PRIMITIVES
|
||||
import java.util.Objects;
|
||||
import java.util.function.JAVA_PREDICATE;
|
||||
import java.util.function.Predicate;
|
||||
#if SPLIT_ITERATOR_FEATURE && STREAM_FEATURE
|
||||
import java.util.stream.JAVA_STREAM;
|
||||
import java.util.stream.StreamSupport;
|
||||
#endif
|
||||
#endif
|
||||
#if TYPE_OBJECT
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.IntFunction;
|
||||
#else
|
||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||
#endif
|
||||
#if SPLIT_ITERATOR_FEATURE
|
||||
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
||||
#endif
|
||||
import speiger.src.collections.PACKAGE.utils.COLLECTIONS;
|
||||
import speiger.src.collections.utils.ISizeProvider;
|
||||
import speiger.src.collections.utils.SanityChecks;
|
||||
|
||||
/**
|
||||
* A Type-Specific {@link Collection} that reduces (un)boxing
|
||||
* @Type(T)
|
||||
*/
|
||||
public interface COLLECTION KEY_GENERIC_TYPE extends Collection<CLASS_TYPE>, ITERABLE KEY_GENERIC_TYPE, ISizeProvider
|
||||
{
|
||||
#if !TYPE_OBJECT
|
||||
/**
|
||||
* A Type-Specific add function to reduce (un)boxing
|
||||
* @param o the element that should be added
|
||||
* @return true if the element was added to the collection
|
||||
*/
|
||||
public boolean add(KEY_TYPE o);
|
||||
|
||||
#endif
|
||||
/**
|
||||
* A Type-Specific addAll function to reduce (un)boxing
|
||||
* @param c the collection of elements that should be added
|
||||
* @return true if elements were added into the collection
|
||||
*/
|
||||
public boolean addAll(COLLECTION KEY_GENERIC_TYPE c);
|
||||
|
||||
/**
|
||||
* A Type-Specific Array based addAll method to reduce the amount of Wrapping
|
||||
* @param e the elements that should be added
|
||||
* @return if the collection was modified
|
||||
*/
|
||||
public default boolean addAll(KEY_TYPE... e) { return addAll(e, 0, e.length); }
|
||||
|
||||
/**
|
||||
* A Type-Specific Array based addAll method to reduce the amount of Wrapping
|
||||
* @param e the elements that should be added
|
||||
* @param length how many elements of the array should be added
|
||||
* @return if the collection was modified
|
||||
*/
|
||||
public default boolean addAll(KEY_TYPE[] e, int length) { return addAll(e, 0, length); }
|
||||
|
||||
/**
|
||||
* A Type-Specific Array based addAll method to reduce the amount of Wrapping
|
||||
* @param e the elements that should be added
|
||||
* @param offset where to start within the array
|
||||
* @param length how many elements of the array should be added
|
||||
* @return if the collection was modified
|
||||
*/
|
||||
public default boolean addAll(KEY_TYPE[] e, int offset, int length) {
|
||||
if(length <= 0) return false;
|
||||
SanityChecks.checkArrayCapacity(e.length, offset, length);
|
||||
boolean added = false;
|
||||
for(int i = 0;i<length;i++) {
|
||||
if(add(e[offset+i])) added = true;
|
||||
}
|
||||
return added;
|
||||
}
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
/**
|
||||
* A Type-Specific contains function to reduce (un)boxing
|
||||
* @param o the element that is checked for
|
||||
* @return true if the element is found in the collection
|
||||
*/
|
||||
public boolean contains(KEY_TYPE o);
|
||||
|
||||
#endif
|
||||
/**
|
||||
* A Type-Specific containsAll function to reduce (un)boxing
|
||||
* @param c the collection of elements that should be tested for
|
||||
* @return true if all the element is found in the collection
|
||||
*/
|
||||
public boolean containsAll(COLLECTION KEY_GENERIC_TYPE c);
|
||||
|
||||
/**
|
||||
* A Type-Specific containsAny function to reduce (un)boxing
|
||||
* @param c the collection of elements that should be tested for
|
||||
* @return true if any element was found
|
||||
*/
|
||||
public boolean containsAny(COLLECTION KEY_GENERIC_TYPE c);
|
||||
|
||||
/**
|
||||
* Returns true if any element of the Collection is found in the provided collection.
|
||||
* A Small Optimization function to find out of any element is present when comparing collections and not all of them.
|
||||
* @param c the collection of elements that should be tested for
|
||||
* @return true if any element was found.
|
||||
*/
|
||||
@Primitive
|
||||
public boolean containsAny(Collection<?> c);
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
/**
|
||||
* A Type-Specific remove function that reduces (un)boxing.
|
||||
* @param o the element that should be removed
|
||||
* @return true if the element was removed
|
||||
* @see Collection#remove(Object)
|
||||
*/
|
||||
public boolean REMOVE_KEY(KEY_TYPE o);
|
||||
|
||||
#endif
|
||||
/**
|
||||
* A Type-Specific removeAll function that reduces (un)boxing.
|
||||
* @param c the collection of elements that should be removed
|
||||
* @return true if any element was removed
|
||||
* @see Collection#removeAll(Collection)
|
||||
*/
|
||||
public boolean removeAll(COLLECTION KEY_GENERIC_TYPE c);
|
||||
|
||||
/**
|
||||
* A Type-Specific removeAll function that reduces (un)boxing.
|
||||
* It also notifies the remover of which exact element is going to be removed.
|
||||
* @param c the collection of elements that should be removed
|
||||
* @param r elements that got removed
|
||||
* @return true if any element was removed
|
||||
* @see Collection#removeAll(Collection)
|
||||
*/
|
||||
public boolean removeAll(COLLECTION KEY_GENERIC_TYPE c, CONSUMER KEY_GENERIC_TYPE r);
|
||||
|
||||
/**
|
||||
* A Type-Specific retainAll function that reduces (un)boxing.
|
||||
* @param c the collection of elements that should be kept
|
||||
* @return true if any element was removed
|
||||
* @see Collection#retainAll(Collection)
|
||||
*/
|
||||
public boolean retainAll(COLLECTION KEY_GENERIC_TYPE c);
|
||||
|
||||
/**
|
||||
* A Type-Specific retainAll function that reduces (un)boxing.
|
||||
* It also notifies the remover of which exact element is going to be removed.
|
||||
* @param c the collection of elements that should be kept
|
||||
* @param r elements that got removed
|
||||
* @return true if any element was removed
|
||||
* @see Collection#retainAll(Collection)
|
||||
*/
|
||||
public boolean retainAll(COLLECTION KEY_GENERIC_TYPE c, CONSUMER KEY_GENERIC_TYPE r);
|
||||
|
||||
/**
|
||||
* A Helper function to reduce the usage of Streams and allows to collect all elements
|
||||
* @param collection that the elements should be inserted to
|
||||
* @param <E> the collection type
|
||||
* @return the input with the desired elements
|
||||
*/
|
||||
default <E extends COLLECTION KEY_GENERIC_TYPE> E pour(E collection) {
|
||||
collection.addAll(this);
|
||||
return collection;
|
||||
}
|
||||
|
||||
/**
|
||||
* A Function that does a shallow clone of the Collection itself.
|
||||
* This function is more optimized then a copy constructor since the Collection does not have to be unsorted/resorted.
|
||||
* It can be compared to Cloneable but with less exception risk
|
||||
* @return a Shallow Copy of the collection
|
||||
* @note Wrappers and view collections will not support this feature
|
||||
*/
|
||||
public COLLECTION KEY_GENERIC_TYPE copy();
|
||||
|
||||
#if TYPE_OBJECT
|
||||
/**
|
||||
* A Helper function that simplifies the process of creating a new Array.
|
||||
* @param action the array creation function
|
||||
* @return an array containing all of the elements in this collection
|
||||
* @see Collection#toArray(Object[])
|
||||
*/
|
||||
default <E> E[] TO_ARRAY(IntFunction<E[]> action) {
|
||||
return TO_ARRAY(action.apply(size()));
|
||||
}
|
||||
|
||||
#else
|
||||
/**
|
||||
* A Type-Specific toArray function that delegates to {@link #TO_ARRAY(KEY_TYPE[])} with a newly created array.
|
||||
* @return an array containing all of the elements in this collection
|
||||
* @see Collection#toArray()
|
||||
*/
|
||||
public KEY_TYPE[] TO_ARRAY();
|
||||
|
||||
/**
|
||||
* A Type-Specific toArray function that reduces (un)boxing.
|
||||
* @param a array that the elements should be injected to. If null or to small a new array with the right size is created
|
||||
* @return an array containing all of the elements in this collection
|
||||
* @see Collection#toArray(Object[])
|
||||
*/
|
||||
public KEY_TYPE[] TO_ARRAY(KEY_TYPE[] a);
|
||||
|
||||
#if PRIMITIVES
|
||||
/** {@inheritDoc}
|
||||
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||
* @deprecated Please use the corresponding type-specific function instead.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public default boolean removeIf(Predicate<? super CLASS_TYPE> filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
#if TYPE_BYTE || TYPE_SHORT || TYPE_CHAR || TYPE_FLOAT
|
||||
return remIf(v -> filter.test(KEY_TO_OBJ(SanityChecks.SANITY_CAST(v))));
|
||||
#else
|
||||
return remIf(v -> filter.test(KEY_TO_OBJ(v)));
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* A Type-Specific removeIf function to reduce (un)boxing.
|
||||
* <p>Removes elements that were selected by the filter
|
||||
* @see Collection#removeIf(Predicate)
|
||||
* @param filter Filters the elements that should be removed
|
||||
* @return true if the collection was modified
|
||||
* @throws java.lang.NullPointerException if filter is null
|
||||
*/
|
||||
public default boolean remIf(JAVA_PREDICATE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
boolean removed = false;
|
||||
final ITERATOR each = iterator();
|
||||
while (each.hasNext()) {
|
||||
if (filter.test(each.NEXT())) {
|
||||
each.remove();
|
||||
removed = true;
|
||||
}
|
||||
}
|
||||
return removed;
|
||||
}
|
||||
|
||||
#endif
|
||||
/** {@inheritDoc}
|
||||
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||
* @deprecated Please use the corresponding type-specific function instead.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public default boolean add(CLASS_TYPE o) { return add(OBJ_TO_KEY(o)); }
|
||||
|
||||
/** {@inheritDoc}
|
||||
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||
* @deprecated Please use the corresponding type-specific function instead.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public default boolean contains(Object o) { return o != null && contains(CLASS_TO_KEY(o)); }
|
||||
|
||||
/** {@inheritDoc}
|
||||
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||
* @deprecated Please use the corresponding type-specific function instead.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public default boolean remove(Object o) { return o != null && REMOVE_KEY(CLASS_TO_KEY(o)); }
|
||||
|
||||
#endif
|
||||
/**
|
||||
* Returns a Type-Specific Iterator to reduce (un)boxing
|
||||
* @return a iterator of the collection
|
||||
* @see Collection#iterator()
|
||||
*/
|
||||
@Override
|
||||
public ITERATOR KEY_GENERIC_TYPE iterator();
|
||||
|
||||
/**
|
||||
* Creates a Wrapped Collection that is Synchronized
|
||||
* @return a new Collection that is synchronized
|
||||
* @see COLLECTIONS#synchronize
|
||||
*/
|
||||
public default COLLECTION KEY_GENERIC_TYPE synchronize() { return COLLECTIONS.synchronize(this); }
|
||||
|
||||
/**
|
||||
* Creates a Wrapped Collection that is Synchronized
|
||||
* @param mutex is the controller of the synchronization block
|
||||
* @return a new Collection Wrapper that is synchronized
|
||||
* @see COLLECTIONS#synchronize
|
||||
*/
|
||||
public default COLLECTION KEY_GENERIC_TYPE synchronize(Object mutex) { return COLLECTIONS.synchronize(this, mutex); }
|
||||
|
||||
/**
|
||||
* Creates a Wrapped Collection that is unmodifiable
|
||||
* @return a new Collection Wrapper that is unmodifiable
|
||||
* @see COLLECTIONS#unmodifiable
|
||||
*/
|
||||
public default COLLECTION KEY_GENERIC_TYPE unmodifiable() { return COLLECTIONS.unmodifiable(this); }
|
||||
|
||||
#if SPLIT_ITERATOR_FEATURE
|
||||
#if PRIMITIVES
|
||||
/**
|
||||
* Returns a Java-Type-Specific Stream to reduce boxing/unboxing.
|
||||
* @return a Stream of the closest java type
|
||||
*/
|
||||
default JAVA_STREAM primitiveStream() { return StreamSupport.NEW_STREAM(SPLIT_ITERATORS.createJavaSplititerator(this, 0), false); }
|
||||
|
||||
/**
|
||||
* Returns a Java-Type-Specific Parallel Stream to reduce boxing/unboxing.
|
||||
* @return a Stream of the closest java type
|
||||
*/
|
||||
default JAVA_STREAM parallelPrimitiveStream() { return StreamSupport.NEW_STREAM(SPLIT_ITERATORS.createJavaSplititerator(this, 0), true); }
|
||||
|
||||
#endif
|
||||
#if STREAM_FEATURE
|
||||
/**
|
||||
* A Type Specific Type Splititerator to reduce boxing/unboxing
|
||||
* @return type specific splititerator
|
||||
*/
|
||||
@Override
|
||||
default SPLIT_ITERATOR KEY_GENERIC_TYPE spliterator() { return SPLIT_ITERATORS.createSplititerator(this, 0); }
|
||||
#endif
|
||||
#endif
|
||||
package speiger.src.collections.PACKAGE.collections;
|
||||
|
||||
import java.util.Collection;
|
||||
#if PRIMITIVES
|
||||
import java.util.Objects;
|
||||
import java.util.function.JAVA_PREDICATE;
|
||||
import java.util.function.Predicate;
|
||||
#if SPLIT_ITERATOR_FEATURE && STREAM_FEATURE
|
||||
import java.util.stream.JAVA_STREAM;
|
||||
import java.util.stream.StreamSupport;
|
||||
#endif
|
||||
#endif
|
||||
#if TYPE_OBJECT
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.IntFunction;
|
||||
#else
|
||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||
#endif
|
||||
#if SPLIT_ITERATOR_FEATURE
|
||||
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
||||
#endif
|
||||
import speiger.src.collections.PACKAGE.utils.COLLECTIONS;
|
||||
import speiger.src.collections.utils.ISizeProvider;
|
||||
import speiger.src.collections.utils.SanityChecks;
|
||||
|
||||
/**
|
||||
* A Type-Specific {@link Collection} that reduces (un)boxing
|
||||
* @Type(T)
|
||||
*/
|
||||
public interface COLLECTION KEY_GENERIC_TYPE extends Collection<CLASS_TYPE>, ITERABLE KEY_GENERIC_TYPE, ISizeProvider
|
||||
{
|
||||
#if !TYPE_OBJECT
|
||||
/**
|
||||
* A Type-Specific add function to reduce (un)boxing
|
||||
* @param o the element that should be added
|
||||
* @return true if the element was added to the collection
|
||||
*/
|
||||
public boolean add(KEY_TYPE o);
|
||||
|
||||
#endif
|
||||
/**
|
||||
* A Type-Specific addAll function to reduce (un)boxing
|
||||
* @param c the collection of elements that should be added
|
||||
* @return true if elements were added into the collection
|
||||
*/
|
||||
public boolean addAll(COLLECTION KEY_GENERIC_TYPE c);
|
||||
|
||||
/**
|
||||
* A Type-Specific Array based addAll method to reduce the amount of Wrapping
|
||||
* @param e the elements that should be added
|
||||
* @return if the collection was modified
|
||||
*/
|
||||
public default boolean addAll(KEY_TYPE... e) { return addAll(e, 0, e.length); }
|
||||
|
||||
/**
|
||||
* A Type-Specific Array based addAll method to reduce the amount of Wrapping
|
||||
* @param e the elements that should be added
|
||||
* @param length how many elements of the array should be added
|
||||
* @return if the collection was modified
|
||||
*/
|
||||
public default boolean addAll(KEY_TYPE[] e, int length) { return addAll(e, 0, length); }
|
||||
|
||||
/**
|
||||
* A Type-Specific Array based addAll method to reduce the amount of Wrapping
|
||||
* @param e the elements that should be added
|
||||
* @param offset where to start within the array
|
||||
* @param length how many elements of the array should be added
|
||||
* @return if the collection was modified
|
||||
*/
|
||||
public default boolean addAll(KEY_TYPE[] e, int offset, int length) {
|
||||
if(length <= 0) return false;
|
||||
SanityChecks.checkArrayCapacity(e.length, offset, length);
|
||||
boolean added = false;
|
||||
for(int i = 0;i<length;i++) {
|
||||
if(add(e[offset+i])) added = true;
|
||||
}
|
||||
return added;
|
||||
}
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
/**
|
||||
* A Type-Specific contains function to reduce (un)boxing
|
||||
* @param o the element that is checked for
|
||||
* @return true if the element is found in the collection
|
||||
*/
|
||||
public boolean contains(KEY_TYPE o);
|
||||
|
||||
#endif
|
||||
/**
|
||||
* A Type-Specific containsAll function to reduce (un)boxing
|
||||
* @param c the collection of elements that should be tested for
|
||||
* @return true if all the element is found in the collection
|
||||
*/
|
||||
public boolean containsAll(COLLECTION KEY_GENERIC_TYPE c);
|
||||
|
||||
/**
|
||||
* A Type-Specific containsAny function to reduce (un)boxing
|
||||
* @param c the collection of elements that should be tested for
|
||||
* @return true if any element was found
|
||||
*/
|
||||
public boolean containsAny(COLLECTION KEY_GENERIC_TYPE c);
|
||||
|
||||
/**
|
||||
* Returns true if any element of the Collection is found in the provided collection.
|
||||
* A Small Optimization function to find out of any element is present when comparing collections and not all of them.
|
||||
* @param c the collection of elements that should be tested for
|
||||
* @return true if any element was found.
|
||||
*/
|
||||
@Primitive
|
||||
public boolean containsAny(Collection<?> c);
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
/**
|
||||
* A Type-Specific remove function that reduces (un)boxing.
|
||||
* @param o the element that should be removed
|
||||
* @return true if the element was removed
|
||||
* @see Collection#remove(Object)
|
||||
*/
|
||||
public boolean REMOVE_KEY(KEY_TYPE o);
|
||||
|
||||
#endif
|
||||
/**
|
||||
* A Type-Specific removeAll function that reduces (un)boxing.
|
||||
* @param c the collection of elements that should be removed
|
||||
* @return true if any element was removed
|
||||
* @see Collection#removeAll(Collection)
|
||||
*/
|
||||
public boolean removeAll(COLLECTION KEY_GENERIC_TYPE c);
|
||||
|
||||
/**
|
||||
* A Type-Specific removeAll function that reduces (un)boxing.
|
||||
* It also notifies the remover of which exact element is going to be removed.
|
||||
* @param c the collection of elements that should be removed
|
||||
* @param r elements that got removed
|
||||
* @return true if any element was removed
|
||||
* @see Collection#removeAll(Collection)
|
||||
*/
|
||||
public boolean removeAll(COLLECTION KEY_GENERIC_TYPE c, CONSUMER KEY_GENERIC_TYPE r);
|
||||
|
||||
/**
|
||||
* A Type-Specific retainAll function that reduces (un)boxing.
|
||||
* @param c the collection of elements that should be kept
|
||||
* @return true if any element was removed
|
||||
* @see Collection#retainAll(Collection)
|
||||
*/
|
||||
public boolean retainAll(COLLECTION KEY_GENERIC_TYPE c);
|
||||
|
||||
/**
|
||||
* A Type-Specific retainAll function that reduces (un)boxing.
|
||||
* It also notifies the remover of which exact element is going to be removed.
|
||||
* @param c the collection of elements that should be kept
|
||||
* @param r elements that got removed
|
||||
* @return true if any element was removed
|
||||
* @see Collection#retainAll(Collection)
|
||||
*/
|
||||
public boolean retainAll(COLLECTION KEY_GENERIC_TYPE c, CONSUMER KEY_GENERIC_TYPE r);
|
||||
|
||||
/**
|
||||
* A Helper function to reduce the usage of Streams and allows to collect all elements
|
||||
* @param collection that the elements should be inserted to
|
||||
* @param <E> the collection type
|
||||
* @return the input with the desired elements
|
||||
*/
|
||||
default <E extends COLLECTION KEY_GENERIC_TYPE> E pour(E collection) {
|
||||
collection.addAll(this);
|
||||
return collection;
|
||||
}
|
||||
|
||||
/**
|
||||
* A Function that does a shallow clone of the Collection itself.
|
||||
* This function is more optimized then a copy constructor since the Collection does not have to be unsorted/resorted.
|
||||
* It can be compared to Cloneable but with less exception risk
|
||||
* @return a Shallow Copy of the collection
|
||||
* @note Wrappers and view collections will not support this feature
|
||||
*/
|
||||
public COLLECTION KEY_GENERIC_TYPE copy();
|
||||
|
||||
#if TYPE_OBJECT
|
||||
/**
|
||||
* A Helper function that simplifies the process of creating a new Array.
|
||||
* @param action the array creation function
|
||||
* @param <E> the returning arrayType
|
||||
* @return an array containing all of the elements in this collection
|
||||
* @see Collection#toArray(Object[])
|
||||
*/
|
||||
default <E> E[] TO_ARRAY(IntFunction<E[]> action) {
|
||||
return TO_ARRAY(action.apply(size()));
|
||||
}
|
||||
|
||||
#else
|
||||
/**
|
||||
* A Type-Specific toArray function that delegates to {@link #TO_ARRAY(KEY_TYPE[])} with a newly created array.
|
||||
* @return an array containing all of the elements in this collection
|
||||
* @see Collection#toArray()
|
||||
*/
|
||||
public KEY_TYPE[] TO_ARRAY();
|
||||
|
||||
/**
|
||||
* A Type-Specific toArray function that reduces (un)boxing.
|
||||
* @param a array that the elements should be injected to. If null or to small a new array with the right size is created
|
||||
* @return an array containing all of the elements in this collection
|
||||
* @see Collection#toArray(Object[])
|
||||
*/
|
||||
public KEY_TYPE[] TO_ARRAY(KEY_TYPE[] a);
|
||||
|
||||
#if PRIMITIVES
|
||||
/** {@inheritDoc}
|
||||
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||
* @deprecated Please use the corresponding type-specific function instead.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public default boolean removeIf(Predicate<? super CLASS_TYPE> filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
#if TYPE_BYTE || TYPE_SHORT || TYPE_CHAR || TYPE_FLOAT
|
||||
return remIf(v -> filter.test(KEY_TO_OBJ(SanityChecks.SANITY_CAST(v))));
|
||||
#else
|
||||
return remIf(v -> filter.test(KEY_TO_OBJ(v)));
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* A Type-Specific removeIf function to reduce (un)boxing.
|
||||
* <p>Removes elements that were selected by the filter
|
||||
* @see Collection#removeIf(Predicate)
|
||||
* @param filter Filters the elements that should be removed
|
||||
* @return true if the collection was modified
|
||||
* @throws java.lang.NullPointerException if filter is null
|
||||
*/
|
||||
public default boolean remIf(JAVA_PREDICATE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
boolean removed = false;
|
||||
final ITERATOR each = iterator();
|
||||
while (each.hasNext()) {
|
||||
if (filter.test(each.NEXT())) {
|
||||
each.remove();
|
||||
removed = true;
|
||||
}
|
||||
}
|
||||
return removed;
|
||||
}
|
||||
|
||||
#endif
|
||||
/** {@inheritDoc}
|
||||
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||
* @deprecated Please use the corresponding type-specific function instead.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public default boolean add(CLASS_TYPE o) { return add(OBJ_TO_KEY(o)); }
|
||||
|
||||
/** {@inheritDoc}
|
||||
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||
* @deprecated Please use the corresponding type-specific function instead.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public default boolean contains(Object o) { return o != null && contains(CLASS_TO_KEY(o)); }
|
||||
|
||||
/** {@inheritDoc}
|
||||
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||
* @deprecated Please use the corresponding type-specific function instead.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public default boolean remove(Object o) { return o != null && REMOVE_KEY(CLASS_TO_KEY(o)); }
|
||||
|
||||
#endif
|
||||
/**
|
||||
* Returns a Type-Specific Iterator to reduce (un)boxing
|
||||
* @return a iterator of the collection
|
||||
* @see Collection#iterator()
|
||||
*/
|
||||
@Override
|
||||
public ITERATOR KEY_GENERIC_TYPE iterator();
|
||||
|
||||
/**
|
||||
* Creates a Wrapped Collection that is Synchronized
|
||||
* @return a new Collection that is synchronized
|
||||
* @see COLLECTIONS#synchronize
|
||||
*/
|
||||
public default COLLECTION KEY_GENERIC_TYPE synchronize() { return COLLECTIONS.synchronize(this); }
|
||||
|
||||
/**
|
||||
* Creates a Wrapped Collection that is Synchronized
|
||||
* @param mutex is the controller of the synchronization block
|
||||
* @return a new Collection Wrapper that is synchronized
|
||||
* @see COLLECTIONS#synchronize
|
||||
*/
|
||||
public default COLLECTION KEY_GENERIC_TYPE synchronize(Object mutex) { return COLLECTIONS.synchronize(this, mutex); }
|
||||
|
||||
/**
|
||||
* Creates a Wrapped Collection that is unmodifiable
|
||||
* @return a new Collection Wrapper that is unmodifiable
|
||||
* @see COLLECTIONS#unmodifiable
|
||||
*/
|
||||
public default COLLECTION KEY_GENERIC_TYPE unmodifiable() { return COLLECTIONS.unmodifiable(this); }
|
||||
|
||||
#if SPLIT_ITERATOR_FEATURE
|
||||
#if PRIMITIVES
|
||||
/**
|
||||
* Returns a Java-Type-Specific Stream to reduce boxing/unboxing.
|
||||
* @return a Stream of the closest java type
|
||||
*/
|
||||
default JAVA_STREAM primitiveStream() { return StreamSupport.NEW_STREAM(SPLIT_ITERATORS.createJavaSplititerator(this, 0), false); }
|
||||
|
||||
/**
|
||||
* Returns a Java-Type-Specific Parallel Stream to reduce boxing/unboxing.
|
||||
* @return a Stream of the closest java type
|
||||
*/
|
||||
default JAVA_STREAM parallelPrimitiveStream() { return StreamSupport.NEW_STREAM(SPLIT_ITERATORS.createJavaSplititerator(this, 0), true); }
|
||||
|
||||
#endif
|
||||
#if STREAM_FEATURE
|
||||
/**
|
||||
* A Type Specific Type Splititerator to reduce boxing/unboxing
|
||||
* @return type specific splititerator
|
||||
*/
|
||||
@Override
|
||||
default SPLIT_ITERATOR KEY_GENERIC_TYPE spliterator() { return SPLIT_ITERATORS.createSplititerator(this, 0); }
|
||||
#endif
|
||||
#endif
|
||||
}
|
|
@ -1,457 +1,458 @@
|
|||
package speiger.src.collections.PACKAGE.collections;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.function.Consumer;
|
||||
#if JDK_FUNCTION
|
||||
import java.util.function.PREDICATE;
|
||||
#endif
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
|
||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||
import speiger.src.collections.objects.collections.ObjectIterable;
|
||||
#else
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.IntFunction;
|
||||
import java.util.Comparator;
|
||||
|
||||
#endif
|
||||
import speiger.src.collections.PACKAGE.functions.function.TO_OBJECT_FUNCTION;
|
||||
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
|
||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
||||
#if !JDK_FUNCTION
|
||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||
#endif
|
||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||
#if ARRAY_LIST_FEATURE || LINKED_LIST_FEATURE
|
||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||
#if ARRAY_LIST_FEATURE
|
||||
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
||||
#else
|
||||
import speiger.src.collections.PACKAGE.lists.LINKED_LIST;
|
||||
#endif
|
||||
#endif
|
||||
#if SET_MODULE && !TYPE_BOOLEAN
|
||||
#if LINKED_SET_FEATURE || LINKED_CUSTOM_SET_FEATURE || SET_FEATURE || CUSTOM_SET_FEATURE || RB_TREE_SET_FEATURE || AVL_TREE_SET_FEATURE || ARRAY_SET_FEATURE
|
||||
import speiger.src.collections.PACKAGE.sets.SET;
|
||||
#if LINKED_SET_FEATURE
|
||||
import speiger.src.collections.PACKAGE.sets.LINKED_HASH_SET;
|
||||
#else if LINKED_CUSTOM_SET_FEATURE
|
||||
import speiger.src.collections.PACKAGE.sets.LINKED_CUSTOM_HASH_SET;
|
||||
#else if SET_FEATURE
|
||||
import speiger.src.collections.PACKAGE.sets.HASH_SET;
|
||||
#else if CUSTOM_SET_FEATURE
|
||||
import speiger.src.collections.PACKAGE.sets.CUSTOM_HASH_SET;
|
||||
#else if RB_TREE_SET_FEATURE
|
||||
import speiger.src.collections.PACKAGE.sets.RB_TREE_SET;
|
||||
#else if AVL_TREE_SET_FEATURE
|
||||
import speiger.src.collections.PACKAGE.sets.AVL_TREE_SET;
|
||||
#else if ARRAY_SET_FEATURE
|
||||
import speiger.src.collections.PACKAGE.sets.ARRAY_SET;
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
||||
#if ASYNC_MODULE
|
||||
import speiger.src.collections.PACKAGE.utils.ASYNC_BUILDER;
|
||||
#endif
|
||||
#if SPLIT_ITERATOR_FEATURE
|
||||
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
||||
#endif
|
||||
import speiger.src.collections.PACKAGE.utils.ITERABLES;
|
||||
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
||||
#if !LINKED_HASH_SET_FEATURE && LINKED_CUSTOM_HASH_SET_FEATURE
|
||||
import speiger.src.collections.PACKAGE.utils.STRATEGY;
|
||||
#endif
|
||||
import speiger.src.collections.utils.ISizeProvider;
|
||||
|
||||
/**
|
||||
* A Type-Specific {@link Iterable} that reduces (un)boxing
|
||||
* @Type(T)
|
||||
*/
|
||||
public interface ITERABLE KEY_GENERIC_TYPE extends Iterable<CLASS_TYPE>
|
||||
{
|
||||
/**
|
||||
* Returns an iterator over elements of type {@code T}.
|
||||
*
|
||||
* @return an Iterator.
|
||||
*/
|
||||
@Override
|
||||
ITERATOR KEY_GENERIC_TYPE iterator();
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
/**
|
||||
* A Type Specific foreach function that reduces (un)boxing
|
||||
*
|
||||
* @implSpec
|
||||
* <p>The default implementation behaves as if:
|
||||
* <pre>{@code
|
||||
* iterator().forEachRemaining(action);
|
||||
* }</pre>
|
||||
*
|
||||
* @param action The action to be performed for each element
|
||||
* @throws NullPointerException if the specified action is null
|
||||
* @see Iterable#forEach(Consumer)
|
||||
*/
|
||||
default void forEach(CONSUMER action) {
|
||||
Objects.requireNonNull(action);
|
||||
iterator().forEachRemaining(action);
|
||||
}
|
||||
|
||||
/** {@inheritDoc}
|
||||
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||
* @deprecated Please use the corresponding type-specific function instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
default void forEach(Consumer<? super CLASS_TYPE> action) {
|
||||
Objects.requireNonNull(action);
|
||||
iterator().forEachRemaining(action);
|
||||
}
|
||||
|
||||
#endif
|
||||
/**
|
||||
* A Indexed forEach implementation that allows you to keep track of how many elements were already iterated over.
|
||||
* @param action The action to be performed for each element
|
||||
* @throws java.lang.NullPointerException if the specified action is null
|
||||
*/
|
||||
public default void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) {
|
||||
Objects.requireNonNull(action);
|
||||
int index = 0;
|
||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();action.accept(index++, iter.NEXT()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to reduce Lambda usage and allow for more method references, since these are faster/cleaner.
|
||||
* @param input the object that should be included
|
||||
* @param action The action to be performed for each element
|
||||
* @param <E> the generic type of the Object
|
||||
* @throws java.lang.NullPointerException if the specified action is null
|
||||
*/
|
||||
default <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
||||
Objects.requireNonNull(action);
|
||||
iterator().forEachRemaining(input, action);
|
||||
}
|
||||
|
||||
#if SPLIT_ITERATOR_FEATURE
|
||||
/**
|
||||
* A Type Specific Type Splititerator to reduce boxing/unboxing
|
||||
* @return type specific splititerator
|
||||
*/
|
||||
@Override
|
||||
default SPLIT_ITERATOR KEY_GENERIC_TYPE spliterator() { return SPLIT_ITERATORS.createUnknownSplititerator(iterator(), 0); }
|
||||
|
||||
#endif
|
||||
#if ASYNC_MODULE
|
||||
/**
|
||||
* Creates a Async Builder for moving work of the thread.
|
||||
* It is not designed to split the work to multithreaded work, so using this keep it singlethreaded, but it allows to be moved to another thread.
|
||||
* @see ASYNC_BUILDER
|
||||
* @return a AsyncBuilder
|
||||
*/
|
||||
default ASYNC_BUILDER KEY_GENERIC_TYPE asAsync() {
|
||||
return new ASYNC_BUILDERBRACES(this);
|
||||
}
|
||||
|
||||
#endif
|
||||
/**
|
||||
* A Helper function to reduce the usage of Streams and allows to convert a Iterable to something else.
|
||||
* @param mapper the mapping function
|
||||
* @param <E> The return type.
|
||||
* @return a new Iterable that returns the desired result
|
||||
*/
|
||||
default <E> ObjectIterable<E> map(TO_OBJECT_FUNCTION KKS_GENERIC_TYPE<E> mapper) {
|
||||
return ITERABLES.map(this, mapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* A Helper function to reduce the usage of Streams and allows to convert a Iterable to something else.
|
||||
* @param mapper the flatMapping function
|
||||
* @param <V> The return type supplier.
|
||||
* @param <E> The return type.
|
||||
* @return a new Iterable that returns the desired result
|
||||
* @note does not support TO_ARRAY optimizations.
|
||||
*/
|
||||
default <E, V extends Iterable<E>> ObjectIterable<E> flatMap(TO_OBJECT_FUNCTION KKS_GENERIC_TYPE<V> mapper) {
|
||||
return ITERABLES.flatMap(this, mapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* A Helper function to reduce the usage of Streams and allows to convert a Iterable to something else.
|
||||
* @param mapper the flatMapping function
|
||||
* @param <E> The return type.
|
||||
* @return a new Iterable that returns the desired result
|
||||
* @note does not support TO_ARRAY optimizations.
|
||||
*/
|
||||
default <E> ObjectIterable<E> arrayflatMap(TO_OBJECT_FUNCTION KKS_GENERIC_TYPE<E[]> mapper) {
|
||||
return ITERABLES.arrayFlatMap(this, mapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* A Helper function to reduce the usage of Streams and allows to filter out unwanted elements
|
||||
* @param filter the elements that should be kept.
|
||||
* @return a Iterable that filtered out all unwanted elements
|
||||
* @note does not support TO_ARRAY optimizations.
|
||||
*/
|
||||
default ITERABLE KEY_GENERIC_TYPE filter(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
return ITERABLES.filter(this, filter);
|
||||
}
|
||||
|
||||
/**
|
||||
* A Helper function to reduce the usage of Streams and allows to filter out duplicated elements
|
||||
* @return a Iterable that filtered out all duplicated elements
|
||||
* @note does not support TO_ARRAY optimizations.
|
||||
*/
|
||||
default ITERABLE KEY_GENERIC_TYPE distinct() {
|
||||
return ITERABLES.distinct(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* A Helper function to reduce the usage of Streams and allows to repeat elements a desired amount of times
|
||||
* @param repeats how many times the elements should be repeated
|
||||
* @return a Iterable that is repeating multiple times
|
||||
*/
|
||||
default ITERABLE KEY_GENERIC_TYPE repeat(int repeats) {
|
||||
return ITERABLES.repeat(this, repeats);
|
||||
}
|
||||
|
||||
/**
|
||||
* A Helper function to reduce the usage of Streams and allows to limit the amount of elements
|
||||
* @param limit the amount of elements it should be limited to
|
||||
* @return a Iterable that is limited in length
|
||||
*/
|
||||
default ITERABLE KEY_GENERIC_TYPE limit(long limit) {
|
||||
return ITERABLES.limit(this, limit);
|
||||
}
|
||||
|
||||
/**
|
||||
* A Helper function to reduce the usage of Streams and allows to sort the elements
|
||||
* @param sorter that sorts the elements.
|
||||
* @return a Iterable that is sorted
|
||||
*/
|
||||
default ITERABLE KEY_GENERIC_TYPE sorted(COMPARATOR KEY_GENERIC_TYPE sorter) {
|
||||
return ITERABLES.sorted(this, sorter);
|
||||
}
|
||||
|
||||
/**
|
||||
* A Helper function to reduce the usage of Streams and allows to preview elements before they are iterated through
|
||||
* @param action the action that should be applied
|
||||
* @return a Peeked Iterable
|
||||
*/
|
||||
default ITERABLE KEY_GENERIC_TYPE peek(CONSUMER KEY_GENERIC_TYPE action) {
|
||||
return ITERABLES.peek(this, action);
|
||||
}
|
||||
|
||||
/**
|
||||
* A Helper function to reduce the usage of Streams and allows to collect all elements
|
||||
* @param collection that the elements should be inserted to
|
||||
* @param <E> the collection type
|
||||
* @return the input with the desired elements
|
||||
*/
|
||||
default <E extends COLLECTION KEY_GENERIC_TYPE> E pour(E collection) {
|
||||
ITERATORS.pour(iterator(), collection);
|
||||
return collection;
|
||||
}
|
||||
|
||||
#if ARRAY_LIST_FEATURE || LINKED_LIST_FEATURE
|
||||
/**
|
||||
* A Helper function that reduces the usage of streams and allows to collect all elements as a ArrayList
|
||||
* @return a new ArrayList of all elements
|
||||
*/
|
||||
default LIST KEY_GENERIC_TYPE pourAsList() {
|
||||
#if ARRAY_LIST_FEATURE
|
||||
return pour(new ARRAY_LISTBRACES());
|
||||
#else
|
||||
return pour(new LINKED_LISTBRACES());
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
#if !TYPE_BOOLEAN && SET_MODULE
|
||||
#if LINKED_SET_FEATURE || LINKED_CUSTOM_SET_FEATURE || SET_FEATURE || CUSTOM_SET_FEATURE || RB_TREE_SET_FEATURE || AVL_TREE_SET_FEATURE || ARRAY_SET_FEATURE
|
||||
/**
|
||||
* A Helper function that reduces the usage of streams and allows to collect all elements as a LinkedHashSet
|
||||
* @return a new LinkedHashSet of all elements
|
||||
*/
|
||||
default SET KEY_GENERIC_TYPE pourAsSet() {
|
||||
#if LINKED_SET_FEATURE
|
||||
return pour(new LINKED_HASH_SETBRACES());
|
||||
#else if LINKED_CUSTOM_SET_FEATURE
|
||||
return pour(new LINKED_CUSTOM_HASH_SETBRACES(STRATEGY.normalStrategy()));
|
||||
#else if SET_FEATURE
|
||||
return pour(new HASH_SETBRACES());
|
||||
#else if CUSTOM_SET_FEATURE
|
||||
return pour(new CUSTOM_HASH_SETBRACES(STRATEGY.normalStrategy()));
|
||||
#else if RB_TREE_SET_FEATURE
|
||||
return pour(new RB_Tree_SETBRACES());
|
||||
#else if AVL_TREE_SET_FEATURE
|
||||
return pour(new AVL_Tree_SETBRACES());
|
||||
#else if ARRAY_SET_FEATURE
|
||||
return pour(new ARRAY_SETBRACES());
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
#if TYPE_OBJECT
|
||||
/**
|
||||
* A Helper function that reduces the usage of streams and allows to collect all elements as a Array
|
||||
* @param action is the creator function of said Array to ensure type is kept.
|
||||
* @return a new Array of all elements
|
||||
*/
|
||||
default <E> E[] TO_ARRAY(IntFunction<E[]> action) {
|
||||
ISizeProvider prov = ISizeProvider.of(this);
|
||||
if(prov != null) {
|
||||
int size = prov.size();
|
||||
if(size >= 0) {
|
||||
E[] array = action.apply(size);
|
||||
ITERATORS.unwrap(array, iterator());
|
||||
return array;
|
||||
}
|
||||
}
|
||||
return ARRAYS.pour(iterator(), action);
|
||||
}
|
||||
#else
|
||||
/**
|
||||
* A Helper function that reduces the usage of streams and allows to collect all elements as a Array
|
||||
* @return a new Array of all elements
|
||||
*/
|
||||
default KEY_TYPE[] TO_ARRAY() {
|
||||
ISizeProvider prov = ISizeProvider.of(this);
|
||||
if(prov != null) {
|
||||
int size = prov.size();
|
||||
if(size >= 0) {
|
||||
KEY_TYPE[] array = NEW_KEY_ARRAY(size);
|
||||
ITERATORS.unwrap(array, iterator());
|
||||
return array;
|
||||
}
|
||||
}
|
||||
return ARRAYS.pour(iterator());
|
||||
}
|
||||
|
||||
#endif
|
||||
/**
|
||||
* Helper function to reduce stream usage that allows to filter for any matches.
|
||||
* @param filter that should be applied
|
||||
* @return true if any matches were found
|
||||
*/
|
||||
default boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||
if(filter.test(iter.NEXT())) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to reduce stream usage that allows to filter for no matches.
|
||||
* @param filter that should be applied
|
||||
* @return true if no matches were found
|
||||
*/
|
||||
default boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||
if(filter.test(iter.NEXT())) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to reduce stream usage that allows to filter for all matches.
|
||||
* @param filter that should be applied
|
||||
* @return true if all matches.
|
||||
*/
|
||||
default boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||
if(!filter.test(iter.NEXT())) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to reduce stream usage that allows to filter for the first match.
|
||||
* @param filter that should be applied
|
||||
* @return the found value or the null equivalent variant.
|
||||
*/
|
||||
default KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||
KEY_TYPE entry = iter.NEXT();
|
||||
if(filter.test(entry)) return entry;
|
||||
}
|
||||
return EMPTY_VALUE;
|
||||
}
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
/**
|
||||
* Performs a <a href="package-summary.html#Reduction">reduction</a> on the
|
||||
* elements of this Iterable
|
||||
* @param operator the operation that should be applied
|
||||
* @param identity the start value
|
||||
* @return the reduction result, returns identity if nothing was found
|
||||
*/
|
||||
default KEY_TYPE reduce(KEY_TYPE identity, UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||
Objects.requireNonNull(operator);
|
||||
KEY_TYPE state = identity;
|
||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||
state = operator.APPLY_VALUE(state, iter.NEXT());
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
#else
|
||||
/**
|
||||
* Performs a <a href="package-summary.html#Reduction">reduction</a> on the
|
||||
* elements of this Iterable
|
||||
* @param operator the operation that should be applied
|
||||
* @param identity the start value
|
||||
* @Type(E)
|
||||
* @return the reduction result, returns identity if nothing was found
|
||||
*/
|
||||
default <KEY_SPECIAL_TYPE> KEY_SPECIAL_TYPE reduce(KEY_SPECIAL_TYPE identity, BiFunction<KEY_SPECIAL_TYPE, KEY_TYPE, KEY_SPECIAL_TYPE> operator) {
|
||||
Objects.requireNonNull(operator);
|
||||
KEY_SPECIAL_TYPE state = identity;
|
||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||
state = operator.APPLY_VALUE(state, iter.NEXT());
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
#endif
|
||||
/**
|
||||
* Performs a <a href="package-summary.html#Reduction">reduction</a> on the
|
||||
* elements of this Iterable
|
||||
* @param operator the operation that should be applied
|
||||
* @return the reduction result, returns null value if nothing was found
|
||||
*/
|
||||
default KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||
Objects.requireNonNull(operator);
|
||||
KEY_TYPE state = EMPTY_VALUE;
|
||||
boolean empty = true;
|
||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||
if(empty) {
|
||||
empty = false;
|
||||
state = iter.NEXT();
|
||||
continue;
|
||||
}
|
||||
state = operator.APPLY_VALUE(state, iter.NEXT());
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to reduce stream usage that allows to count the valid elements.
|
||||
* @param filter that should be applied
|
||||
* @return the amount of Valid Elements
|
||||
*/
|
||||
default int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
int result = 0;
|
||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||
if(filter.test(iter.NEXT())) result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
package speiger.src.collections.PACKAGE.collections;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.function.Consumer;
|
||||
#if JDK_FUNCTION
|
||||
import java.util.function.PREDICATE;
|
||||
#endif
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
|
||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||
import speiger.src.collections.objects.collections.ObjectIterable;
|
||||
#else
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.IntFunction;
|
||||
import java.util.Comparator;
|
||||
|
||||
#endif
|
||||
import speiger.src.collections.PACKAGE.functions.function.TO_OBJECT_FUNCTION;
|
||||
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
|
||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
||||
#if !JDK_FUNCTION
|
||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||
#endif
|
||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||
#if ARRAY_LIST_FEATURE || LINKED_LIST_FEATURE
|
||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||
#if ARRAY_LIST_FEATURE
|
||||
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
||||
#else
|
||||
import speiger.src.collections.PACKAGE.lists.LINKED_LIST;
|
||||
#endif
|
||||
#endif
|
||||
#if SET_MODULE && !TYPE_BOOLEAN
|
||||
#if LINKED_SET_FEATURE || LINKED_CUSTOM_SET_FEATURE || SET_FEATURE || CUSTOM_SET_FEATURE || RB_TREE_SET_FEATURE || AVL_TREE_SET_FEATURE || ARRAY_SET_FEATURE
|
||||
import speiger.src.collections.PACKAGE.sets.SET;
|
||||
#if LINKED_SET_FEATURE
|
||||
import speiger.src.collections.PACKAGE.sets.LINKED_HASH_SET;
|
||||
#else if LINKED_CUSTOM_SET_FEATURE
|
||||
import speiger.src.collections.PACKAGE.sets.LINKED_CUSTOM_HASH_SET;
|
||||
#else if SET_FEATURE
|
||||
import speiger.src.collections.PACKAGE.sets.HASH_SET;
|
||||
#else if CUSTOM_SET_FEATURE
|
||||
import speiger.src.collections.PACKAGE.sets.CUSTOM_HASH_SET;
|
||||
#else if RB_TREE_SET_FEATURE
|
||||
import speiger.src.collections.PACKAGE.sets.RB_TREE_SET;
|
||||
#else if AVL_TREE_SET_FEATURE
|
||||
import speiger.src.collections.PACKAGE.sets.AVL_TREE_SET;
|
||||
#else if ARRAY_SET_FEATURE
|
||||
import speiger.src.collections.PACKAGE.sets.ARRAY_SET;
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
||||
#if ASYNC_MODULE
|
||||
import speiger.src.collections.PACKAGE.utils.ASYNC_BUILDER;
|
||||
#endif
|
||||
#if SPLIT_ITERATOR_FEATURE
|
||||
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
||||
#endif
|
||||
import speiger.src.collections.PACKAGE.utils.ITERABLES;
|
||||
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
||||
#if !LINKED_HASH_SET_FEATURE && LINKED_CUSTOM_HASH_SET_FEATURE
|
||||
import speiger.src.collections.PACKAGE.utils.STRATEGY;
|
||||
#endif
|
||||
import speiger.src.collections.utils.ISizeProvider;
|
||||
|
||||
/**
|
||||
* A Type-Specific {@link Iterable} that reduces (un)boxing
|
||||
* @Type(T)
|
||||
*/
|
||||
public interface ITERABLE KEY_GENERIC_TYPE extends Iterable<CLASS_TYPE>
|
||||
{
|
||||
/**
|
||||
* Returns an iterator over elements of type {@code T}.
|
||||
*
|
||||
* @return an Iterator.
|
||||
*/
|
||||
@Override
|
||||
ITERATOR KEY_GENERIC_TYPE iterator();
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
/**
|
||||
* A Type Specific foreach function that reduces (un)boxing
|
||||
*
|
||||
* @implSpec
|
||||
* <p>The default implementation behaves as if:
|
||||
* <pre>{@code
|
||||
* iterator().forEachRemaining(action);
|
||||
* }</pre>
|
||||
*
|
||||
* @param action The action to be performed for each element
|
||||
* @throws NullPointerException if the specified action is null
|
||||
* @see Iterable#forEach(Consumer)
|
||||
*/
|
||||
default void forEach(CONSUMER action) {
|
||||
Objects.requireNonNull(action);
|
||||
iterator().forEachRemaining(action);
|
||||
}
|
||||
|
||||
/** {@inheritDoc}
|
||||
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||
* @deprecated Please use the corresponding type-specific function instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
default void forEach(Consumer<? super CLASS_TYPE> action) {
|
||||
Objects.requireNonNull(action);
|
||||
iterator().forEachRemaining(action);
|
||||
}
|
||||
|
||||
#endif
|
||||
/**
|
||||
* A Indexed forEach implementation that allows you to keep track of how many elements were already iterated over.
|
||||
* @param action The action to be performed for each element
|
||||
* @throws java.lang.NullPointerException if the specified action is null
|
||||
*/
|
||||
public default void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) {
|
||||
Objects.requireNonNull(action);
|
||||
int index = 0;
|
||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();action.accept(index++, iter.NEXT()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to reduce Lambda usage and allow for more method references, since these are faster/cleaner.
|
||||
* @param input the object that should be included
|
||||
* @param action The action to be performed for each element
|
||||
* @param <E> the generic type of the Object
|
||||
* @throws java.lang.NullPointerException if the specified action is null
|
||||
*/
|
||||
default <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
||||
Objects.requireNonNull(action);
|
||||
iterator().forEachRemaining(input, action);
|
||||
}
|
||||
|
||||
#if SPLIT_ITERATOR_FEATURE
|
||||
/**
|
||||
* A Type Specific Type Splititerator to reduce boxing/unboxing
|
||||
* @return type specific splititerator
|
||||
*/
|
||||
@Override
|
||||
default SPLIT_ITERATOR KEY_GENERIC_TYPE spliterator() { return SPLIT_ITERATORS.createUnknownSplititerator(iterator(), 0); }
|
||||
|
||||
#endif
|
||||
#if ASYNC_MODULE
|
||||
/**
|
||||
* Creates a Async Builder for moving work of the thread.
|
||||
* It is not designed to split the work to multithreaded work, so using this keep it singlethreaded, but it allows to be moved to another thread.
|
||||
* @see ASYNC_BUILDER
|
||||
* @return a AsyncBuilder
|
||||
*/
|
||||
default ASYNC_BUILDER KEY_GENERIC_TYPE asAsync() {
|
||||
return new ASYNC_BUILDERBRACES(this);
|
||||
}
|
||||
|
||||
#endif
|
||||
/**
|
||||
* A Helper function to reduce the usage of Streams and allows to convert a Iterable to something else.
|
||||
* @param mapper the mapping function
|
||||
* @param <E> The return type.
|
||||
* @return a new Iterable that returns the desired result
|
||||
*/
|
||||
default <E> ObjectIterable<E> map(TO_OBJECT_FUNCTION KKS_GENERIC_TYPE<E> mapper) {
|
||||
return ITERABLES.map(this, mapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* A Helper function to reduce the usage of Streams and allows to convert a Iterable to something else.
|
||||
* @param mapper the flatMapping function
|
||||
* @param <V> The return type supplier.
|
||||
* @param <E> The return type.
|
||||
* @return a new Iterable that returns the desired result
|
||||
* @note does not support TO_ARRAY optimizations.
|
||||
*/
|
||||
default <E, V extends Iterable<E>> ObjectIterable<E> flatMap(TO_OBJECT_FUNCTION KKS_GENERIC_TYPE<V> mapper) {
|
||||
return ITERABLES.flatMap(this, mapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* A Helper function to reduce the usage of Streams and allows to convert a Iterable to something else.
|
||||
* @param mapper the flatMapping function
|
||||
* @param <E> The return type.
|
||||
* @return a new Iterable that returns the desired result
|
||||
* @note does not support TO_ARRAY optimizations.
|
||||
*/
|
||||
default <E> ObjectIterable<E> arrayflatMap(TO_OBJECT_FUNCTION KKS_GENERIC_TYPE<E[]> mapper) {
|
||||
return ITERABLES.arrayFlatMap(this, mapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* A Helper function to reduce the usage of Streams and allows to filter out unwanted elements
|
||||
* @param filter the elements that should be kept.
|
||||
* @return a Iterable that filtered out all unwanted elements
|
||||
* @note does not support TO_ARRAY optimizations.
|
||||
*/
|
||||
default ITERABLE KEY_GENERIC_TYPE filter(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
return ITERABLES.filter(this, filter);
|
||||
}
|
||||
|
||||
/**
|
||||
* A Helper function to reduce the usage of Streams and allows to filter out duplicated elements
|
||||
* @return a Iterable that filtered out all duplicated elements
|
||||
* @note does not support TO_ARRAY optimizations.
|
||||
*/
|
||||
default ITERABLE KEY_GENERIC_TYPE distinct() {
|
||||
return ITERABLES.distinct(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* A Helper function to reduce the usage of Streams and allows to repeat elements a desired amount of times
|
||||
* @param repeats how many times the elements should be repeated
|
||||
* @return a Iterable that is repeating multiple times
|
||||
*/
|
||||
default ITERABLE KEY_GENERIC_TYPE repeat(int repeats) {
|
||||
return ITERABLES.repeat(this, repeats);
|
||||
}
|
||||
|
||||
/**
|
||||
* A Helper function to reduce the usage of Streams and allows to limit the amount of elements
|
||||
* @param limit the amount of elements it should be limited to
|
||||
* @return a Iterable that is limited in length
|
||||
*/
|
||||
default ITERABLE KEY_GENERIC_TYPE limit(long limit) {
|
||||
return ITERABLES.limit(this, limit);
|
||||
}
|
||||
|
||||
/**
|
||||
* A Helper function to reduce the usage of Streams and allows to sort the elements
|
||||
* @param sorter that sorts the elements.
|
||||
* @return a Iterable that is sorted
|
||||
*/
|
||||
default ITERABLE KEY_GENERIC_TYPE sorted(COMPARATOR KEY_GENERIC_TYPE sorter) {
|
||||
return ITERABLES.sorted(this, sorter);
|
||||
}
|
||||
|
||||
/**
|
||||
* A Helper function to reduce the usage of Streams and allows to preview elements before they are iterated through
|
||||
* @param action the action that should be applied
|
||||
* @return a Peeked Iterable
|
||||
*/
|
||||
default ITERABLE KEY_GENERIC_TYPE peek(CONSUMER KEY_GENERIC_TYPE action) {
|
||||
return ITERABLES.peek(this, action);
|
||||
}
|
||||
|
||||
/**
|
||||
* A Helper function to reduce the usage of Streams and allows to collect all elements
|
||||
* @param collection that the elements should be inserted to
|
||||
* @param <E> the collection type
|
||||
* @return the input with the desired elements
|
||||
*/
|
||||
default <E extends COLLECTION KEY_GENERIC_TYPE> E pour(E collection) {
|
||||
ITERATORS.pour(iterator(), collection);
|
||||
return collection;
|
||||
}
|
||||
|
||||
#if ARRAY_LIST_FEATURE || LINKED_LIST_FEATURE
|
||||
/**
|
||||
* A Helper function that reduces the usage of streams and allows to collect all elements as a ArrayList
|
||||
* @return a new ArrayList of all elements
|
||||
*/
|
||||
default LIST KEY_GENERIC_TYPE pourAsList() {
|
||||
#if ARRAY_LIST_FEATURE
|
||||
return pour(new ARRAY_LISTBRACES());
|
||||
#else
|
||||
return pour(new LINKED_LISTBRACES());
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
#if !TYPE_BOOLEAN && SET_MODULE
|
||||
#if LINKED_SET_FEATURE || LINKED_CUSTOM_SET_FEATURE || SET_FEATURE || CUSTOM_SET_FEATURE || RB_TREE_SET_FEATURE || AVL_TREE_SET_FEATURE || ARRAY_SET_FEATURE
|
||||
/**
|
||||
* A Helper function that reduces the usage of streams and allows to collect all elements as a LinkedHashSet
|
||||
* @return a new LinkedHashSet of all elements
|
||||
*/
|
||||
default SET KEY_GENERIC_TYPE pourAsSet() {
|
||||
#if LINKED_SET_FEATURE
|
||||
return pour(new LINKED_HASH_SETBRACES());
|
||||
#else if LINKED_CUSTOM_SET_FEATURE
|
||||
return pour(new LINKED_CUSTOM_HASH_SETBRACES(STRATEGY.normalStrategy()));
|
||||
#else if SET_FEATURE
|
||||
return pour(new HASH_SETBRACES());
|
||||
#else if CUSTOM_SET_FEATURE
|
||||
return pour(new CUSTOM_HASH_SETBRACES(STRATEGY.normalStrategy()));
|
||||
#else if RB_TREE_SET_FEATURE
|
||||
return pour(new RB_Tree_SETBRACES());
|
||||
#else if AVL_TREE_SET_FEATURE
|
||||
return pour(new AVL_Tree_SETBRACES());
|
||||
#else if ARRAY_SET_FEATURE
|
||||
return pour(new ARRAY_SETBRACES());
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
#if TYPE_OBJECT
|
||||
/**
|
||||
* A Helper function that reduces the usage of streams and allows to collect all elements as a Array
|
||||
* @param action is the creator function of said Array to ensure type is kept.
|
||||
* @param <E> the returning arrayType
|
||||
* @return a new Array of all elements
|
||||
*/
|
||||
default <E> E[] TO_ARRAY(IntFunction<E[]> action) {
|
||||
ISizeProvider prov = ISizeProvider.of(this);
|
||||
if(prov != null) {
|
||||
int size = prov.size();
|
||||
if(size >= 0) {
|
||||
E[] array = action.apply(size);
|
||||
ITERATORS.unwrap(array, iterator());
|
||||
return array;
|
||||
}
|
||||
}
|
||||
return ARRAYS.pour(iterator(), action);
|
||||
}
|
||||
#else
|
||||
/**
|
||||
* A Helper function that reduces the usage of streams and allows to collect all elements as a Array
|
||||
* @return a new Array of all elements
|
||||
*/
|
||||
default KEY_TYPE[] TO_ARRAY() {
|
||||
ISizeProvider prov = ISizeProvider.of(this);
|
||||
if(prov != null) {
|
||||
int size = prov.size();
|
||||
if(size >= 0) {
|
||||
KEY_TYPE[] array = NEW_KEY_ARRAY(size);
|
||||
ITERATORS.unwrap(array, iterator());
|
||||
return array;
|
||||
}
|
||||
}
|
||||
return ARRAYS.pour(iterator());
|
||||
}
|
||||
|
||||
#endif
|
||||
/**
|
||||
* Helper function to reduce stream usage that allows to filter for any matches.
|
||||
* @param filter that should be applied
|
||||
* @return true if any matches were found
|
||||
*/
|
||||
default boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||
if(filter.test(iter.NEXT())) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to reduce stream usage that allows to filter for no matches.
|
||||
* @param filter that should be applied
|
||||
* @return true if no matches were found
|
||||
*/
|
||||
default boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||
if(filter.test(iter.NEXT())) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to reduce stream usage that allows to filter for all matches.
|
||||
* @param filter that should be applied
|
||||
* @return true if all matches.
|
||||
*/
|
||||
default boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||
if(!filter.test(iter.NEXT())) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to reduce stream usage that allows to filter for the first match.
|
||||
* @param filter that should be applied
|
||||
* @return the found value or the null equivalent variant.
|
||||
*/
|
||||
default KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||
KEY_TYPE entry = iter.NEXT();
|
||||
if(filter.test(entry)) return entry;
|
||||
}
|
||||
return EMPTY_VALUE;
|
||||
}
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
/**
|
||||
* Performs a <a href="package-summary.html#Reduction">reduction</a> on the
|
||||
* elements of this Iterable
|
||||
* @param operator the operation that should be applied
|
||||
* @param identity the start value
|
||||
* @return the reduction result, returns identity if nothing was found
|
||||
*/
|
||||
default KEY_TYPE reduce(KEY_TYPE identity, UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||
Objects.requireNonNull(operator);
|
||||
KEY_TYPE state = identity;
|
||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||
state = operator.APPLY_VALUE(state, iter.NEXT());
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
#else
|
||||
/**
|
||||
* Performs a <a href="package-summary.html#Reduction">reduction</a> on the
|
||||
* elements of this Iterable
|
||||
* @param operator the operation that should be applied
|
||||
* @param identity the start value
|
||||
* @Type(E)
|
||||
* @return the reduction result, returns identity if nothing was found
|
||||
*/
|
||||
default <KEY_SPECIAL_TYPE> KEY_SPECIAL_TYPE reduce(KEY_SPECIAL_TYPE identity, BiFunction<KEY_SPECIAL_TYPE, KEY_TYPE, KEY_SPECIAL_TYPE> operator) {
|
||||
Objects.requireNonNull(operator);
|
||||
KEY_SPECIAL_TYPE state = identity;
|
||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||
state = operator.APPLY_VALUE(state, iter.NEXT());
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
#endif
|
||||
/**
|
||||
* Performs a <a href="package-summary.html#Reduction">reduction</a> on the
|
||||
* elements of this Iterable
|
||||
* @param operator the operation that should be applied
|
||||
* @return the reduction result, returns null value if nothing was found
|
||||
*/
|
||||
default KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||
Objects.requireNonNull(operator);
|
||||
KEY_TYPE state = EMPTY_VALUE;
|
||||
boolean empty = true;
|
||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||
if(empty) {
|
||||
empty = false;
|
||||
state = iter.NEXT();
|
||||
continue;
|
||||
}
|
||||
state = operator.APPLY_VALUE(state, iter.NEXT());
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to reduce stream usage that allows to count the valid elements.
|
||||
* @param filter that should be applied
|
||||
* @return the amount of Valid Elements
|
||||
*/
|
||||
default int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
int result = 0;
|
||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||
if(filter.test(iter.NEXT())) result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -1,70 +1,70 @@
|
|||
package speiger.src.collections.PACKAGE.functions;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Type-Specific Class for Comparator to reduce (un)boxing
|
||||
*/
|
||||
public interface COMPARATOR extends Comparator<CLASS_TYPE>
|
||||
{
|
||||
/**
|
||||
* Type-Specific compare function to reduce (un)boxing
|
||||
* @param o1 the first object to be compared.
|
||||
* @param o2 the second object to be compared.
|
||||
* @return a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
|
||||
* @see Comparator#compare(Object, Object)
|
||||
*/
|
||||
int compare(KEY_TYPE o1, KEY_TYPE o2);
|
||||
|
||||
/** {@inheritDoc}
|
||||
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||
* @deprecated Please use the corresponding type-specific function instead.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
default int compare(CLASS_TYPE o1, CLASS_TYPE o2) {
|
||||
return compare(OBJ_TO_KEY(o1), OBJ_TO_KEY(o2));
|
||||
}
|
||||
|
||||
/**
|
||||
* A Wrapper function to convert a Non-Type-Specific Comparator to a Type-Specific-Comparator
|
||||
* @param c comparator to convert
|
||||
* @return the wrapper of the comparator
|
||||
* @throws NullPointerException if the comparator is null
|
||||
*/
|
||||
public static COMPARATOR of(Comparator<CLASS_TYPE> c) {
|
||||
Objects.requireNonNull(c);
|
||||
return (K, V) -> c.compare(KEY_TO_OBJ(K), KEY_TO_OBJ(V));
|
||||
}
|
||||
|
||||
@Override
|
||||
public default COMPARATOR reversed() {
|
||||
return new Reversed(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* A Type Specific Reversed Comparator to reduce boxing/unboxing
|
||||
*/
|
||||
static class Reversed implements COMPARATOR
|
||||
{
|
||||
COMPARATOR original;
|
||||
|
||||
/**
|
||||
* default constructor
|
||||
* @param original that is going to be reversed
|
||||
*/
|
||||
public Reversed(COMPARATOR original) {
|
||||
this.original = original;
|
||||
}
|
||||
|
||||
public int compare(KEY_TYPE o1, KEY_TYPE o2) {
|
||||
return original.compare(o2, o1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public COMPARATOR reversed() {
|
||||
return original;
|
||||
}
|
||||
}
|
||||
package speiger.src.collections.PACKAGE.functions;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Type-Specific Class for Comparator to reduce (un)boxing
|
||||
*/
|
||||
public interface COMPARATOR extends Comparator<CLASS_TYPE>
|
||||
{
|
||||
/**
|
||||
* Type-Specific compare function to reduce (un)boxing
|
||||
* @param o1 the first object to be compared.
|
||||
* @param o2 the second object to be compared.
|
||||
* @return a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
|
||||
* @see Comparator#compare(Object, Object)
|
||||
*/
|
||||
int compare(KEY_TYPE o1, KEY_TYPE o2);
|
||||
|
||||
/** {@inheritDoc}
|
||||
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||
* @deprecated Please use the corresponding type-specific function instead.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
default int compare(CLASS_TYPE o1, CLASS_TYPE o2) {
|
||||
return compare(OBJ_TO_KEY(o1), OBJ_TO_KEY(o2));
|
||||
}
|
||||
|
||||
/**
|
||||
* A Wrapper function to convert a Non-Type-Specific Comparator to a Type-Specific-Comparator
|
||||
* @param c comparator to convert
|
||||
* @return the wrapper of the comparator
|
||||
* @throws NullPointerException if the comparator is null
|
||||
*/
|
||||
public static COMPARATOR of(Comparator<CLASS_TYPE> c) {
|
||||
Objects.requireNonNull(c);
|
||||
return (K, V) -> c.compare(KEY_TO_OBJ(K), KEY_TO_OBJ(V));
|
||||
}
|
||||
|
||||
@Override
|
||||
public default COMPARATOR reversed() {
|
||||
return new Reversed(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* A Type Specific Reversed Comparator to reduce boxing/unboxing
|
||||
*/
|
||||
static class Reversed implements COMPARATOR
|
||||
{
|
||||
COMPARATOR original;
|
||||
|
||||
/**
|
||||
* default constructor
|
||||
* @param original that is going to be reversed
|
||||
*/
|
||||
public Reversed(COMPARATOR original) {
|
||||
this.original = original;
|
||||
}
|
||||
|
||||
public int compare(KEY_TYPE o1, KEY_TYPE o2) {
|
||||
return original.compare(o2, o1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public COMPARATOR reversed() {
|
||||
return original;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,19 +1,19 @@
|
|||
package speiger.src.collections.PACKAGE.functions;
|
||||
|
||||
/**
|
||||
* Type-Specific Supplier interface that reduces (un)boxing and allows to merge other consumer types into this interface
|
||||
* @Type(T)
|
||||
*/
|
||||
#if TYPE_OBJECT
|
||||
public interface SUPPLIER KEY_GENERIC_TYPE extends java.util.function.Supplier<KEY_TYPE>
|
||||
#else if JDK_TYPE && !TYPE_BOOLEAN
|
||||
public interface SUPPLIER KEY_GENERIC_TYPE extends JAVA_SUPPLIER
|
||||
#else
|
||||
public interface SUPPLIER KEY_GENERIC_TYPE
|
||||
#endif
|
||||
{
|
||||
/**
|
||||
* @return the supplied value
|
||||
*/
|
||||
public KEY_TYPE SUPPLY_GET();
|
||||
package speiger.src.collections.PACKAGE.functions;
|
||||
|
||||
/**
|
||||
* Type-Specific Supplier interface that reduces (un)boxing and allows to merge other consumer types into this interface
|
||||
* @Type(T)
|
||||
*/
|
||||
#if TYPE_OBJECT
|
||||
public interface SUPPLIER KEY_GENERIC_TYPE extends java.util.function.Supplier<KEY_TYPE>
|
||||
#else if JDK_TYPE && !TYPE_BOOLEAN
|
||||
public interface SUPPLIER KEY_GENERIC_TYPE extends JAVA_SUPPLIER
|
||||
#else
|
||||
public interface SUPPLIER KEY_GENERIC_TYPE
|
||||
#endif
|
||||
{
|
||||
/**
|
||||
* @return the supplied value
|
||||
*/
|
||||
public KEY_TYPE SUPPLY_GET();
|
||||
}
|
|
@ -1,92 +1,92 @@
|
|||
package speiger.src.collections.PACKAGE.functions;
|
||||
|
||||
import java.util.concurrent.RunnableFuture;
|
||||
#if !TYPE_OBJECT
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
#endif
|
||||
|
||||
/**
|
||||
*
|
||||
* A Type Specific Task interface that allows you to keep track of the task that is currently running.<br>
|
||||
* It extends Runnable future and supports said functions but also provides quality of life functions like:<br>
|
||||
*
|
||||
* - isSuccesfull: which allows to detect if the task was completed properly and not interrupted or crashed.
|
||||
* - pause/resume: which allows to pause/resume the task at any moment, making it easier to create thread-safe actions.
|
||||
* @Type(T)
|
||||
*/
|
||||
public interface TASK KEY_GENERIC_TYPE extends RunnableFuture<CLASS_TYPE> {
|
||||
/**
|
||||
* Helper function to detect if the task is currently paused.
|
||||
* @return true if paused
|
||||
*/
|
||||
public boolean isPaused();
|
||||
|
||||
/**
|
||||
* Pauses the task, which lets the thread finish without completing the task.
|
||||
* Tasks are written in the way where they can pause without any issues.
|
||||
* This won't be instant, as this function is applied asynchronous and doesn't check if the thread paused.
|
||||
* So make sure it had the time to pause.
|
||||
*/
|
||||
public void pause();
|
||||
|
||||
/**
|
||||
* Pauses the task, which lets the thread finish without completing the task.
|
||||
* Tasks are written in the way where they can pause without any issues.
|
||||
* This won't be instant, as this function is applied asynchronous.
|
||||
* It will await the pausing of the task.
|
||||
*/
|
||||
public void awaitPausing();
|
||||
|
||||
/**
|
||||
* Continues the task if it wasn't already completed.
|
||||
* This is done by resubmitting the task to the executor provided.
|
||||
*/
|
||||
public void resume();
|
||||
|
||||
/**
|
||||
* Quality of life function that allows to detect if no cancellation/exception was applied to this task and it completed on its own.
|
||||
* @return true if it was properly completed
|
||||
*/
|
||||
public boolean isSuccessful();
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
/**
|
||||
* A Type Specific get method that allows to reduce (un)boxing of primtives.
|
||||
*
|
||||
* Waits if necessary for the computation to complete, and then
|
||||
* retrieves its result.
|
||||
*
|
||||
* @return the computed result as primitive
|
||||
* @throws CancellationException if the computation was cancelled
|
||||
* @throws ExecutionException if the computation threw an exception
|
||||
* @throws InterruptedException if the current thread was interrupted
|
||||
* while waiting
|
||||
*/
|
||||
public KEY_TYPE GET_KEY() throws InterruptedException, ExecutionException;
|
||||
|
||||
/**
|
||||
* Waits if necessary for at most the given time for the computation
|
||||
* to complete, and then retrieves its result, if available.
|
||||
*
|
||||
* @param timeout the maximum time to wait
|
||||
* @param unit the time unit of the timeout argument
|
||||
* @return the computed result as primitive
|
||||
* @throws CancellationException if the computation was cancelled
|
||||
* @throws ExecutionException if the computation threw an exception
|
||||
* @throws InterruptedException if the current thread was interrupted while waiting
|
||||
* @throws TimeoutException if the wait timed out
|
||||
*/
|
||||
public KEY_TYPE GET_KEY(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException;
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public default CLASS_TYPE get() throws InterruptedException, ExecutionException { return KEY_TO_OBJ(GET_KEY()); }
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public default CLASS_TYPE get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { return KEY_TO_OBJ(GET_KEY(timeout, unit)); }
|
||||
#endif
|
||||
package speiger.src.collections.PACKAGE.functions;
|
||||
|
||||
import java.util.concurrent.RunnableFuture;
|
||||
#if !TYPE_OBJECT
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
#endif
|
||||
|
||||
/**
|
||||
*
|
||||
* A Type Specific Task interface that allows you to keep track of the task that is currently running.<br>
|
||||
* It extends Runnable future and supports said functions but also provides quality of life functions like:<br>
|
||||
*
|
||||
* - isSuccesfull: which allows to detect if the task was completed properly and not interrupted or crashed.
|
||||
* - pause/resume: which allows to pause/resume the task at any moment, making it easier to create thread-safe actions.
|
||||
* @Type(T)
|
||||
*/
|
||||
public interface TASK KEY_GENERIC_TYPE extends RunnableFuture<CLASS_TYPE> {
|
||||
/**
|
||||
* Helper function to detect if the task is currently paused.
|
||||
* @return true if paused
|
||||
*/
|
||||
public boolean isPaused();
|
||||
|
||||
/**
|
||||
* Pauses the task, which lets the thread finish without completing the task.
|
||||
* Tasks are written in the way where they can pause without any issues.
|
||||
* This won't be instant, as this function is applied asynchronous and doesn't check if the thread paused.
|
||||
* So make sure it had the time to pause.
|
||||
*/
|
||||
public void pause();
|
||||
|
||||
/**
|
||||
* Pauses the task, which lets the thread finish without completing the task.
|
||||
* Tasks are written in the way where they can pause without any issues.
|
||||
* This won't be instant, as this function is applied asynchronous.
|
||||
* It will await the pausing of the task.
|
||||
*/
|
||||
public void awaitPausing();
|
||||
|
||||
/**
|
||||
* Continues the task if it wasn't already completed.
|
||||
* This is done by resubmitting the task to the executor provided.
|
||||
*/
|
||||
public void resume();
|
||||
|
||||
/**
|
||||
* Quality of life function that allows to detect if no cancellation/exception was applied to this task and it completed on its own.
|
||||
* @return true if it was properly completed
|
||||
*/
|
||||
public boolean isSuccessful();
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
/**
|
||||
* A Type Specific get method that allows to reduce (un)boxing of primtives.
|
||||
*
|
||||
* Waits if necessary for the computation to complete, and then
|
||||
* retrieves its result.
|
||||
*
|
||||
* @return the computed result as primitive
|
||||
* @throws CancellationException if the computation was cancelled
|
||||
* @throws ExecutionException if the computation threw an exception
|
||||
* @throws InterruptedException if the current thread was interrupted
|
||||
* while waiting
|
||||
*/
|
||||
public KEY_TYPE GET_KEY() throws InterruptedException, ExecutionException;
|
||||
|
||||
/**
|
||||
* Waits if necessary for at most the given time for the computation
|
||||
* to complete, and then retrieves its result, if available.
|
||||
*
|
||||
* @param timeout the maximum time to wait
|
||||
* @param unit the time unit of the timeout argument
|
||||
* @return the computed result as primitive
|
||||
* @throws CancellationException if the computation was cancelled
|
||||
* @throws ExecutionException if the computation threw an exception
|
||||
* @throws InterruptedException if the current thread was interrupted while waiting
|
||||
* @throws TimeoutException if the wait timed out
|
||||
*/
|
||||
public KEY_TYPE GET_KEY(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException;
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public default CLASS_TYPE get() throws InterruptedException, ExecutionException { return KEY_TO_OBJ(GET_KEY()); }
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public default CLASS_TYPE get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { return KEY_TO_OBJ(GET_KEY(timeout, unit)); }
|
||||
#endif
|
||||
}
|
|
@ -1,134 +1,134 @@
|
|||
package speiger.src.collections.PACKAGE.functions.function;
|
||||
|
||||
#if VALUE_BOOLEAN || SAME_TYPE
|
||||
import java.util.Objects;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* A Type Specific Function interface that reduces boxing/unboxing and fills the gaps of interfaces that are missing.
|
||||
* @Type(T)
|
||||
* @ValueType(V)
|
||||
*/
|
||||
@FunctionalInterface
|
||||
#if JDK_FUNCTION
|
||||
public interface FUNCTION KEY_VALUE_GENERIC_TYPE extends JAVA_FUNCTION KEY_VALUE_GENERIC_TYPE
|
||||
#else
|
||||
public interface FUNCTION KEY_VALUE_GENERIC_TYPE
|
||||
#endif
|
||||
{
|
||||
/**
|
||||
* Type Specific get function to reduce boxing/unboxing
|
||||
* @param k the value that should be processed
|
||||
* @return the result of the function
|
||||
*/
|
||||
public VALUE_TYPE APPLY(KEY_TYPE k);
|
||||
|
||||
#if SAME_TYPE
|
||||
/**
|
||||
* Creates a Default function that returns the input provided.
|
||||
* @Type(T)
|
||||
* @return a input returning function
|
||||
*/
|
||||
public static GENERIC_KEY_BRACES FUNCTION KEY_SAME_GENERIC_TYPE identity() {
|
||||
return T -> T;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a composed function that first applies the {@code before}
|
||||
* function to its input, and then applies this function to the result.
|
||||
* If evaluation of either function throws an exception, it is relayed to
|
||||
* the caller of the composed function.
|
||||
*
|
||||
* @Type(I)
|
||||
* @param before the function that should be used first
|
||||
* @return a composed function with a different starting function.
|
||||
*/
|
||||
public default GENERIC_SPECIAL_VALUE_BRACES<I> FUNCTION SV_GENERIC_TYPE<I> compose(FUNCTION SK_GENERIC_TYPE<I> before) {
|
||||
Objects.requireNonNull(before);
|
||||
return T -> APPLY(before.APPLY(T));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a composed function that first applies this function to
|
||||
* its input, and then applies the {@code after} function to the result.
|
||||
* If evaluation of either function throws an exception, it is relayed to
|
||||
* the caller of the composed function.
|
||||
*
|
||||
* @Type(I)
|
||||
* @param after the function that should be used last
|
||||
* @return a composed function with a different starting function.
|
||||
*/
|
||||
public default GENERIC_SPECIAL_VALUE_BRACES<I> FUNCTION KS_GENERIC_TYPE<I> andThen(FUNCTION VS_GENERIC_TYPE<I> after) {
|
||||
Objects.requireNonNull(after);
|
||||
return T -> after.APPLY(APPLY(T));
|
||||
}
|
||||
|
||||
#endif
|
||||
#if VALUE_BOOLEAN
|
||||
/**
|
||||
* Creates a Always true function that may be useful if you don't need to process information or just want a default.
|
||||
* @Type(T)
|
||||
* @return a default returning function
|
||||
*/
|
||||
public static GENERIC_KEY_BRACES FUNCTION KEY_GENERIC_TYPE alwaysTrue() {
|
||||
return T -> true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a Always false function that may be useful if you don't need to process information or just want a default.
|
||||
* @Type(T)
|
||||
* @return a default returning function
|
||||
*/
|
||||
public static GENERIC_KEY_BRACES FUNCTION KEY_GENERIC_TYPE alwaysFalse() {
|
||||
return T -> false;
|
||||
}
|
||||
|
||||
/**
|
||||
* A Type specific and-function helper function that reduces boxing/unboxing
|
||||
* @param other the other function that should be merged with.
|
||||
* @return a function that compares values in a and comparason
|
||||
*/
|
||||
public default FUNCTION KEY_VALUE_GENERIC_TYPE andType(FUNCTION KEY_VALUE_GENERIC_TYPE other) {
|
||||
Objects.requireNonNull(other);
|
||||
return T -> APPLY(T) && other.APPLY(T);
|
||||
}
|
||||
|
||||
#if JDK_FUNCTION
|
||||
@Override
|
||||
@Deprecated
|
||||
public default FUNCTION KEY_VALUE_GENERIC_TYPE and(JAVA_FUNCTION KEY_VALUE_SUPER_GENERIC_TYPE other) {
|
||||
Objects.requireNonNull(other);
|
||||
return T -> APPLY(T) && other.APPLY(T);
|
||||
}
|
||||
|
||||
@Override
|
||||
#else
|
||||
/**
|
||||
* A type specific inverter function
|
||||
* @return the same function but inverts the result
|
||||
*/
|
||||
#endif
|
||||
public default FUNCTION KEY_VALUE_GENERIC_TYPE negate() {
|
||||
return T -> !APPLY(T);
|
||||
}
|
||||
|
||||
/**
|
||||
* A Type specific or-function helper function that reduces boxing/unboxing
|
||||
* @param other the other function that should be merged with.
|
||||
* @return a function that compares values in a or comparason
|
||||
*/
|
||||
public default FUNCTION KEY_VALUE_GENERIC_TYPE orType(FUNCTION KEY_VALUE_GENERIC_TYPE other) {
|
||||
Objects.requireNonNull(other);
|
||||
return T -> APPLY(T) || other.APPLY(T);
|
||||
}
|
||||
|
||||
#if JDK_FUNCTION
|
||||
@Override
|
||||
@Deprecated
|
||||
public default FUNCTION KEY_VALUE_GENERIC_TYPE or(JAVA_FUNCTION KEY_VALUE_SUPER_GENERIC_TYPE other) {
|
||||
Objects.requireNonNull(other);
|
||||
return T -> APPLY(T) || other.APPLY(T);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
package speiger.src.collections.PACKAGE.functions.function;
|
||||
|
||||
#if VALUE_BOOLEAN || SAME_TYPE
|
||||
import java.util.Objects;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* A Type Specific Function interface that reduces boxing/unboxing and fills the gaps of interfaces that are missing.
|
||||
* @Type(T)
|
||||
* @ValueType(V)
|
||||
*/
|
||||
@FunctionalInterface
|
||||
#if JDK_FUNCTION
|
||||
public interface FUNCTION KEY_VALUE_GENERIC_TYPE extends JAVA_FUNCTION KEY_VALUE_GENERIC_TYPE
|
||||
#else
|
||||
public interface FUNCTION KEY_VALUE_GENERIC_TYPE
|
||||
#endif
|
||||
{
|
||||
/**
|
||||
* Type Specific get function to reduce boxing/unboxing
|
||||
* @param k the value that should be processed
|
||||
* @return the result of the function
|
||||
*/
|
||||
public VALUE_TYPE APPLY(KEY_TYPE k);
|
||||
|
||||
#if SAME_TYPE
|
||||
/**
|
||||
* Creates a Default function that returns the input provided.
|
||||
* @Type(T)
|
||||
* @return a input returning function
|
||||
*/
|
||||
public static GENERIC_KEY_BRACES FUNCTION KEY_SAME_GENERIC_TYPE identity() {
|
||||
return T -> T;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a composed function that first applies the {@code before}
|
||||
* function to its input, and then applies this function to the result.
|
||||
* If evaluation of either function throws an exception, it is relayed to
|
||||
* the caller of the composed function.
|
||||
*
|
||||
* @Type(I)
|
||||
* @param before the function that should be used first
|
||||
* @return a composed function with a different starting function.
|
||||
*/
|
||||
public default GENERIC_SPECIAL_VALUE_BRACES<I> FUNCTION SV_GENERIC_TYPE<I> compose(FUNCTION SK_GENERIC_TYPE<I> before) {
|
||||
Objects.requireNonNull(before);
|
||||
return T -> APPLY(before.APPLY(T));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a composed function that first applies this function to
|
||||
* its input, and then applies the {@code after} function to the result.
|
||||
* If evaluation of either function throws an exception, it is relayed to
|
||||
* the caller of the composed function.
|
||||
*
|
||||
* @Type(I)
|
||||
* @param after the function that should be used last
|
||||
* @return a composed function with a different starting function.
|
||||
*/
|
||||
public default GENERIC_SPECIAL_VALUE_BRACES<I> FUNCTION KS_GENERIC_TYPE<I> andThen(FUNCTION VS_GENERIC_TYPE<I> after) {
|
||||
Objects.requireNonNull(after);
|
||||
return T -> after.APPLY(APPLY(T));
|
||||
}
|
||||
|
||||
#endif
|
||||
#if VALUE_BOOLEAN
|
||||
/**
|
||||
* Creates a Always true function that may be useful if you don't need to process information or just want a default.
|
||||
* @Type(T)
|
||||
* @return a default returning function
|
||||
*/
|
||||
public static GENERIC_KEY_BRACES FUNCTION KEY_GENERIC_TYPE alwaysTrue() {
|
||||
return T -> true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a Always false function that may be useful if you don't need to process information or just want a default.
|
||||
* @Type(T)
|
||||
* @return a default returning function
|
||||
*/
|
||||
public static GENERIC_KEY_BRACES FUNCTION KEY_GENERIC_TYPE alwaysFalse() {
|
||||
return T -> false;
|
||||
}
|
||||
|
||||
/**
|
||||
* A Type specific and-function helper function that reduces boxing/unboxing
|
||||
* @param other the other function that should be merged with.
|
||||
* @return a function that compares values in a and comparason
|
||||
*/
|
||||
public default FUNCTION KEY_VALUE_GENERIC_TYPE andType(FUNCTION KEY_VALUE_GENERIC_TYPE other) {
|
||||
Objects.requireNonNull(other);
|
||||
return T -> APPLY(T) && other.APPLY(T);
|
||||
}
|
||||
|
||||
#if JDK_FUNCTION
|
||||
@Override
|
||||
@Deprecated
|
||||
public default FUNCTION KEY_VALUE_GENERIC_TYPE and(JAVA_FUNCTION KEY_VALUE_SUPER_GENERIC_TYPE other) {
|
||||
Objects.requireNonNull(other);
|
||||
return T -> APPLY(T) && other.APPLY(T);
|
||||
}
|
||||
|
||||
@Override
|
||||
#else
|
||||
/**
|
||||
* A type specific inverter function
|
||||
* @return the same function but inverts the result
|
||||
*/
|
||||
#endif
|
||||
public default FUNCTION KEY_VALUE_GENERIC_TYPE negate() {
|
||||
return T -> !APPLY(T);
|
||||
}
|
||||
|
||||
/**
|
||||
* A Type specific or-function helper function that reduces boxing/unboxing
|
||||
* @param other the other function that should be merged with.
|
||||
* @return a function that compares values in a or comparason
|
||||
*/
|
||||
public default FUNCTION KEY_VALUE_GENERIC_TYPE orType(FUNCTION KEY_VALUE_GENERIC_TYPE other) {
|
||||
Objects.requireNonNull(other);
|
||||
return T -> APPLY(T) || other.APPLY(T);
|
||||
}
|
||||
|
||||
#if JDK_FUNCTION
|
||||
@Override
|
||||
@Deprecated
|
||||
public default FUNCTION KEY_VALUE_GENERIC_TYPE or(JAVA_FUNCTION KEY_VALUE_SUPER_GENERIC_TYPE other) {
|
||||
Objects.requireNonNull(other);
|
||||
return T -> APPLY(T) || other.APPLY(T);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,95 +1,95 @@
|
|||
package speiger.src.collections.PACKAGE.maps.interfaces;
|
||||
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* A type specific ConcurrentMap interface that reduces boxing/unboxing.
|
||||
* Since the interface adds nothing new. It is there just for completion sake.
|
||||
* @Type(T)
|
||||
* @ValueType(V)
|
||||
*/
|
||||
public interface CONCURRENT_MAP KEY_VALUE_GENERIC_TYPE extends ConcurrentMap<CLASS_TYPE, CLASS_VALUE_TYPE>, MAP KEY_VALUE_GENERIC_TYPE
|
||||
{
|
||||
@Override
|
||||
@Primitive
|
||||
public default CLASS_VALUE_TYPE compute(CLASS_TYPE key, BiFunction<? super CLASS_TYPE, ? super CLASS_VALUE_TYPE, ? extends CLASS_VALUE_TYPE> mappingFunction) {
|
||||
return MAP.super.compute(key, mappingFunction);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Primitive
|
||||
public default CLASS_VALUE_TYPE computeIfAbsent(CLASS_TYPE key, Function<? super CLASS_TYPE, ? extends CLASS_VALUE_TYPE> mappingFunction) {
|
||||
return MAP.super.computeIfAbsent(key, mappingFunction);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Primitive
|
||||
public default CLASS_VALUE_TYPE computeIfPresent(CLASS_TYPE key, BiFunction<? super CLASS_TYPE, ? super CLASS_VALUE_TYPE, ? extends CLASS_VALUE_TYPE> mappingFunction) {
|
||||
return MAP.super.computeIfPresent(key, mappingFunction);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Primitive
|
||||
public default void forEach(BiConsumer<? super CLASS_TYPE, ? super CLASS_VALUE_TYPE> action) {
|
||||
MAP.super.forEach(action);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Primitive
|
||||
public default CLASS_VALUE_TYPE merge(CLASS_TYPE key, CLASS_VALUE_TYPE value, BiFunction<? super CLASS_VALUE_TYPE, ? super CLASS_VALUE_TYPE, ? extends CLASS_VALUE_TYPE> mappingFunction) {
|
||||
return MAP.super.merge(key, value, mappingFunction);
|
||||
}
|
||||
|
||||
#if TYPE_OBJECT && VALUE_OBJECT
|
||||
@Override
|
||||
public CLASS_VALUE_TYPE getOrDefault(Object key, CLASS_VALUE_TYPE defaultValue);
|
||||
@Override
|
||||
public CLASS_VALUE_TYPE putIfAbsent(CLASS_TYPE key, CLASS_VALUE_TYPE value);
|
||||
@Override
|
||||
public boolean remove(Object key, Object value);
|
||||
@Override
|
||||
public boolean replace(CLASS_TYPE key, CLASS_VALUE_TYPE oldValue, CLASS_VALUE_TYPE newValue);
|
||||
@Override
|
||||
public CLASS_VALUE_TYPE replace(CLASS_TYPE key, CLASS_VALUE_TYPE value);
|
||||
|
||||
#else
|
||||
@Primitive
|
||||
@Override
|
||||
public default CLASS_VALUE_TYPE getOrDefault(Object key, CLASS_VALUE_TYPE defaultValue) {
|
||||
return MAP.super.getOrDefault(key, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Primitive
|
||||
public default CLASS_VALUE_TYPE putIfAbsent(CLASS_TYPE key, CLASS_VALUE_TYPE value) {
|
||||
return MAP.super.putIfAbsent(key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public default boolean remove(Object key, Object value) {
|
||||
return MAP.super.remove(key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public default boolean replace(CLASS_TYPE key, CLASS_VALUE_TYPE oldValue, CLASS_VALUE_TYPE newValue) {
|
||||
return MAP.super.replace(key, oldValue, newValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public default CLASS_VALUE_TYPE replace(CLASS_TYPE key, CLASS_VALUE_TYPE value) {
|
||||
return MAP.super.replace(key, value);
|
||||
}
|
||||
|
||||
#endif
|
||||
@Override
|
||||
@Deprecated
|
||||
public default void replaceAll(BiFunction<? super CLASS_TYPE, ? super CLASS_VALUE_TYPE, ? extends CLASS_VALUE_TYPE> mappingFunction) {
|
||||
MAP.super.replaceAll(mappingFunction);
|
||||
}
|
||||
package speiger.src.collections.PACKAGE.maps.interfaces;
|
||||
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* A type specific ConcurrentMap interface that reduces boxing/unboxing.
|
||||
* Since the interface adds nothing new. It is there just for completion sake.
|
||||
* @Type(T)
|
||||
* @ValueType(V)
|
||||
*/
|
||||
public interface CONCURRENT_MAP KEY_VALUE_GENERIC_TYPE extends ConcurrentMap<CLASS_TYPE, CLASS_VALUE_TYPE>, MAP KEY_VALUE_GENERIC_TYPE
|
||||
{
|
||||
@Override
|
||||
@Primitive
|
||||
public default CLASS_VALUE_TYPE compute(CLASS_TYPE key, BiFunction<? super CLASS_TYPE, ? super CLASS_VALUE_TYPE, ? extends CLASS_VALUE_TYPE> mappingFunction) {
|
||||
return MAP.super.compute(key, mappingFunction);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Primitive
|
||||
public default CLASS_VALUE_TYPE computeIfAbsent(CLASS_TYPE key, Function<? super CLASS_TYPE, ? extends CLASS_VALUE_TYPE> mappingFunction) {
|
||||
return MAP.super.computeIfAbsent(key, mappingFunction);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Primitive
|
||||
public default CLASS_VALUE_TYPE computeIfPresent(CLASS_TYPE key, BiFunction<? super CLASS_TYPE, ? super CLASS_VALUE_TYPE, ? extends CLASS_VALUE_TYPE> mappingFunction) {
|
||||
return MAP.super.computeIfPresent(key, mappingFunction);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Primitive
|
||||
public default void forEach(BiConsumer<? super CLASS_TYPE, ? super CLASS_VALUE_TYPE> action) {
|
||||
MAP.super.forEach(action);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Primitive
|
||||
public default CLASS_VALUE_TYPE merge(CLASS_TYPE key, CLASS_VALUE_TYPE value, BiFunction<? super CLASS_VALUE_TYPE, ? super CLASS_VALUE_TYPE, ? extends CLASS_VALUE_TYPE> mappingFunction) {
|
||||
return MAP.super.merge(key, value, mappingFunction);
|
||||
}
|
||||
|
||||
#if TYPE_OBJECT && VALUE_OBJECT
|
||||
@Override
|
||||
public CLASS_VALUE_TYPE getOrDefault(Object key, CLASS_VALUE_TYPE defaultValue);
|
||||
@Override
|
||||
public CLASS_VALUE_TYPE putIfAbsent(CLASS_TYPE key, CLASS_VALUE_TYPE value);
|
||||
@Override
|
||||
public boolean remove(Object key, Object value);
|
||||
@Override
|
||||
public boolean replace(CLASS_TYPE key, CLASS_VALUE_TYPE oldValue, CLASS_VALUE_TYPE newValue);
|
||||
@Override
|
||||
public CLASS_VALUE_TYPE replace(CLASS_TYPE key, CLASS_VALUE_TYPE value);
|
||||
|
||||
#else
|
||||
@Primitive
|
||||
@Override
|
||||
public default CLASS_VALUE_TYPE getOrDefault(Object key, CLASS_VALUE_TYPE defaultValue) {
|
||||
return MAP.super.getOrDefault(key, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Primitive
|
||||
public default CLASS_VALUE_TYPE putIfAbsent(CLASS_TYPE key, CLASS_VALUE_TYPE value) {
|
||||
return MAP.super.putIfAbsent(key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public default boolean remove(Object key, Object value) {
|
||||
return MAP.super.remove(key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public default boolean replace(CLASS_TYPE key, CLASS_VALUE_TYPE oldValue, CLASS_VALUE_TYPE newValue) {
|
||||
return MAP.super.replace(key, oldValue, newValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public default CLASS_VALUE_TYPE replace(CLASS_TYPE key, CLASS_VALUE_TYPE value) {
|
||||
return MAP.super.replace(key, value);
|
||||
}
|
||||
|
||||
#endif
|
||||
@Override
|
||||
@Deprecated
|
||||
public default void replaceAll(BiFunction<? super CLASS_TYPE, ? super CLASS_VALUE_TYPE, ? extends CLASS_VALUE_TYPE> mappingFunction) {
|
||||
MAP.super.replaceAll(mappingFunction);
|
||||
}
|
||||
}
|
|
@ -1,46 +1,46 @@
|
|||
package speiger.src.collections.PACKAGE.queues;
|
||||
|
||||
#if TYPE_OBJECT
|
||||
import java.util.Objects;
|
||||
#endif
|
||||
import java.util.StringJoiner;
|
||||
|
||||
/**
|
||||
* Helper class that implements all the essential methods for the PriorityQueues
|
||||
* @Type(T)
|
||||
*/
|
||||
public abstract class ABSTRACT_PRIORITY_QUEUE KEY_GENERIC_TYPE implements PRIORITY_QUEUE KEY_GENERIC_TYPE
|
||||
{
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if(obj instanceof PRIORITY_QUEUE) {
|
||||
PRIORITY_QUEUE KEY_GENERIC_TYPE queue = (PRIORITY_QUEUE KEY_GENERIC_TYPE)obj;
|
||||
if(queue.size() != size()) return false;
|
||||
for(int i = 0,m=size();i<m;i++) {
|
||||
if(KEY_EQUALS_NOT(queue.peek(i), peek(i))) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = 1;
|
||||
for (int i = 0,m=size();i<m;i++) {
|
||||
result = 31 * result + KEY_TO_HASH(peek(i));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
if(isEmpty()) return "[]";
|
||||
StringJoiner joiner = new StringJoiner(", ", "[", "]");
|
||||
for (int i = 0,m=size();i<m;i++) {
|
||||
joiner.add(KEY_TO_STRING(peek(i)));
|
||||
}
|
||||
return joiner.toString();
|
||||
}
|
||||
}
|
||||
package speiger.src.collections.PACKAGE.queues;
|
||||
|
||||
#if TYPE_OBJECT
|
||||
import java.util.Objects;
|
||||
#endif
|
||||
import java.util.StringJoiner;
|
||||
|
||||
/**
|
||||
* Helper class that implements all the essential methods for the PriorityQueues
|
||||
* @Type(T)
|
||||
*/
|
||||
public abstract class ABSTRACT_PRIORITY_QUEUE KEY_GENERIC_TYPE implements PRIORITY_QUEUE KEY_GENERIC_TYPE
|
||||
{
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if(obj instanceof PRIORITY_QUEUE) {
|
||||
PRIORITY_QUEUE KEY_GENERIC_TYPE queue = (PRIORITY_QUEUE KEY_GENERIC_TYPE)obj;
|
||||
if(queue.size() != size()) return false;
|
||||
for(int i = 0,m=size();i<m;i++) {
|
||||
if(KEY_EQUALS_NOT(queue.peek(i), peek(i))) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = 1;
|
||||
for (int i = 0,m=size();i<m;i++) {
|
||||
result = 31 * result + KEY_TO_HASH(peek(i));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
if(isEmpty()) return "[]";
|
||||
StringJoiner joiner = new StringJoiner(", ", "[", "]");
|
||||
for (int i = 0,m=size();i<m;i++) {
|
||||
joiner.add(KEY_TO_STRING(peek(i)));
|
||||
}
|
||||
return joiner.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,195 +1,196 @@
|
|||
package speiger.src.collections.PACKAGE.queues;
|
||||
|
||||
#if TYPE_OBJECT
|
||||
import java.util.Comparator;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.function.IntFunction;
|
||||
#else
|
||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||
#endif
|
||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||
import speiger.src.collections.PACKAGE.collections.ITERABLE;
|
||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||
#if QUEUES_FEATURE
|
||||
import speiger.src.collections.PACKAGE.utils.PRIORITY_QUEUES;
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* A Simple PriorityQueue (or Queue) interface that provides with the nessesary functions to interact with it, without cluttering with the Collection interface.
|
||||
* @Type(T)
|
||||
*/
|
||||
public interface PRIORITY_QUEUE KEY_GENERIC_TYPE extends ITERABLE KEY_GENERIC_TYPE
|
||||
{
|
||||
/**
|
||||
* @return true if the PriorityQueue is empty
|
||||
*/
|
||||
public default boolean isEmpty() { return size() <= 0; }
|
||||
/**
|
||||
* @return the amount of elements that are stored in the PriorityQueue
|
||||
*/
|
||||
public int size();
|
||||
/**
|
||||
* clears all elements within the PriorityQueue,
|
||||
* this does not resize the backing arrays
|
||||
*/
|
||||
public void clear();
|
||||
|
||||
/**
|
||||
* Method to insert a element into the PriorityQueue
|
||||
* @param e the element that should be inserted
|
||||
*/
|
||||
public void enqueue(KEY_TYPE e);
|
||||
|
||||
/**
|
||||
* Method to mass insert elements into the PriorityQueue
|
||||
* @param e the elements that should be inserted
|
||||
*/
|
||||
public default void enqueueAll(KEY_TYPE... e) {
|
||||
enqueueAll(e, 0, e.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to mass insert elements into the PriorityQueue
|
||||
* @param e the elements that should be inserted
|
||||
* @param length the amount of elements that should be inserted
|
||||
*/
|
||||
public default void enqueueAll(KEY_TYPE[] e, int length) {
|
||||
enqueueAll(e, 0, length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to mass insert elements into the PriorityQueue
|
||||
* @param e the elements that should be inserted
|
||||
* @param offset the offset where in the array should be started
|
||||
* @param length the amount of elements that should be inserted
|
||||
*/
|
||||
public default void enqueueAll(KEY_TYPE[] e, int offset, int length) {
|
||||
for(int i = 0;i<length;i++)
|
||||
enqueue(e[i+offset]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to mass insert elements into the PriorityQueue
|
||||
* @param c the elements that should be inserted from the Collection
|
||||
*/
|
||||
public default void enqueueAll(COLLECTION KEY_GENERIC_TYPE c) {
|
||||
for(ITERATOR KEY_GENERIC_TYPE iter = c.iterator();iter.hasNext();)
|
||||
enqueue(iter.NEXT());
|
||||
}
|
||||
|
||||
#if TYPE_OBJECT
|
||||
/**
|
||||
* Method to mass insert elements into the PriorityQueue
|
||||
* This method exists to add support for Java Collections to make it more useable
|
||||
* @param c the elements that should be inserted from the Collection
|
||||
*/
|
||||
public default void enqueueAll(Collection<? extends CLASS_TYPE> c) {
|
||||
for(Iterator<? extends CLASS_TYPE> iter = c.iterator();iter.hasNext();)
|
||||
enqueue(iter.next());
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Method to extract a element from the PriorityQueue
|
||||
* @return a element from the Queue
|
||||
* @throws java.util.NoSuchElementException if no element is present
|
||||
*/
|
||||
public KEY_TYPE dequeue();
|
||||
|
||||
/**
|
||||
* Peeking function to see whats inside the queue.
|
||||
* @param index of the element that is requested to be viewed.
|
||||
* @return the element that is requested
|
||||
*/
|
||||
public KEY_TYPE peek(int index);
|
||||
/**
|
||||
* Shows the element that is to be returned next
|
||||
* @return the first element in the Queue
|
||||
*/
|
||||
public default KEY_TYPE first() { return peek(0); }
|
||||
|
||||
/**
|
||||
* Removes the first found element in the queue
|
||||
* @param e the element that should be removed
|
||||
* @return if a searched element was removed
|
||||
*/
|
||||
public boolean removeFirst(KEY_TYPE e);
|
||||
/**
|
||||
* Removes the last found element in the queue
|
||||
* @param e the element that should be removed
|
||||
* @return if a searched element was removed
|
||||
*/
|
||||
public boolean removeLast(KEY_TYPE e);
|
||||
|
||||
/**
|
||||
* Allows to notify the Queue to be revalidate its data
|
||||
*/
|
||||
public void onChanged();
|
||||
|
||||
/**
|
||||
* A Function that does a shallow clone of the PriorityQueue itself.
|
||||
* This function is more optimized then a copy constructor since the PriorityQueue does not have to be unsorted/resorted.
|
||||
* It can be compared to Cloneable but with less exception risk
|
||||
* @return a Shallow Copy of the PriorityQueue
|
||||
* @note Wrappers and view PriorityQueues will not support this feature
|
||||
*/
|
||||
public PRIORITY_QUEUE KEY_GENERIC_TYPE copy();
|
||||
|
||||
/**
|
||||
* @return the sorter of the Queue, can be null
|
||||
*/
|
||||
public COMPARATOR KEY_SUPER_GENERIC_TYPE comparator();
|
||||
|
||||
#if TYPE_OBJECT
|
||||
/**
|
||||
* @return draining iterator of the PriorityQueue
|
||||
*/
|
||||
public ITERATOR KEY_GENERIC_TYPE iterator();
|
||||
|
||||
#endif
|
||||
#if QUEUES_FEATURE
|
||||
/**
|
||||
* Creates a Wrapped PriorityQueue that is Synchronized
|
||||
* @return a new PriorityQueue that is synchronized
|
||||
* @see PRIORITY_QUEUES#synchronize
|
||||
*/
|
||||
public default PRIORITY_QUEUE KEY_GENERIC_TYPE synchronizeQueue() { return PRIORITY_QUEUES.synchronize(this); }
|
||||
|
||||
/**
|
||||
* Creates a Wrapped PriorityQueue that is Synchronized
|
||||
* @param mutex is the controller of the synchronization block
|
||||
* @return a new PriorityQueue Wrapper that is synchronized
|
||||
* @see PRIORITY_QUEUES#synchronize
|
||||
*/
|
||||
public default PRIORITY_QUEUE KEY_GENERIC_TYPE synchronizeQueue(Object mutex) { return PRIORITY_QUEUES.synchronize(this, mutex); }
|
||||
|
||||
#endif
|
||||
/**
|
||||
* A method to drop the contents of the Queue without clearing the queue
|
||||
* @Type(E)
|
||||
* @return the contents of the queue into a seperate array.
|
||||
*/
|
||||
public default GENERIC_SPECIAL_KEY_BRACES<E> KEY_SPECIAL_TYPE[] TO_ARRAY() { return TO_ARRAY(NEW_SPECIAL_KEY_ARRAY(size())); }
|
||||
/**
|
||||
* A method to drop the contents of the Queue without clearing the queue
|
||||
* @param input where the elements should be inserted to. If it does not fit then it creates a new appropiatly created array
|
||||
* @Type(E)
|
||||
* @return the contents of the queue into a seperate array.
|
||||
* @note if the Type is generic then a Object Array is created instead of a Type Array
|
||||
*/
|
||||
public GENERIC_SPECIAL_KEY_BRACES<E> KEY_SPECIAL_TYPE[] TO_ARRAY(KEY_SPECIAL_TYPE[] input);
|
||||
#if TYPE_OBJECT
|
||||
/**
|
||||
* A Helper function that simplifies the process of creating a new Array.
|
||||
* @param action the array creation function
|
||||
* @return an array containing all of the elements in this collection
|
||||
* @see Collection#toArray(Object[])
|
||||
*/
|
||||
default <E> E[] TO_ARRAY(IntFunction<E[]> action) {
|
||||
return TO_ARRAY(action.apply(size()));
|
||||
}
|
||||
#endif
|
||||
package speiger.src.collections.PACKAGE.queues;
|
||||
|
||||
#if TYPE_OBJECT
|
||||
import java.util.Comparator;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.function.IntFunction;
|
||||
#else
|
||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||
#endif
|
||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||
import speiger.src.collections.PACKAGE.collections.ITERABLE;
|
||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||
#if QUEUES_FEATURE
|
||||
import speiger.src.collections.PACKAGE.utils.PRIORITY_QUEUES;
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* A Simple PriorityQueue (or Queue) interface that provides with the nessesary functions to interact with it, without cluttering with the Collection interface.
|
||||
* @Type(T)
|
||||
*/
|
||||
public interface PRIORITY_QUEUE KEY_GENERIC_TYPE extends ITERABLE KEY_GENERIC_TYPE
|
||||
{
|
||||
/**
|
||||
* @return true if the PriorityQueue is empty
|
||||
*/
|
||||
public default boolean isEmpty() { return size() <= 0; }
|
||||
/**
|
||||
* @return the amount of elements that are stored in the PriorityQueue
|
||||
*/
|
||||
public int size();
|
||||
/**
|
||||
* clears all elements within the PriorityQueue,
|
||||
* this does not resize the backing arrays
|
||||
*/
|
||||
public void clear();
|
||||
|
||||
/**
|
||||
* Method to insert a element into the PriorityQueue
|
||||
* @param e the element that should be inserted
|
||||
*/
|
||||
public void enqueue(KEY_TYPE e);
|
||||
|
||||
/**
|
||||
* Method to mass insert elements into the PriorityQueue
|
||||
* @param e the elements that should be inserted
|
||||
*/
|
||||
public default void enqueueAll(KEY_TYPE... e) {
|
||||
enqueueAll(e, 0, e.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to mass insert elements into the PriorityQueue
|
||||
* @param e the elements that should be inserted
|
||||
* @param length the amount of elements that should be inserted
|
||||
*/
|
||||
public default void enqueueAll(KEY_TYPE[] e, int length) {
|
||||
enqueueAll(e, 0, length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to mass insert elements into the PriorityQueue
|
||||
* @param e the elements that should be inserted
|
||||
* @param offset the offset where in the array should be started
|
||||
* @param length the amount of elements that should be inserted
|
||||
*/
|
||||
public default void enqueueAll(KEY_TYPE[] e, int offset, int length) {
|
||||
for(int i = 0;i<length;i++)
|
||||
enqueue(e[i+offset]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to mass insert elements into the PriorityQueue
|
||||
* @param c the elements that should be inserted from the Collection
|
||||
*/
|
||||
public default void enqueueAll(COLLECTION KEY_GENERIC_TYPE c) {
|
||||
for(ITERATOR KEY_GENERIC_TYPE iter = c.iterator();iter.hasNext();)
|
||||
enqueue(iter.NEXT());
|
||||
}
|
||||
|
||||
#if TYPE_OBJECT
|
||||
/**
|
||||
* Method to mass insert elements into the PriorityQueue
|
||||
* This method exists to add support for Java Collections to make it more useable
|
||||
* @param c the elements that should be inserted from the Collection
|
||||
*/
|
||||
public default void enqueueAll(Collection<? extends CLASS_TYPE> c) {
|
||||
for(Iterator<? extends CLASS_TYPE> iter = c.iterator();iter.hasNext();)
|
||||
enqueue(iter.next());
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Method to extract a element from the PriorityQueue
|
||||
* @return a element from the Queue
|
||||
* @throws java.util.NoSuchElementException if no element is present
|
||||
*/
|
||||
public KEY_TYPE dequeue();
|
||||
|
||||
/**
|
||||
* Peeking function to see whats inside the queue.
|
||||
* @param index of the element that is requested to be viewed.
|
||||
* @return the element that is requested
|
||||
*/
|
||||
public KEY_TYPE peek(int index);
|
||||
/**
|
||||
* Shows the element that is to be returned next
|
||||
* @return the first element in the Queue
|
||||
*/
|
||||
public default KEY_TYPE first() { return peek(0); }
|
||||
|
||||
/**
|
||||
* Removes the first found element in the queue
|
||||
* @param e the element that should be removed
|
||||
* @return if a searched element was removed
|
||||
*/
|
||||
public boolean removeFirst(KEY_TYPE e);
|
||||
/**
|
||||
* Removes the last found element in the queue
|
||||
* @param e the element that should be removed
|
||||
* @return if a searched element was removed
|
||||
*/
|
||||
public boolean removeLast(KEY_TYPE e);
|
||||
|
||||
/**
|
||||
* Allows to notify the Queue to be revalidate its data
|
||||
*/
|
||||
public void onChanged();
|
||||
|
||||
/**
|
||||
* A Function that does a shallow clone of the PriorityQueue itself.
|
||||
* This function is more optimized then a copy constructor since the PriorityQueue does not have to be unsorted/resorted.
|
||||
* It can be compared to Cloneable but with less exception risk
|
||||
* @return a Shallow Copy of the PriorityQueue
|
||||
* @note Wrappers and view PriorityQueues will not support this feature
|
||||
*/
|
||||
public PRIORITY_QUEUE KEY_GENERIC_TYPE copy();
|
||||
|
||||
/**
|
||||
* @return the sorter of the Queue, can be null
|
||||
*/
|
||||
public COMPARATOR KEY_SUPER_GENERIC_TYPE comparator();
|
||||
|
||||
#if TYPE_OBJECT
|
||||
/**
|
||||
* @return draining iterator of the PriorityQueue
|
||||
*/
|
||||
public ITERATOR KEY_GENERIC_TYPE iterator();
|
||||
|
||||
#endif
|
||||
#if QUEUES_FEATURE
|
||||
/**
|
||||
* Creates a Wrapped PriorityQueue that is Synchronized
|
||||
* @return a new PriorityQueue that is synchronized
|
||||
* @see PRIORITY_QUEUES#synchronize
|
||||
*/
|
||||
public default PRIORITY_QUEUE KEY_GENERIC_TYPE synchronizeQueue() { return PRIORITY_QUEUES.synchronize(this); }
|
||||
|
||||
/**
|
||||
* Creates a Wrapped PriorityQueue that is Synchronized
|
||||
* @param mutex is the controller of the synchronization block
|
||||
* @return a new PriorityQueue Wrapper that is synchronized
|
||||
* @see PRIORITY_QUEUES#synchronize
|
||||
*/
|
||||
public default PRIORITY_QUEUE KEY_GENERIC_TYPE synchronizeQueue(Object mutex) { return PRIORITY_QUEUES.synchronize(this, mutex); }
|
||||
|
||||
#endif
|
||||
/**
|
||||
* A method to drop the contents of the Queue without clearing the queue
|
||||
* @Type(E)
|
||||
* @return the contents of the queue into a seperate array.
|
||||
*/
|
||||
public default GENERIC_SPECIAL_KEY_BRACES<E> KEY_SPECIAL_TYPE[] TO_ARRAY() { return TO_ARRAY(NEW_SPECIAL_KEY_ARRAY(size())); }
|
||||
/**
|
||||
* A method to drop the contents of the Queue without clearing the queue
|
||||
* @param input where the elements should be inserted to. If it does not fit then it creates a new appropiatly created array
|
||||
* @Type(E)
|
||||
* @return the contents of the queue into a seperate array.
|
||||
* @note if the Type is generic then a Object Array is created instead of a Type Array
|
||||
*/
|
||||
public GENERIC_SPECIAL_KEY_BRACES<E> KEY_SPECIAL_TYPE[] TO_ARRAY(KEY_SPECIAL_TYPE[] input);
|
||||
#if TYPE_OBJECT
|
||||
/**
|
||||
* A Helper function that simplifies the process of creating a new Array.
|
||||
* @param action the array creation function
|
||||
* @param <E> the returning arrayType
|
||||
* @return an array containing all of the elements in this collection
|
||||
* @see Collection#toArray(Object[])
|
||||
*/
|
||||
default <E> E[] TO_ARRAY(IntFunction<E[]> action) {
|
||||
return TO_ARRAY(action.apply(size()));
|
||||
}
|
||||
#endif
|
||||
}
|
|
@ -1,50 +1,50 @@
|
|||
package speiger.src.collections.PACKAGE.sets;
|
||||
|
||||
#if TYPE_OBJECT
|
||||
import java.util.Objects;
|
||||
#endif
|
||||
import java.util.Set;
|
||||
|
||||
import speiger.src.collections.PACKAGE.collections.ABSTRACT_COLLECTION;
|
||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||
|
||||
/**
|
||||
* Abstract Type Specific Set that reduces boxing/unboxing
|
||||
* @Type(T)
|
||||
*/
|
||||
public abstract class ABSTRACT_SET KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION KEY_GENERIC_TYPE implements SET KEY_GENERIC_TYPE
|
||||
{
|
||||
#if TYPE_OBJECT
|
||||
@Override
|
||||
public KEY_TYPE addOrGet(KEY_TYPE o) { throw new UnsupportedOperationException(); }
|
||||
|
||||
#endif
|
||||
@Override
|
||||
public abstract ITERATOR KEY_GENERIC_TYPE iterator();
|
||||
@Override
|
||||
public ABSTRACT_SET KEY_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); }
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hashCode = 0;
|
||||
ITERATOR KEY_GENERIC_TYPE i = iterator();
|
||||
while(i.hasNext())
|
||||
hashCode += KEY_TO_HASH(i.NEXT());
|
||||
return hashCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o == this)
|
||||
return true;
|
||||
if (!(o instanceof Set))
|
||||
return false;
|
||||
Set<?> l = (Set<?>)o;
|
||||
if(l.size() != size()) return false;
|
||||
try {
|
||||
return containsAll(l);
|
||||
} catch (ClassCastException | NullPointerException unused) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
package speiger.src.collections.PACKAGE.sets;
|
||||
|
||||
#if TYPE_OBJECT
|
||||
import java.util.Objects;
|
||||
#endif
|
||||
import java.util.Set;
|
||||
|
||||
import speiger.src.collections.PACKAGE.collections.ABSTRACT_COLLECTION;
|
||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||
|
||||
/**
|
||||
* Abstract Type Specific Set that reduces boxing/unboxing
|
||||
* @Type(T)
|
||||
*/
|
||||
public abstract class ABSTRACT_SET KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION KEY_GENERIC_TYPE implements SET KEY_GENERIC_TYPE
|
||||
{
|
||||
#if TYPE_OBJECT
|
||||
@Override
|
||||
public KEY_TYPE addOrGet(KEY_TYPE o) { throw new UnsupportedOperationException(); }
|
||||
|
||||
#endif
|
||||
@Override
|
||||
public abstract ITERATOR KEY_GENERIC_TYPE iterator();
|
||||
@Override
|
||||
public ABSTRACT_SET KEY_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); }
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hashCode = 0;
|
||||
ITERATOR KEY_GENERIC_TYPE i = iterator();
|
||||
while(i.hasNext())
|
||||
hashCode += KEY_TO_HASH(i.NEXT());
|
||||
return hashCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o == this)
|
||||
return true;
|
||||
if (!(o instanceof Set))
|
||||
return false;
|
||||
Set<?> l = (Set<?>)o;
|
||||
if(l.size() != size()) return false;
|
||||
try {
|
||||
return containsAll(l);
|
||||
} catch (ClassCastException | NullPointerException unused) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,28 +1,28 @@
|
|||
package speiger.src.testers.PACKAGE.builder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.testing.AbstractTester;
|
||||
|
||||
import speiger.src.testers.PACKAGE.generators.TEST_QUEUE_GENERATOR;
|
||||
import speiger.src.testers.PACKAGE.tests.queue.FILE_KEY_TYPEDequeueDequeueTester;
|
||||
import speiger.src.testers.PACKAGE.tests.queue.FILE_KEY_TYPEDequeueEnqueueTester;
|
||||
import speiger.src.testers.PACKAGE.tests.queue.FILE_KEY_TYPEDequeueLastTester;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public class DEQUEUE_TEST_BUILDER KEY_GENERIC_TYPE extends QUEUE_TEST_BUILDER KEY_GENERIC_TYPE
|
||||
{
|
||||
public static GENERIC_KEY_BRACES DEQUEUE_TEST_BUILDER KEY_GENERIC_TYPE using(TEST_QUEUE_GENERATOR KEY_GENERIC_TYPE builder) {
|
||||
return (DEQUEUE_TEST_BUILDER KEY_GENERIC_TYPE)new DEQUEUE_TEST_BUILDER KEY_GENERIC_TYPE().usingGenerator(builder);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("rawtypes")
|
||||
protected List<Class<? extends AbstractTester>> getTesters() {
|
||||
List<Class<? extends AbstractTester>> tester = super.getTesters();
|
||||
tester.add(FILE_KEY_TYPEDequeueDequeueTester.class);
|
||||
tester.add(FILE_KEY_TYPEDequeueEnqueueTester.class);
|
||||
tester.add(FILE_KEY_TYPEDequeueLastTester.class);
|
||||
return tester;
|
||||
}
|
||||
}
|
||||
package speiger.src.testers.PACKAGE.builder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.testing.AbstractTester;
|
||||
|
||||
import speiger.src.testers.PACKAGE.generators.TEST_QUEUE_GENERATOR;
|
||||
import speiger.src.testers.PACKAGE.tests.queue.FILE_KEY_TYPEDequeueDequeueTester;
|
||||
import speiger.src.testers.PACKAGE.tests.queue.FILE_KEY_TYPEDequeueEnqueueTester;
|
||||
import speiger.src.testers.PACKAGE.tests.queue.FILE_KEY_TYPEDequeueLastTester;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public class DEQUEUE_TEST_BUILDER KEY_GENERIC_TYPE extends QUEUE_TEST_BUILDER KEY_GENERIC_TYPE
|
||||
{
|
||||
public static GENERIC_KEY_BRACES DEQUEUE_TEST_BUILDER KEY_GENERIC_TYPE using(TEST_QUEUE_GENERATOR KEY_GENERIC_TYPE builder) {
|
||||
return (DEQUEUE_TEST_BUILDER KEY_GENERIC_TYPE)new DEQUEUE_TEST_BUILDER KEY_GENERIC_TYPE().usingGenerator(builder);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("rawtypes")
|
||||
protected List<Class<? extends AbstractTester>> getTesters() {
|
||||
List<Class<? extends AbstractTester>> tester = super.getTesters();
|
||||
tester.add(FILE_KEY_TYPEDequeueDequeueTester.class);
|
||||
tester.add(FILE_KEY_TYPEDequeueEnqueueTester.class);
|
||||
tester.add(FILE_KEY_TYPEDequeueLastTester.class);
|
||||
return tester;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,384 +1,384 @@
|
|||
package speiger.src.testers.PACKAGE.builder;
|
||||
|
||||
#ignore
|
||||
import static com.google.common.collect.testing.features.CollectionFeature.KNOWN_ORDER;
|
||||
import static com.google.common.collect.testing.features.CollectionFeature.SERIALIZABLE;
|
||||
import static com.google.common.collect.testing.features.CollectionFeature.SERIALIZABLE_INCLUDING_VIEWS;
|
||||
#endignore
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.collect.testing.AbstractTester;
|
||||
import com.google.common.collect.testing.FeatureSpecificTestSuiteBuilder;
|
||||
import com.google.common.collect.testing.Helpers;
|
||||
import com.google.common.collect.testing.ListTestSuiteBuilder;
|
||||
import com.google.common.collect.testing.OneSizeTestContainerGenerator;
|
||||
import com.google.common.collect.testing.SampleElements;
|
||||
import com.google.common.collect.testing.TestListGenerator;
|
||||
import com.google.common.collect.testing.features.CollectionFeature;
|
||||
import com.google.common.collect.testing.features.Feature;
|
||||
import com.google.common.collect.testing.testers.CollectionSerializationEqualTester;
|
||||
import com.google.common.collect.testing.testers.ListAddAllAtIndexTester;
|
||||
import com.google.common.collect.testing.testers.ListAddAllTester;
|
||||
import com.google.common.collect.testing.testers.ListAddAtIndexTester;
|
||||
import com.google.common.collect.testing.testers.ListAddTester;
|
||||
import com.google.common.collect.testing.testers.ListCreationTester;
|
||||
import com.google.common.collect.testing.testers.ListEqualsTester;
|
||||
import com.google.common.collect.testing.testers.ListGetTester;
|
||||
import com.google.common.collect.testing.testers.ListHashCodeTester;
|
||||
import com.google.common.collect.testing.testers.ListIndexOfTester;
|
||||
import com.google.common.collect.testing.testers.ListLastIndexOfTester;
|
||||
import com.google.common.collect.testing.testers.ListRemoveAllTester;
|
||||
import com.google.common.collect.testing.testers.ListRemoveAtIndexTester;
|
||||
import com.google.common.collect.testing.testers.ListRemoveTester;
|
||||
import com.google.common.collect.testing.testers.ListReplaceAllTester;
|
||||
import com.google.common.collect.testing.testers.ListRetainAllTester;
|
||||
import com.google.common.collect.testing.testers.ListSetTester;
|
||||
import com.google.common.collect.testing.testers.ListSubListTester;
|
||||
import com.google.common.collect.testing.testers.ListToArrayTester;
|
||||
import com.google.common.testing.SerializableTester;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
import speiger.src.collections.PACKAGE.collections.ITERABLE;
|
||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||
import speiger.src.testers.base.tests.list.JavaListListIteratorTester;
|
||||
import speiger.src.testers.PACKAGE.generators.TEST_LIST_GENERATOR;
|
||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListAbsentTester;
|
||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListAddAllArrayAtIndexTester;
|
||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListAddAllAtIndexTester;
|
||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListAddAllListAtIndexTester;
|
||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListAddAllTester;
|
||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListAddAtIndexTester;
|
||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListAddTester;
|
||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListCreationTester;
|
||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListEqualsTester;
|
||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListExtractElementsTester;
|
||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListGetElementsTester;
|
||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListGetTester;
|
||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListIndexOfTester;
|
||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListLastIndexOfTester;
|
||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListListIteratorTester;
|
||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListPresentTester;
|
||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListRemoveAllTester;
|
||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListRemoveAtIndexTester;
|
||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListRemoveElementsTester;
|
||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListRemoveTester;
|
||||
#if !TYPE_BOOLEAN
|
||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListSortTester;
|
||||
#if !TYPE_OBJECT
|
||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListFillBufferTester;
|
||||
#endif
|
||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListReplaceAllTester;
|
||||
#endif
|
||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListRetainAllTester;
|
||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListSetTester;
|
||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListSubListTester;
|
||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListSwapRemoveAtIndexTester;
|
||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListSwapRemoveTester;
|
||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListToArrayTester;
|
||||
import speiger.src.testers.PACKAGE.utils.SAMPLE_ELEMENTS;
|
||||
#if !TYPE_BOOLEAN
|
||||
import speiger.src.testers.utils.SpecialFeature;
|
||||
#endif
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public class LIST_TEST_BUILDER KEY_GENERIC_TYPE extends COLLECTION_TEST_BUILDER KEY_GENERIC_TYPE {
|
||||
|
||||
#if TYPE_OBJECT
|
||||
KEY_TYPE[] prefixes;
|
||||
KEY_TYPE[] suffixes;
|
||||
#else
|
||||
KEY_TYPE[] prefixes = createPrefixes();
|
||||
KEY_TYPE[] suffixes = createSuffixes();
|
||||
#endif
|
||||
|
||||
public static GENERIC_KEY_BRACES LIST_TEST_BUILDER KEY_GENERIC_TYPE using(TEST_LIST_GENERATOR KEY_GENERIC_TYPE generator) {
|
||||
return (LIST_TEST_BUILDER KEY_GENERIC_TYPE) new LIST_TEST_BUILDER KEY_GENERIC_TYPE().usingGenerator(generator);
|
||||
}
|
||||
|
||||
public LIST_TEST_BUILDER KEY_GENERIC_TYPE setPrefixes(KEY_TYPE[] prefixes) {
|
||||
this.prefixes = prefixes;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LIST_TEST_BUILDER KEY_GENERIC_TYPE setSuffixes(KEY_TYPE[] suffixes) {
|
||||
this.suffixes = suffixes;
|
||||
return this;
|
||||
}
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
public KEY_TYPE[] createPrefixes() {
|
||||
#if TYPE_BOOLEAN
|
||||
return new KEY_TYPE[]{false, false, false};
|
||||
#else if TYPE_BYTE
|
||||
return new KEY_TYPE[]{(byte)-3, (byte)-2, (byte)-1};
|
||||
#else if TYPE_SHORT
|
||||
return new KEY_TYPE[]{(short)-3, (short)-2, (short)-1};
|
||||
#else if TYPE_CHAR
|
||||
return new KEY_TYPE[]{'^', '_', '`'};
|
||||
#else
|
||||
return new KEY_TYPE[]{-3, -2, -1};
|
||||
#endif
|
||||
}
|
||||
|
||||
public KEY_TYPE[] createSuffixes() {
|
||||
#if TYPE_BOOLEAN
|
||||
return new KEY_TYPE[]{true, true, true};
|
||||
#else if TYPE_BYTE
|
||||
return new KEY_TYPE[]{(byte)5, (byte)6, (byte)7};
|
||||
#else if TYPE_SHORT
|
||||
return new KEY_TYPE[]{(short)5, (short)6, (short)7};
|
||||
#else if TYPE_CHAR
|
||||
return new KEY_TYPE[]{'f', 'g', 'h'};
|
||||
#else
|
||||
return new KEY_TYPE[]{5, 6, 7};
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
@Override
|
||||
@SuppressWarnings("rawtypes")
|
||||
protected List<Class<? extends AbstractTester>> getTesters() {
|
||||
List<Class<? extends AbstractTester>> testers = Helpers.copyToList(super.getTesters());
|
||||
|
||||
testers.add(CollectionSerializationEqualTester.class);
|
||||
testers.add(ListAddAllAtIndexTester.class);
|
||||
testers.add(ListAddAllTester.class);
|
||||
testers.add(ListAddAtIndexTester.class);
|
||||
testers.add(ListAddTester.class);
|
||||
testers.add(ListCreationTester.class);
|
||||
testers.add(ListEqualsTester.class);
|
||||
testers.add(ListGetTester.class);
|
||||
testers.add(ListHashCodeTester.class);
|
||||
testers.add(ListIndexOfTester.class);
|
||||
testers.add(ListLastIndexOfTester.class);
|
||||
testers.add(JavaListListIteratorTester.class);
|
||||
testers.add(ListRemoveAllTester.class);
|
||||
testers.add(ListRemoveAtIndexTester.class);
|
||||
testers.add(ListRemoveTester.class);
|
||||
testers.add(ListReplaceAllTester.class);
|
||||
testers.add(ListRetainAllTester.class);
|
||||
testers.add(ListSetTester.class);
|
||||
testers.add(ListSubListTester.class);
|
||||
testers.add(ListToArrayTester.class);
|
||||
|
||||
testers.add(FILE_KEY_TYPEListAddAllAtIndexTester.class);
|
||||
testers.add(FILE_KEY_TYPEListAddAllListAtIndexTester.class);
|
||||
testers.add(FILE_KEY_TYPEListAddAllArrayAtIndexTester.class);
|
||||
testers.add(FILE_KEY_TYPEListAddAllTester.class);
|
||||
testers.add(FILE_KEY_TYPEListAddAtIndexTester.class);
|
||||
testers.add(FILE_KEY_TYPEListAddTester.class);
|
||||
testers.add(FILE_KEY_TYPEListAbsentTester.class);
|
||||
testers.add(FILE_KEY_TYPEListPresentTester.class);
|
||||
testers.add(FILE_KEY_TYPEListCreationTester.class);
|
||||
testers.add(FILE_KEY_TYPEListEqualsTester.class);
|
||||
testers.add(FILE_KEY_TYPEListGetTester.class);
|
||||
testers.add(FILE_KEY_TYPEListGetElementsTester.class);
|
||||
testers.add(FILE_KEY_TYPEListExtractElementsTester.class);
|
||||
testers.add(FILE_KEY_TYPEListIndexOfTester.class);
|
||||
testers.add(FILE_KEY_TYPEListLastIndexOfTester.class);
|
||||
testers.add(FILE_KEY_TYPEListListIteratorTester.class);
|
||||
testers.add(FILE_KEY_TYPEListRemoveAllTester.class);
|
||||
testers.add(FILE_KEY_TYPEListRemoveAtIndexTester.class);
|
||||
testers.add(FILE_KEY_TYPEListRemoveTester.class);
|
||||
testers.add(FILE_KEY_TYPEListRemoveElementsTester.class);
|
||||
testers.add(FILE_KEY_TYPEListSwapRemoveAtIndexTester.class);
|
||||
testers.add(FILE_KEY_TYPEListSwapRemoveTester.class);
|
||||
#if !TYPE_BOOLEAN
|
||||
testers.add(FILE_KEY_TYPEListSortTester.class);
|
||||
#if !TYPE_OBJECT
|
||||
testers.add(FILE_KEY_TYPEListFillBufferTester.class);
|
||||
#endif
|
||||
testers.add(FILE_KEY_TYPEListReplaceAllTester.class);
|
||||
#endif
|
||||
testers.add(FILE_KEY_TYPEListRetainAllTester.class);
|
||||
testers.add(FILE_KEY_TYPEListSetTester.class);
|
||||
testers.add(FILE_KEY_TYPEListSubListTester.class);
|
||||
testers.add(FILE_KEY_TYPEListToArrayTester.class);
|
||||
return testers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TestSuite createTestSuite() {
|
||||
#ignore
|
||||
withFeatures(KNOWN_ORDER);
|
||||
#endignore
|
||||
return super.createTestSuite();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<TestSuite> createDerivedSuites(FeatureSpecificTestSuiteBuilder<?, ? extends OneSizeTestContainerGenerator<Collection<CLASS_TYPE>, CLASS_TYPE>> parentBuilder) {
|
||||
List<TestSuite> derivedSuites = new ArrayList<>(super.createDerivedSuites(parentBuilder));
|
||||
#ignore
|
||||
if (parentBuilder.getFeatures().contains(SERIALIZABLE)) {
|
||||
#endignore
|
||||
derivedSuites.add(ListTestSuiteBuilder.using(new ReserializedListGenerator<CLASS_TYPE>(parentBuilder.getSubjectGenerator()))
|
||||
.named(getName() + " reserialized")
|
||||
.withFeatures(computeReserializedCollectionFeatures(parentBuilder.getFeatures()))
|
||||
.suppressing(parentBuilder.getSuppressedTests()).withSetUp(parentBuilder.getSetUp())
|
||||
.withTearDown(parentBuilder.getTearDown()).createTestSuite());
|
||||
}
|
||||
#ignore
|
||||
if(!parentBuilder.getFeatures().contains(CollectionFeature.SUBSET_VIEW)) {
|
||||
#endignore
|
||||
#if !TYPE_BOOLEAN
|
||||
if(prefixes != null) {
|
||||
derivedSuites.add(LIST_TEST_BUILDER.using(new SubListListGeneratorBRACES(parentBuilder.getSubjectGenerator(), prefixes, null))
|
||||
.named(getName() + " subSet_prefix")
|
||||
.withFeatures(computeSubListFeatures(parentBuilder.getFeatures()))
|
||||
.suppressing(parentBuilder.getSuppressedTests()).withSetUp(parentBuilder.getSetUp())
|
||||
.withTearDown(parentBuilder.getTearDown()).createTestSuite());
|
||||
}
|
||||
if(suffixes != null) {
|
||||
derivedSuites.add(LIST_TEST_BUILDER.using(new SubListListGeneratorBRACES(parentBuilder.getSubjectGenerator(), null, suffixes))
|
||||
.named(getName() + " subSet_suffixes")
|
||||
.withFeatures(computeSubListFeatures(parentBuilder.getFeatures()))
|
||||
.suppressing(parentBuilder.getSuppressedTests()).withSetUp(parentBuilder.getSetUp())
|
||||
.withTearDown(parentBuilder.getTearDown()).createTestSuite());
|
||||
}
|
||||
if(prefixes != null && suffixes != null) {
|
||||
derivedSuites.add(LIST_TEST_BUILDER.using(new SubListListGeneratorBRACES(parentBuilder.getSubjectGenerator(), prefixes, suffixes))
|
||||
.named(getName() + " subSet")
|
||||
.withFeatures(computeSubListFeatures(parentBuilder.getFeatures()))
|
||||
.suppressing(parentBuilder.getSuppressedTests()).withSetUp(parentBuilder.getSetUp())
|
||||
.withTearDown(parentBuilder.getTearDown()).createTestSuite());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return derivedSuites;
|
||||
}
|
||||
|
||||
static class SubListListGenerator KEY_GENERIC_TYPE implements TEST_LIST_GENERATOR KEY_GENERIC_TYPE {
|
||||
TEST_LIST_GENERATOR KEY_GENERIC_TYPE generator;
|
||||
KEY_TYPE[] prefix;
|
||||
KEY_TYPE[] suffix;
|
||||
|
||||
public SubListListGenerator(OneSizeTestContainerGenerator<Collection<CLASS_TYPE>, CLASS_TYPE> gen, KEY_TYPE[] prefix, KEY_TYPE[] suffix) {
|
||||
generator = (TEST_LIST_GENERATOR KEY_GENERIC_TYPE)gen.getInnerGenerator();
|
||||
this.prefix = prefix;
|
||||
this.suffix = suffix;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SampleElements<CLASS_TYPE> samples() {
|
||||
return generator.samples();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CLASS_TYPE[] createArray(int length) {
|
||||
return generator.createArray(length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<CLASS_TYPE> order(List<CLASS_TYPE> insertionOrder) {
|
||||
return generator.order(insertionOrder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SAMPLE_ELEMENTS KEY_GENERIC_TYPE getSamples() {
|
||||
return generator.getSamples();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITERABLE KEY_GENERIC_TYPE order(LIST KEY_GENERIC_TYPE insertionOrder) {
|
||||
return generator.order(insertionOrder);
|
||||
}
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
@Override
|
||||
public LIST KEY_GENERIC_TYPE create(Object... elements) {
|
||||
KEY_TYPE[] array = NEW_KEY_ARRAY(elements.length);
|
||||
int i = 0;
|
||||
for (Object e : elements) {
|
||||
array[i++] = CLASS_TO_KEY(e);
|
||||
}
|
||||
return create(array);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LIST KEY_GENERIC_TYPE create(KEY_TYPE... elements) {
|
||||
int length = getLength(prefix);
|
||||
return generator.create(merge(elements)).subList(length, length+elements.length);
|
||||
}
|
||||
|
||||
#else
|
||||
@Override
|
||||
public LIST KEY_GENERIC_TYPE create(Object... elements) {
|
||||
KEY_TYPE[] array = NEW_KEY_ARRAY(elements.length);
|
||||
int i = 0;
|
||||
for (Object e : elements) {
|
||||
array[i++] = CLASS_TO_KEY(e);
|
||||
}
|
||||
int length = getLength(prefix);
|
||||
return generator.create(merge(array)).subList(length, length+elements.length);
|
||||
}
|
||||
|
||||
#endif
|
||||
private int getLength(KEY_TYPE[] keys) {
|
||||
return keys == null ? 0 : keys.length;
|
||||
}
|
||||
|
||||
private KEY_TYPE[] merge(KEY_TYPE[] input) {
|
||||
int prefixLength = getLength(prefix);
|
||||
int suffixLength = getLength(suffix);
|
||||
KEY_TYPE[] result = NEW_KEY_ARRAY(input.length+prefixLength+suffixLength);
|
||||
if(prefixLength != 0) System.arraycopy(prefix, 0, result, 0, prefixLength);
|
||||
System.arraycopy(input, 0, result, prefixLength, input.length);
|
||||
if(suffixLength != 0) System.arraycopy(suffix, 0, result, prefixLength+input.length, suffixLength);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
static class ReserializedListGenerator<E> implements TestListGenerator<E> {
|
||||
final OneSizeTestContainerGenerator<Collection<E>, E> gen;
|
||||
|
||||
private ReserializedListGenerator(OneSizeTestContainerGenerator<Collection<E>, E> gen) {
|
||||
this.gen = gen;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SampleElements<E> samples() {
|
||||
return gen.samples();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<E> create(Object... elements) {
|
||||
return (List<E>) SerializableTester.reserialize(gen.create(elements));
|
||||
}
|
||||
|
||||
@Override
|
||||
public E[] createArray(int length) {
|
||||
return gen.createArray(length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<E> order(List<E> insertionOrder) {
|
||||
return gen.order(insertionOrder);
|
||||
}
|
||||
}
|
||||
|
||||
#if !TYPE_BOOLEAN
|
||||
private static Set<Feature<?>> computeSubListFeatures(Set<Feature<?>> features) {
|
||||
Set<Feature<?>> derivedFeatures = new HashSet<>(features);
|
||||
#ignore
|
||||
derivedFeatures.add(CollectionFeature.SUBSET_VIEW);
|
||||
derivedFeatures.remove(SpecialFeature.COPYING);
|
||||
derivedFeatures.remove(SpecialFeature.CHILDREN_COPY);
|
||||
#endignore
|
||||
return derivedFeatures;
|
||||
}
|
||||
|
||||
#endif
|
||||
private static Set<Feature<?>> computeReserializedCollectionFeatures(Set<Feature<?>> features) {
|
||||
Set<Feature<?>> derivedFeatures = new HashSet<>(features);
|
||||
#ignore
|
||||
derivedFeatures.remove(SERIALIZABLE);
|
||||
derivedFeatures.remove(SERIALIZABLE_INCLUDING_VIEWS);
|
||||
#endignore
|
||||
return derivedFeatures;
|
||||
}
|
||||
}
|
||||
package speiger.src.testers.PACKAGE.builder;
|
||||
|
||||
#ignore
|
||||
import static com.google.common.collect.testing.features.CollectionFeature.KNOWN_ORDER;
|
||||
import static com.google.common.collect.testing.features.CollectionFeature.SERIALIZABLE;
|
||||
import static com.google.common.collect.testing.features.CollectionFeature.SERIALIZABLE_INCLUDING_VIEWS;
|
||||
#endignore
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.collect.testing.AbstractTester;
|
||||
import com.google.common.collect.testing.FeatureSpecificTestSuiteBuilder;
|
||||
import com.google.common.collect.testing.Helpers;
|
||||
import com.google.common.collect.testing.ListTestSuiteBuilder;
|
||||
import com.google.common.collect.testing.OneSizeTestContainerGenerator;
|
||||
import com.google.common.collect.testing.SampleElements;
|
||||
import com.google.common.collect.testing.TestListGenerator;
|
||||
import com.google.common.collect.testing.features.CollectionFeature;
|
||||
import com.google.common.collect.testing.features.Feature;
|
||||
import com.google.common.collect.testing.testers.CollectionSerializationEqualTester;
|
||||
import com.google.common.collect.testing.testers.ListAddAllAtIndexTester;
|
||||
import com.google.common.collect.testing.testers.ListAddAllTester;
|
||||
import com.google.common.collect.testing.testers.ListAddAtIndexTester;
|
||||
import com.google.common.collect.testing.testers.ListAddTester;
|
||||
import com.google.common.collect.testing.testers.ListCreationTester;
|
||||
import com.google.common.collect.testing.testers.ListEqualsTester;
|
||||
import com.google.common.collect.testing.testers.ListGetTester;
|
||||
import com.google.common.collect.testing.testers.ListHashCodeTester;
|
||||
import com.google.common.collect.testing.testers.ListIndexOfTester;
|
||||
import com.google.common.collect.testing.testers.ListLastIndexOfTester;
|
||||
import com.google.common.collect.testing.testers.ListRemoveAllTester;
|
||||
import com.google.common.collect.testing.testers.ListRemoveAtIndexTester;
|
||||
import com.google.common.collect.testing.testers.ListRemoveTester;
|
||||
import com.google.common.collect.testing.testers.ListReplaceAllTester;
|
||||
import com.google.common.collect.testing.testers.ListRetainAllTester;
|
||||
import com.google.common.collect.testing.testers.ListSetTester;
|
||||
import com.google.common.collect.testing.testers.ListSubListTester;
|
||||
import com.google.common.collect.testing.testers.ListToArrayTester;
|
||||
import com.google.common.testing.SerializableTester;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
import speiger.src.collections.PACKAGE.collections.ITERABLE;
|
||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||
import speiger.src.testers.base.tests.list.JavaListListIteratorTester;
|
||||
import speiger.src.testers.PACKAGE.generators.TEST_LIST_GENERATOR;
|
||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListAbsentTester;
|
||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListAddAllArrayAtIndexTester;
|
||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListAddAllAtIndexTester;
|
||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListAddAllListAtIndexTester;
|
||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListAddAllTester;
|
||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListAddAtIndexTester;
|
||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListAddTester;
|
||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListCreationTester;
|
||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListEqualsTester;
|
||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListExtractElementsTester;
|
||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListGetElementsTester;
|
||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListGetTester;
|
||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListIndexOfTester;
|
||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListLastIndexOfTester;
|
||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListListIteratorTester;
|
||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListPresentTester;
|
||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListRemoveAllTester;
|
||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListRemoveAtIndexTester;
|
||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListRemoveElementsTester;
|
||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListRemoveTester;
|
||||
#if !TYPE_BOOLEAN
|
||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListSortTester;
|
||||
#if !TYPE_OBJECT
|
||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListFillBufferTester;
|
||||
#endif
|
||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListReplaceAllTester;
|
||||
#endif
|
||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListRetainAllTester;
|
||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListSetTester;
|
||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListSubListTester;
|
||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListSwapRemoveAtIndexTester;
|
||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListSwapRemoveTester;
|
||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListToArrayTester;
|
||||
import speiger.src.testers.PACKAGE.utils.SAMPLE_ELEMENTS;
|
||||
#if !TYPE_BOOLEAN
|
||||
import speiger.src.testers.utils.SpecialFeature;
|
||||
#endif
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public class LIST_TEST_BUILDER KEY_GENERIC_TYPE extends COLLECTION_TEST_BUILDER KEY_GENERIC_TYPE {
|
||||
|
||||
#if TYPE_OBJECT
|
||||
KEY_TYPE[] prefixes;
|
||||
KEY_TYPE[] suffixes;
|
||||
#else
|
||||
KEY_TYPE[] prefixes = createPrefixes();
|
||||
KEY_TYPE[] suffixes = createSuffixes();
|
||||
#endif
|
||||
|
||||
public static GENERIC_KEY_BRACES LIST_TEST_BUILDER KEY_GENERIC_TYPE using(TEST_LIST_GENERATOR KEY_GENERIC_TYPE generator) {
|
||||
return (LIST_TEST_BUILDER KEY_GENERIC_TYPE) new LIST_TEST_BUILDER KEY_GENERIC_TYPE().usingGenerator(generator);
|
||||
}
|
||||
|
||||
public LIST_TEST_BUILDER KEY_GENERIC_TYPE setPrefixes(KEY_TYPE[] prefixes) {
|
||||
this.prefixes = prefixes;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LIST_TEST_BUILDER KEY_GENERIC_TYPE setSuffixes(KEY_TYPE[] suffixes) {
|
||||
this.suffixes = suffixes;
|
||||
return this;
|
||||
}
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
public KEY_TYPE[] createPrefixes() {
|
||||
#if TYPE_BOOLEAN
|
||||
return new KEY_TYPE[]{false, false, false};
|
||||
#else if TYPE_BYTE
|
||||
return new KEY_TYPE[]{(byte)-3, (byte)-2, (byte)-1};
|
||||
#else if TYPE_SHORT
|
||||
return new KEY_TYPE[]{(short)-3, (short)-2, (short)-1};
|
||||
#else if TYPE_CHAR
|
||||
return new KEY_TYPE[]{'^', '_', '`'};
|
||||
#else
|
||||
return new KEY_TYPE[]{-3, -2, -1};
|
||||
#endif
|
||||
}
|
||||
|
||||
public KEY_TYPE[] createSuffixes() {
|
||||
#if TYPE_BOOLEAN
|
||||
return new KEY_TYPE[]{true, true, true};
|
||||
#else if TYPE_BYTE
|
||||
return new KEY_TYPE[]{(byte)5, (byte)6, (byte)7};
|
||||
#else if TYPE_SHORT
|
||||
return new KEY_TYPE[]{(short)5, (short)6, (short)7};
|
||||
#else if TYPE_CHAR
|
||||
return new KEY_TYPE[]{'f', 'g', 'h'};
|
||||
#else
|
||||
return new KEY_TYPE[]{5, 6, 7};
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
@Override
|
||||
@SuppressWarnings("rawtypes")
|
||||
protected List<Class<? extends AbstractTester>> getTesters() {
|
||||
List<Class<? extends AbstractTester>> testers = Helpers.copyToList(super.getTesters());
|
||||
|
||||
testers.add(CollectionSerializationEqualTester.class);
|
||||
testers.add(ListAddAllAtIndexTester.class);
|
||||
testers.add(ListAddAllTester.class);
|
||||
testers.add(ListAddAtIndexTester.class);
|
||||
testers.add(ListAddTester.class);
|
||||
testers.add(ListCreationTester.class);
|
||||
testers.add(ListEqualsTester.class);
|
||||
testers.add(ListGetTester.class);
|
||||
testers.add(ListHashCodeTester.class);
|
||||
testers.add(ListIndexOfTester.class);
|
||||
testers.add(ListLastIndexOfTester.class);
|
||||
testers.add(JavaListListIteratorTester.class);
|
||||
testers.add(ListRemoveAllTester.class);
|
||||
testers.add(ListRemoveAtIndexTester.class);
|
||||
testers.add(ListRemoveTester.class);
|
||||
testers.add(ListReplaceAllTester.class);
|
||||
testers.add(ListRetainAllTester.class);
|
||||
testers.add(ListSetTester.class);
|
||||
testers.add(ListSubListTester.class);
|
||||
testers.add(ListToArrayTester.class);
|
||||
|
||||
testers.add(FILE_KEY_TYPEListAddAllAtIndexTester.class);
|
||||
testers.add(FILE_KEY_TYPEListAddAllListAtIndexTester.class);
|
||||
testers.add(FILE_KEY_TYPEListAddAllArrayAtIndexTester.class);
|
||||
testers.add(FILE_KEY_TYPEListAddAllTester.class);
|
||||
testers.add(FILE_KEY_TYPEListAddAtIndexTester.class);
|
||||
testers.add(FILE_KEY_TYPEListAddTester.class);
|
||||
testers.add(FILE_KEY_TYPEListAbsentTester.class);
|
||||
testers.add(FILE_KEY_TYPEListPresentTester.class);
|
||||
testers.add(FILE_KEY_TYPEListCreationTester.class);
|
||||
testers.add(FILE_KEY_TYPEListEqualsTester.class);
|
||||
testers.add(FILE_KEY_TYPEListGetTester.class);
|
||||
testers.add(FILE_KEY_TYPEListGetElementsTester.class);
|
||||
testers.add(FILE_KEY_TYPEListExtractElementsTester.class);
|
||||
testers.add(FILE_KEY_TYPEListIndexOfTester.class);
|
||||
testers.add(FILE_KEY_TYPEListLastIndexOfTester.class);
|
||||
testers.add(FILE_KEY_TYPEListListIteratorTester.class);
|
||||
testers.add(FILE_KEY_TYPEListRemoveAllTester.class);
|
||||
testers.add(FILE_KEY_TYPEListRemoveAtIndexTester.class);
|
||||
testers.add(FILE_KEY_TYPEListRemoveTester.class);
|
||||
testers.add(FILE_KEY_TYPEListRemoveElementsTester.class);
|
||||
testers.add(FILE_KEY_TYPEListSwapRemoveAtIndexTester.class);
|
||||
testers.add(FILE_KEY_TYPEListSwapRemoveTester.class);
|
||||
#if !TYPE_BOOLEAN
|
||||
testers.add(FILE_KEY_TYPEListSortTester.class);
|
||||
#if !TYPE_OBJECT
|
||||
testers.add(FILE_KEY_TYPEListFillBufferTester.class);
|
||||
#endif
|
||||
testers.add(FILE_KEY_TYPEListReplaceAllTester.class);
|
||||
#endif
|
||||
testers.add(FILE_KEY_TYPEListRetainAllTester.class);
|
||||
testers.add(FILE_KEY_TYPEListSetTester.class);
|
||||
testers.add(FILE_KEY_TYPEListSubListTester.class);
|
||||
testers.add(FILE_KEY_TYPEListToArrayTester.class);
|
||||
return testers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TestSuite createTestSuite() {
|
||||
#ignore
|
||||
withFeatures(KNOWN_ORDER);
|
||||
#endignore
|
||||
return super.createTestSuite();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<TestSuite> createDerivedSuites(FeatureSpecificTestSuiteBuilder<?, ? extends OneSizeTestContainerGenerator<Collection<CLASS_TYPE>, CLASS_TYPE>> parentBuilder) {
|
||||
List<TestSuite> derivedSuites = new ArrayList<>(super.createDerivedSuites(parentBuilder));
|
||||
#ignore
|
||||
if (parentBuilder.getFeatures().contains(SERIALIZABLE)) {
|
||||
#endignore
|
||||
derivedSuites.add(ListTestSuiteBuilder.using(new ReserializedListGenerator<CLASS_TYPE>(parentBuilder.getSubjectGenerator()))
|
||||
.named(getName() + " reserialized")
|
||||
.withFeatures(computeReserializedCollectionFeatures(parentBuilder.getFeatures()))
|
||||
.suppressing(parentBuilder.getSuppressedTests()).withSetUp(parentBuilder.getSetUp())
|
||||
.withTearDown(parentBuilder.getTearDown()).createTestSuite());
|
||||
}
|
||||
#ignore
|
||||
if(!parentBuilder.getFeatures().contains(CollectionFeature.SUBSET_VIEW)) {
|
||||
#endignore
|
||||
#if !TYPE_BOOLEAN
|
||||
if(prefixes != null) {
|
||||
derivedSuites.add(LIST_TEST_BUILDER.using(new SubListListGeneratorBRACES(parentBuilder.getSubjectGenerator(), prefixes, null))
|
||||
.named(getName() + " subSet_prefix")
|
||||
.withFeatures(computeSubListFeatures(parentBuilder.getFeatures()))
|
||||
.suppressing(parentBuilder.getSuppressedTests()).withSetUp(parentBuilder.getSetUp())
|
||||
.withTearDown(parentBuilder.getTearDown()).createTestSuite());
|
||||
}
|
||||
if(suffixes != null) {
|
||||
derivedSuites.add(LIST_TEST_BUILDER.using(new SubListListGeneratorBRACES(parentBuilder.getSubjectGenerator(), null, suffixes))
|
||||
.named(getName() + " subSet_suffixes")
|
||||
.withFeatures(computeSubListFeatures(parentBuilder.getFeatures()))
|
||||
.suppressing(parentBuilder.getSuppressedTests()).withSetUp(parentBuilder.getSetUp())
|
||||
.withTearDown(parentBuilder.getTearDown()).createTestSuite());
|
||||
}
|
||||
if(prefixes != null && suffixes != null) {
|
||||
derivedSuites.add(LIST_TEST_BUILDER.using(new SubListListGeneratorBRACES(parentBuilder.getSubjectGenerator(), prefixes, suffixes))
|
||||
.named(getName() + " subSet")
|
||||
.withFeatures(computeSubListFeatures(parentBuilder.getFeatures()))
|
||||
.suppressing(parentBuilder.getSuppressedTests()).withSetUp(parentBuilder.getSetUp())
|
||||
.withTearDown(parentBuilder.getTearDown()).createTestSuite());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return derivedSuites;
|
||||
}
|
||||
|
||||
static class SubListListGenerator KEY_GENERIC_TYPE implements TEST_LIST_GENERATOR KEY_GENERIC_TYPE {
|
||||
TEST_LIST_GENERATOR KEY_GENERIC_TYPE generator;
|
||||
KEY_TYPE[] prefix;
|
||||
KEY_TYPE[] suffix;
|
||||
|
||||
public SubListListGenerator(OneSizeTestContainerGenerator<Collection<CLASS_TYPE>, CLASS_TYPE> gen, KEY_TYPE[] prefix, KEY_TYPE[] suffix) {
|
||||
generator = (TEST_LIST_GENERATOR KEY_GENERIC_TYPE)gen.getInnerGenerator();
|
||||
this.prefix = prefix;
|
||||
this.suffix = suffix;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SampleElements<CLASS_TYPE> samples() {
|
||||
return generator.samples();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CLASS_TYPE[] createArray(int length) {
|
||||
return generator.createArray(length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<CLASS_TYPE> order(List<CLASS_TYPE> insertionOrder) {
|
||||
return generator.order(insertionOrder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SAMPLE_ELEMENTS KEY_GENERIC_TYPE getSamples() {
|
||||
return generator.getSamples();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITERABLE KEY_GENERIC_TYPE order(LIST KEY_GENERIC_TYPE insertionOrder) {
|
||||
return generator.order(insertionOrder);
|
||||
}
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
@Override
|
||||
public LIST KEY_GENERIC_TYPE create(Object... elements) {
|
||||
KEY_TYPE[] array = NEW_KEY_ARRAY(elements.length);
|
||||
int i = 0;
|
||||
for (Object e : elements) {
|
||||
array[i++] = CLASS_TO_KEY(e);
|
||||
}
|
||||
return create(array);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LIST KEY_GENERIC_TYPE create(KEY_TYPE... elements) {
|
||||
int length = getLength(prefix);
|
||||
return generator.create(merge(elements)).subList(length, length+elements.length);
|
||||
}
|
||||
|
||||
#else
|
||||
@Override
|
||||
public LIST KEY_GENERIC_TYPE create(Object... elements) {
|
||||
KEY_TYPE[] array = NEW_KEY_ARRAY(elements.length);
|
||||
int i = 0;
|
||||
for (Object e : elements) {
|
||||
array[i++] = CLASS_TO_KEY(e);
|
||||
}
|
||||
int length = getLength(prefix);
|
||||
return generator.create(merge(array)).subList(length, length+elements.length);
|
||||
}
|
||||
|
||||
#endif
|
||||
private int getLength(KEY_TYPE[] keys) {
|
||||
return keys == null ? 0 : keys.length;
|
||||
}
|
||||
|
||||
private KEY_TYPE[] merge(KEY_TYPE[] input) {
|
||||
int prefixLength = getLength(prefix);
|
||||
int suffixLength = getLength(suffix);
|
||||
KEY_TYPE[] result = NEW_KEY_ARRAY(input.length+prefixLength+suffixLength);
|
||||
if(prefixLength != 0) System.arraycopy(prefix, 0, result, 0, prefixLength);
|
||||
System.arraycopy(input, 0, result, prefixLength, input.length);
|
||||
if(suffixLength != 0) System.arraycopy(suffix, 0, result, prefixLength+input.length, suffixLength);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
static class ReserializedListGenerator<E> implements TestListGenerator<E> {
|
||||
final OneSizeTestContainerGenerator<Collection<E>, E> gen;
|
||||
|
||||
private ReserializedListGenerator(OneSizeTestContainerGenerator<Collection<E>, E> gen) {
|
||||
this.gen = gen;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SampleElements<E> samples() {
|
||||
return gen.samples();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<E> create(Object... elements) {
|
||||
return (List<E>) SerializableTester.reserialize(gen.create(elements));
|
||||
}
|
||||
|
||||
@Override
|
||||
public E[] createArray(int length) {
|
||||
return gen.createArray(length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<E> order(List<E> insertionOrder) {
|
||||
return gen.order(insertionOrder);
|
||||
}
|
||||
}
|
||||
|
||||
#if !TYPE_BOOLEAN
|
||||
private static Set<Feature<?>> computeSubListFeatures(Set<Feature<?>> features) {
|
||||
Set<Feature<?>> derivedFeatures = new HashSet<>(features);
|
||||
#ignore
|
||||
derivedFeatures.add(CollectionFeature.SUBSET_VIEW);
|
||||
derivedFeatures.remove(SpecialFeature.COPYING);
|
||||
derivedFeatures.remove(SpecialFeature.CHILDREN_COPY);
|
||||
#endignore
|
||||
return derivedFeatures;
|
||||
}
|
||||
|
||||
#endif
|
||||
private static Set<Feature<?>> computeReserializedCollectionFeatures(Set<Feature<?>> features) {
|
||||
Set<Feature<?>> derivedFeatures = new HashSet<>(features);
|
||||
#ignore
|
||||
derivedFeatures.remove(SERIALIZABLE);
|
||||
derivedFeatures.remove(SERIALIZABLE_INCLUDING_VIEWS);
|
||||
#endignore
|
||||
return derivedFeatures;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,140 +1,140 @@
|
|||
package speiger.src.testers.PACKAGE.builder;
|
||||
|
||||
#ignore
|
||||
import static com.google.common.collect.testing.features.CollectionFeature.DESCENDING_VIEW;
|
||||
import static com.google.common.collect.testing.features.CollectionFeature.SUBSET_VIEW;
|
||||
#endignore
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.testing.AbstractTester;
|
||||
import com.google.common.collect.testing.DerivedCollectionGenerators.Bound;
|
||||
import com.google.common.collect.testing.FeatureSpecificTestSuiteBuilder;
|
||||
import com.google.common.collect.testing.Helpers;
|
||||
import com.google.common.collect.testing.OneSizeTestContainerGenerator;
|
||||
import com.google.common.collect.testing.SampleElements;
|
||||
import com.google.common.collect.testing.features.Feature;
|
||||
import com.google.common.collect.testing.testers.NavigableSetNavigationTester;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
import speiger.src.collections.PACKAGE.collections.ITERABLE;
|
||||
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||
import speiger.src.collections.PACKAGE.sets.NAVIGABLE_SET;
|
||||
import speiger.src.collections.PACKAGE.utils.LISTS;
|
||||
import speiger.src.testers.PACKAGE.generators.TEST_NAVIGABLE_SET_GENERATOR;
|
||||
import speiger.src.testers.PACKAGE.generators.TEST_SORTED_SET_GENERATOR;
|
||||
import speiger.src.testers.PACKAGE.impl.SUB_SORTED_SET_CLASS_GENERATOR.SUB_NAVIGABLE_SET_CLASS_GENERATOR;
|
||||
import speiger.src.testers.PACKAGE.tests.set.FILE_KEY_TYPENavigableSetNavigationTester;
|
||||
import speiger.src.testers.PACKAGE.utils.SAMPLE_ELEMENTS;
|
||||
import speiger.src.testers.utils.SpecialFeature;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public class NAVIGABLE_SET_TEST_BUILDER KEY_GENERIC_TYPE extends SORTED_SET_TEST_BUILDER KEY_GENERIC_TYPE {
|
||||
public static GENERIC_KEY_BRACES NAVIGABLE_SET_TEST_BUILDER KEY_GENERIC_TYPE using(TEST_NAVIGABLE_SET_GENERATOR KEY_GENERIC_TYPE generator) {
|
||||
return (NAVIGABLE_SET_TEST_BUILDER KEY_GENERIC_TYPE) new NAVIGABLE_SET_TEST_BUILDER KEY_GENERIC_TYPE().usingGenerator(generator);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("rawtypes")
|
||||
protected List<Class<? extends AbstractTester>> getTesters() {
|
||||
List<Class<? extends AbstractTester>> testers = Helpers.copyToList(super.getTesters());
|
||||
testers.add(NavigableSetNavigationTester.class);
|
||||
testers.add(FILE_KEY_TYPENavigableSetNavigationTester.class);
|
||||
return testers;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<TestSuite> createDerivedSuites(FeatureSpecificTestSuiteBuilder<?, ? extends OneSizeTestContainerGenerator<Collection<CLASS_TYPE>, CLASS_TYPE>> parentBuilder) {
|
||||
List<TestSuite> derivedSuites = new ArrayList<>(super.createDerivedSuites(parentBuilder));
|
||||
|
||||
#ignore
|
||||
if (!parentBuilder.getFeatures().contains(SUBSET_VIEW)) {
|
||||
#endignore
|
||||
// Other combinations are inherited from SortedSetTestSuiteBuilder.
|
||||
derivedSuites.add(createSubsetSuite(parentBuilder, Bound.NO_BOUND, Bound.INCLUSIVE));
|
||||
derivedSuites.add(createSubsetSuite(parentBuilder, Bound.EXCLUSIVE, Bound.NO_BOUND));
|
||||
derivedSuites.add(createSubsetSuite(parentBuilder, Bound.EXCLUSIVE, Bound.EXCLUSIVE));
|
||||
derivedSuites.add(createSubsetSuite(parentBuilder, Bound.EXCLUSIVE, Bound.INCLUSIVE));
|
||||
derivedSuites.add(createSubsetSuite(parentBuilder, Bound.INCLUSIVE, Bound.INCLUSIVE));
|
||||
}
|
||||
#ignore
|
||||
if (!parentBuilder.getFeatures().contains(DESCENDING_VIEW)) {
|
||||
#endignore
|
||||
derivedSuites.add(createDescendingSuite(parentBuilder));
|
||||
}
|
||||
return derivedSuites;
|
||||
}
|
||||
|
||||
@Override
|
||||
SORTED_SET_TEST_BUILDER KEY_GENERIC_TYPE newBuilderUsing(TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE delegate, Bound to, Bound from) {
|
||||
return NAVIGABLE_SET_TEST_BUILDER.using(new SUB_NAVIGABLE_SET_CLASS_GENERATORBRACES(delegate, to, from));
|
||||
}
|
||||
|
||||
private TestSuite createDescendingSuite(FeatureSpecificTestSuiteBuilder<?, ? extends OneSizeTestContainerGenerator<Collection<CLASS_TYPE>, CLASS_TYPE>> parentBuilder) {
|
||||
TEST_NAVIGABLE_SET_GENERATOR KEY_GENERIC_TYPE delegate = (TEST_NAVIGABLE_SET_GENERATOR KEY_GENERIC_TYPE) parentBuilder.getSubjectGenerator().getInnerGenerator();
|
||||
|
||||
List<Feature<?>> features = new ArrayList<>();
|
||||
#ignore
|
||||
features.add(DESCENDING_VIEW);
|
||||
features.addAll(parentBuilder.getFeatures());
|
||||
features.remove(SpecialFeature.COPYING);
|
||||
features.remove(SpecialFeature.CHILDREN_COPY);
|
||||
#endignore
|
||||
|
||||
return NAVIGABLE_SET_TEST_BUILDER.using(new TEST_NAVIGABLE_SET_GENERATOR KEY_GENERIC_TYPE() {
|
||||
|
||||
@Override
|
||||
public SampleElements<CLASS_TYPE> samples() {
|
||||
return delegate.samples();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SAMPLE_ELEMENTS KEY_GENERIC_TYPE getSamples() {
|
||||
return delegate.getSamples();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITERABLE KEY_GENERIC_TYPE order(LIST KEY_GENERIC_TYPE insertionOrder) {
|
||||
LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES();
|
||||
delegate.order(insertionOrder).forEach(list::add);
|
||||
LISTS.reverse(list);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<CLASS_TYPE> order(List<CLASS_TYPE> insertionOrder) {
|
||||
LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES();
|
||||
for(CLASS_TYPE entry : delegate.order(insertionOrder))
|
||||
{
|
||||
list.add(OBJ_TO_KEY(entry));
|
||||
}
|
||||
LISTS.reverse(list);
|
||||
return list;
|
||||
}
|
||||
@Override
|
||||
public KEY_TYPE belowSamplesLesser() { return delegate.aboveSamplesGreater(); }
|
||||
@Override
|
||||
public KEY_TYPE belowSamplesGreater() { return delegate.aboveSamplesLesser(); }
|
||||
@Override
|
||||
public KEY_TYPE aboveSamplesLesser() { return delegate.belowSamplesGreater(); }
|
||||
@Override
|
||||
public KEY_TYPE aboveSamplesGreater() { return delegate.belowSamplesLesser(); }
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
@Override
|
||||
public NAVIGABLE_SET KEY_GENERIC_TYPE create(KEY_TYPE... elements) {
|
||||
return delegate.create(elements).descendingSet();
|
||||
}
|
||||
|
||||
#endif
|
||||
@Override
|
||||
public NAVIGABLE_SET KEY_GENERIC_TYPE create(Object... elements) {
|
||||
return delegate.create(elements).descendingSet();
|
||||
}
|
||||
}).named(parentBuilder.getName() + " descending").withFeatures(features)
|
||||
.suppressing(parentBuilder.getSuppressedTests()).createTestSuite();
|
||||
}
|
||||
}
|
||||
package speiger.src.testers.PACKAGE.builder;
|
||||
|
||||
#ignore
|
||||
import static com.google.common.collect.testing.features.CollectionFeature.DESCENDING_VIEW;
|
||||
import static com.google.common.collect.testing.features.CollectionFeature.SUBSET_VIEW;
|
||||
#endignore
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.testing.AbstractTester;
|
||||
import com.google.common.collect.testing.DerivedCollectionGenerators.Bound;
|
||||
import com.google.common.collect.testing.FeatureSpecificTestSuiteBuilder;
|
||||
import com.google.common.collect.testing.Helpers;
|
||||
import com.google.common.collect.testing.OneSizeTestContainerGenerator;
|
||||
import com.google.common.collect.testing.SampleElements;
|
||||
import com.google.common.collect.testing.features.Feature;
|
||||
import com.google.common.collect.testing.testers.NavigableSetNavigationTester;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
import speiger.src.collections.PACKAGE.collections.ITERABLE;
|
||||
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||
import speiger.src.collections.PACKAGE.sets.NAVIGABLE_SET;
|
||||
import speiger.src.collections.PACKAGE.utils.LISTS;
|
||||
import speiger.src.testers.PACKAGE.generators.TEST_NAVIGABLE_SET_GENERATOR;
|
||||
import speiger.src.testers.PACKAGE.generators.TEST_SORTED_SET_GENERATOR;
|
||||
import speiger.src.testers.PACKAGE.impl.SUB_SORTED_SET_CLASS_GENERATOR.SUB_NAVIGABLE_SET_CLASS_GENERATOR;
|
||||
import speiger.src.testers.PACKAGE.tests.set.FILE_KEY_TYPENavigableSetNavigationTester;
|
||||
import speiger.src.testers.PACKAGE.utils.SAMPLE_ELEMENTS;
|
||||
import speiger.src.testers.utils.SpecialFeature;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public class NAVIGABLE_SET_TEST_BUILDER KEY_GENERIC_TYPE extends SORTED_SET_TEST_BUILDER KEY_GENERIC_TYPE {
|
||||
public static GENERIC_KEY_BRACES NAVIGABLE_SET_TEST_BUILDER KEY_GENERIC_TYPE using(TEST_NAVIGABLE_SET_GENERATOR KEY_GENERIC_TYPE generator) {
|
||||
return (NAVIGABLE_SET_TEST_BUILDER KEY_GENERIC_TYPE) new NAVIGABLE_SET_TEST_BUILDER KEY_GENERIC_TYPE().usingGenerator(generator);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("rawtypes")
|
||||
protected List<Class<? extends AbstractTester>> getTesters() {
|
||||
List<Class<? extends AbstractTester>> testers = Helpers.copyToList(super.getTesters());
|
||||
testers.add(NavigableSetNavigationTester.class);
|
||||
testers.add(FILE_KEY_TYPENavigableSetNavigationTester.class);
|
||||
return testers;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<TestSuite> createDerivedSuites(FeatureSpecificTestSuiteBuilder<?, ? extends OneSizeTestContainerGenerator<Collection<CLASS_TYPE>, CLASS_TYPE>> parentBuilder) {
|
||||
List<TestSuite> derivedSuites = new ArrayList<>(super.createDerivedSuites(parentBuilder));
|
||||
|
||||
#ignore
|
||||
if (!parentBuilder.getFeatures().contains(SUBSET_VIEW)) {
|
||||
#endignore
|
||||
// Other combinations are inherited from SortedSetTestSuiteBuilder.
|
||||
derivedSuites.add(createSubsetSuite(parentBuilder, Bound.NO_BOUND, Bound.INCLUSIVE));
|
||||
derivedSuites.add(createSubsetSuite(parentBuilder, Bound.EXCLUSIVE, Bound.NO_BOUND));
|
||||
derivedSuites.add(createSubsetSuite(parentBuilder, Bound.EXCLUSIVE, Bound.EXCLUSIVE));
|
||||
derivedSuites.add(createSubsetSuite(parentBuilder, Bound.EXCLUSIVE, Bound.INCLUSIVE));
|
||||
derivedSuites.add(createSubsetSuite(parentBuilder, Bound.INCLUSIVE, Bound.INCLUSIVE));
|
||||
}
|
||||
#ignore
|
||||
if (!parentBuilder.getFeatures().contains(DESCENDING_VIEW)) {
|
||||
#endignore
|
||||
derivedSuites.add(createDescendingSuite(parentBuilder));
|
||||
}
|
||||
return derivedSuites;
|
||||
}
|
||||
|
||||
@Override
|
||||
SORTED_SET_TEST_BUILDER KEY_GENERIC_TYPE newBuilderUsing(TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE delegate, Bound to, Bound from) {
|
||||
return NAVIGABLE_SET_TEST_BUILDER.using(new SUB_NAVIGABLE_SET_CLASS_GENERATORBRACES(delegate, to, from));
|
||||
}
|
||||
|
||||
private TestSuite createDescendingSuite(FeatureSpecificTestSuiteBuilder<?, ? extends OneSizeTestContainerGenerator<Collection<CLASS_TYPE>, CLASS_TYPE>> parentBuilder) {
|
||||
TEST_NAVIGABLE_SET_GENERATOR KEY_GENERIC_TYPE delegate = (TEST_NAVIGABLE_SET_GENERATOR KEY_GENERIC_TYPE) parentBuilder.getSubjectGenerator().getInnerGenerator();
|
||||
|
||||
List<Feature<?>> features = new ArrayList<>();
|
||||
#ignore
|
||||
features.add(DESCENDING_VIEW);
|
||||
features.addAll(parentBuilder.getFeatures());
|
||||
features.remove(SpecialFeature.COPYING);
|
||||
features.remove(SpecialFeature.CHILDREN_COPY);
|
||||
#endignore
|
||||
|
||||
return NAVIGABLE_SET_TEST_BUILDER.using(new TEST_NAVIGABLE_SET_GENERATOR KEY_GENERIC_TYPE() {
|
||||
|
||||
@Override
|
||||
public SampleElements<CLASS_TYPE> samples() {
|
||||
return delegate.samples();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SAMPLE_ELEMENTS KEY_GENERIC_TYPE getSamples() {
|
||||
return delegate.getSamples();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITERABLE KEY_GENERIC_TYPE order(LIST KEY_GENERIC_TYPE insertionOrder) {
|
||||
LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES();
|
||||
delegate.order(insertionOrder).forEach(list::add);
|
||||
LISTS.reverse(list);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<CLASS_TYPE> order(List<CLASS_TYPE> insertionOrder) {
|
||||
LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES();
|
||||
for(CLASS_TYPE entry : delegate.order(insertionOrder))
|
||||
{
|
||||
list.add(OBJ_TO_KEY(entry));
|
||||
}
|
||||
LISTS.reverse(list);
|
||||
return list;
|
||||
}
|
||||
@Override
|
||||
public KEY_TYPE belowSamplesLesser() { return delegate.aboveSamplesGreater(); }
|
||||
@Override
|
||||
public KEY_TYPE belowSamplesGreater() { return delegate.aboveSamplesLesser(); }
|
||||
@Override
|
||||
public KEY_TYPE aboveSamplesLesser() { return delegate.belowSamplesGreater(); }
|
||||
@Override
|
||||
public KEY_TYPE aboveSamplesGreater() { return delegate.belowSamplesLesser(); }
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
@Override
|
||||
public NAVIGABLE_SET KEY_GENERIC_TYPE create(KEY_TYPE... elements) {
|
||||
return delegate.create(elements).descendingSet();
|
||||
}
|
||||
|
||||
#endif
|
||||
@Override
|
||||
public NAVIGABLE_SET KEY_GENERIC_TYPE create(Object... elements) {
|
||||
return delegate.create(elements).descendingSet();
|
||||
}
|
||||
}).named(parentBuilder.getName() + " descending").withFeatures(features)
|
||||
.suppressing(parentBuilder.getSuppressedTests()).createTestSuite();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,38 +1,38 @@
|
|||
package speiger.src.testers.PACKAGE.builder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.testing.AbstractTester;
|
||||
import com.google.common.collect.testing.Helpers;
|
||||
import com.google.common.collect.testing.features.CollectionFeature;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
import speiger.src.testers.PACKAGE.generators.TEST_ORDERED_SET_GENERATOR;
|
||||
import speiger.src.testers.PACKAGE.tests.set.FILE_KEY_TYPEOrderedSetMoveTester;
|
||||
import speiger.src.testers.PACKAGE.tests.set.FILE_KEY_TYPEOrderedSetIterationTester;
|
||||
import speiger.src.testers.PACKAGE.tests.set.FILE_KEY_TYPEOrderedSetNavigationTester;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public class ORDERED_SET_TEST_BUILDER KEY_GENERIC_TYPE extends SET_TEST_BUILDER KEY_GENERIC_TYPE {
|
||||
public static GENERIC_KEY_BRACES ORDERED_SET_TEST_BUILDER KEY_GENERIC_TYPE using(TEST_ORDERED_SET_GENERATOR KEY_GENERIC_TYPE generator) {
|
||||
return (ORDERED_SET_TEST_BUILDER KEY_GENERIC_TYPE) new ORDERED_SET_TEST_BUILDER KEY_GENERIC_TYPE().usingGenerator(generator);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("rawtypes")
|
||||
protected List<Class<? extends AbstractTester>> getTesters() {
|
||||
List<Class<? extends AbstractTester>> testers = Helpers.copyToList(super.getTesters());
|
||||
testers.add(FILE_KEY_TYPEOrderedSetNavigationTester.class);
|
||||
testers.add(FILE_KEY_TYPEOrderedSetMoveTester.class);
|
||||
testers.add(FILE_KEY_TYPEOrderedSetIterationTester.class);
|
||||
return testers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TestSuite createTestSuite() {
|
||||
#ignore
|
||||
withFeatures(CollectionFeature.KNOWN_ORDER);
|
||||
#endignore
|
||||
return super.createTestSuite();
|
||||
}
|
||||
}
|
||||
package speiger.src.testers.PACKAGE.builder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.testing.AbstractTester;
|
||||
import com.google.common.collect.testing.Helpers;
|
||||
import com.google.common.collect.testing.features.CollectionFeature;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
import speiger.src.testers.PACKAGE.generators.TEST_ORDERED_SET_GENERATOR;
|
||||
import speiger.src.testers.PACKAGE.tests.set.FILE_KEY_TYPEOrderedSetMoveTester;
|
||||
import speiger.src.testers.PACKAGE.tests.set.FILE_KEY_TYPEOrderedSetIterationTester;
|
||||
import speiger.src.testers.PACKAGE.tests.set.FILE_KEY_TYPEOrderedSetNavigationTester;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public class ORDERED_SET_TEST_BUILDER KEY_GENERIC_TYPE extends SET_TEST_BUILDER KEY_GENERIC_TYPE {
|
||||
public static GENERIC_KEY_BRACES ORDERED_SET_TEST_BUILDER KEY_GENERIC_TYPE using(TEST_ORDERED_SET_GENERATOR KEY_GENERIC_TYPE generator) {
|
||||
return (ORDERED_SET_TEST_BUILDER KEY_GENERIC_TYPE) new ORDERED_SET_TEST_BUILDER KEY_GENERIC_TYPE().usingGenerator(generator);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("rawtypes")
|
||||
protected List<Class<? extends AbstractTester>> getTesters() {
|
||||
List<Class<? extends AbstractTester>> testers = Helpers.copyToList(super.getTesters());
|
||||
testers.add(FILE_KEY_TYPEOrderedSetNavigationTester.class);
|
||||
testers.add(FILE_KEY_TYPEOrderedSetMoveTester.class);
|
||||
testers.add(FILE_KEY_TYPEOrderedSetIterationTester.class);
|
||||
return testers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TestSuite createTestSuite() {
|
||||
#ignore
|
||||
withFeatures(CollectionFeature.KNOWN_ORDER);
|
||||
#endignore
|
||||
return super.createTestSuite();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,60 +1,60 @@
|
|||
package speiger.src.testers.PACKAGE.builder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.testing.AbstractTester;
|
||||
import com.google.common.collect.testing.PerCollectionSizeTestSuiteBuilder;
|
||||
|
||||
import speiger.src.collections.PACKAGE.queues.PRIORITY_QUEUE;
|
||||
import speiger.src.testers.PACKAGE.generators.TEST_QUEUE_GENERATOR;
|
||||
import speiger.src.testers.PACKAGE.tests.queue.FILE_KEY_TYPEQueueDequeueTester;
|
||||
import speiger.src.testers.PACKAGE.tests.queue.FILE_KEY_TYPEQueueEnqueueTester;
|
||||
import speiger.src.testers.PACKAGE.tests.queue.FILE_KEY_TYPEQueueFirstTester;
|
||||
import speiger.src.testers.PACKAGE.tests.queue.FILE_KEY_TYPEQueueRemoveTester;
|
||||
import speiger.src.testers.PACKAGE.tests.queue.iterators.FILE_KEY_TYPEQueueCountTester;
|
||||
import speiger.src.testers.PACKAGE.tests.queue.iterators.FILE_KEY_TYPEQueueDistinctTester;
|
||||
import speiger.src.testers.PACKAGE.tests.queue.iterators.FILE_KEY_TYPEQueueFilterTester;
|
||||
import speiger.src.testers.PACKAGE.tests.queue.iterators.FILE_KEY_TYPEQueueFindFirstTester;
|
||||
import speiger.src.testers.PACKAGE.tests.queue.iterators.FILE_KEY_TYPEQueueLimitTester;
|
||||
import speiger.src.testers.PACKAGE.tests.queue.iterators.FILE_KEY_TYPEQueueMapTester;
|
||||
import speiger.src.testers.PACKAGE.tests.queue.iterators.FILE_KEY_TYPEQueueMatchesTester;
|
||||
import speiger.src.testers.PACKAGE.tests.queue.iterators.FILE_KEY_TYPEQueuePeekTester;
|
||||
import speiger.src.testers.PACKAGE.tests.queue.iterators.FILE_KEY_TYPEQueueForEachTester;
|
||||
import speiger.src.testers.PACKAGE.tests.queue.iterators.FILE_KEY_TYPEQueueReduceTester;
|
||||
import speiger.src.testers.PACKAGE.tests.queue.iterators.FILE_KEY_TYPEQueueSortedTester;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public class QUEUE_TEST_BUILDER KEY_GENERIC_TYPE extends PerCollectionSizeTestSuiteBuilder<QUEUE_TEST_BUILDER KEY_GENERIC_TYPE, TEST_QUEUE_GENERATOR KEY_GENERIC_TYPE, PRIORITY_QUEUE KEY_GENERIC_TYPE, CLASS_TYPE>
|
||||
{
|
||||
public static GENERIC_KEY_BRACES QUEUE_TEST_BUILDER KEY_GENERIC_TYPE using(TEST_QUEUE_GENERATOR KEY_GENERIC_TYPE builder) {
|
||||
return new QUEUE_TEST_BUILDER KEY_GENERIC_TYPE().usingGenerator(builder);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("rawtypes")
|
||||
protected List<Class<? extends AbstractTester>> getTesters()
|
||||
{
|
||||
List<Class<? extends AbstractTester>> testers = new ArrayList<>();
|
||||
testers.add(FILE_KEY_TYPEQueueEnqueueTester.class);
|
||||
testers.add(FILE_KEY_TYPEQueueDequeueTester.class);
|
||||
testers.add(FILE_KEY_TYPEQueueFirstTester.class);
|
||||
testers.add(FILE_KEY_TYPEQueueRemoveTester.class);
|
||||
testers.add(FILE_KEY_TYPEQueueCountTester.class);
|
||||
testers.add(FILE_KEY_TYPEQueueCountTester.class);
|
||||
testers.add(FILE_KEY_TYPEQueueDequeueTester.class);
|
||||
testers.add(FILE_KEY_TYPEQueueDistinctTester.class);
|
||||
testers.add(FILE_KEY_TYPEQueueFilterTester.class);
|
||||
testers.add(FILE_KEY_TYPEQueueFindFirstTester.class);
|
||||
testers.add(FILE_KEY_TYPEQueueFirstTester.class);
|
||||
testers.add(FILE_KEY_TYPEQueueLimitTester.class);
|
||||
testers.add(FILE_KEY_TYPEQueueMapTester.class);
|
||||
testers.add(FILE_KEY_TYPEQueueMatchesTester.class);
|
||||
testers.add(FILE_KEY_TYPEQueuePeekTester.class);
|
||||
testers.add(FILE_KEY_TYPEQueueForEachTester.class);
|
||||
testers.add(FILE_KEY_TYPEQueueReduceTester.class);
|
||||
testers.add(FILE_KEY_TYPEQueueSortedTester.class);
|
||||
return testers;
|
||||
}
|
||||
|
||||
}
|
||||
package speiger.src.testers.PACKAGE.builder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.testing.AbstractTester;
|
||||
import com.google.common.collect.testing.PerCollectionSizeTestSuiteBuilder;
|
||||
|
||||
import speiger.src.collections.PACKAGE.queues.PRIORITY_QUEUE;
|
||||
import speiger.src.testers.PACKAGE.generators.TEST_QUEUE_GENERATOR;
|
||||
import speiger.src.testers.PACKAGE.tests.queue.FILE_KEY_TYPEQueueDequeueTester;
|
||||
import speiger.src.testers.PACKAGE.tests.queue.FILE_KEY_TYPEQueueEnqueueTester;
|
||||
import speiger.src.testers.PACKAGE.tests.queue.FILE_KEY_TYPEQueueFirstTester;
|
||||
import speiger.src.testers.PACKAGE.tests.queue.FILE_KEY_TYPEQueueRemoveTester;
|
||||
import speiger.src.testers.PACKAGE.tests.queue.iterators.FILE_KEY_TYPEQueueCountTester;
|
||||
import speiger.src.testers.PACKAGE.tests.queue.iterators.FILE_KEY_TYPEQueueDistinctTester;
|
||||
import speiger.src.testers.PACKAGE.tests.queue.iterators.FILE_KEY_TYPEQueueFilterTester;
|
||||
import speiger.src.testers.PACKAGE.tests.queue.iterators.FILE_KEY_TYPEQueueFindFirstTester;
|
||||
import speiger.src.testers.PACKAGE.tests.queue.iterators.FILE_KEY_TYPEQueueLimitTester;
|
||||
import speiger.src.testers.PACKAGE.tests.queue.iterators.FILE_KEY_TYPEQueueMapTester;
|
||||
import speiger.src.testers.PACKAGE.tests.queue.iterators.FILE_KEY_TYPEQueueMatchesTester;
|
||||
import speiger.src.testers.PACKAGE.tests.queue.iterators.FILE_KEY_TYPEQueuePeekTester;
|
||||
import speiger.src.testers.PACKAGE.tests.queue.iterators.FILE_KEY_TYPEQueueForEachTester;
|
||||
import speiger.src.testers.PACKAGE.tests.queue.iterators.FILE_KEY_TYPEQueueReduceTester;
|
||||
import speiger.src.testers.PACKAGE.tests.queue.iterators.FILE_KEY_TYPEQueueSortedTester;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public class QUEUE_TEST_BUILDER KEY_GENERIC_TYPE extends PerCollectionSizeTestSuiteBuilder<QUEUE_TEST_BUILDER KEY_GENERIC_TYPE, TEST_QUEUE_GENERATOR KEY_GENERIC_TYPE, PRIORITY_QUEUE KEY_GENERIC_TYPE, CLASS_TYPE>
|
||||
{
|
||||
public static GENERIC_KEY_BRACES QUEUE_TEST_BUILDER KEY_GENERIC_TYPE using(TEST_QUEUE_GENERATOR KEY_GENERIC_TYPE builder) {
|
||||
return new QUEUE_TEST_BUILDER KEY_GENERIC_TYPE().usingGenerator(builder);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("rawtypes")
|
||||
protected List<Class<? extends AbstractTester>> getTesters()
|
||||
{
|
||||
List<Class<? extends AbstractTester>> testers = new ArrayList<>();
|
||||
testers.add(FILE_KEY_TYPEQueueEnqueueTester.class);
|
||||
testers.add(FILE_KEY_TYPEQueueDequeueTester.class);
|
||||
testers.add(FILE_KEY_TYPEQueueFirstTester.class);
|
||||
testers.add(FILE_KEY_TYPEQueueRemoveTester.class);
|
||||
testers.add(FILE_KEY_TYPEQueueCountTester.class);
|
||||
testers.add(FILE_KEY_TYPEQueueCountTester.class);
|
||||
testers.add(FILE_KEY_TYPEQueueDequeueTester.class);
|
||||
testers.add(FILE_KEY_TYPEQueueDistinctTester.class);
|
||||
testers.add(FILE_KEY_TYPEQueueFilterTester.class);
|
||||
testers.add(FILE_KEY_TYPEQueueFindFirstTester.class);
|
||||
testers.add(FILE_KEY_TYPEQueueFirstTester.class);
|
||||
testers.add(FILE_KEY_TYPEQueueLimitTester.class);
|
||||
testers.add(FILE_KEY_TYPEQueueMapTester.class);
|
||||
testers.add(FILE_KEY_TYPEQueueMatchesTester.class);
|
||||
testers.add(FILE_KEY_TYPEQueuePeekTester.class);
|
||||
testers.add(FILE_KEY_TYPEQueueForEachTester.class);
|
||||
testers.add(FILE_KEY_TYPEQueueReduceTester.class);
|
||||
testers.add(FILE_KEY_TYPEQueueSortedTester.class);
|
||||
return testers;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,116 +1,116 @@
|
|||
package speiger.src.testers.PACKAGE.builder;
|
||||
|
||||
#ignore
|
||||
import static com.google.common.collect.testing.features.CollectionFeature.SERIALIZABLE;
|
||||
import static com.google.common.collect.testing.features.CollectionFeature.SERIALIZABLE_INCLUDING_VIEWS;
|
||||
#endignore
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.collect.testing.AbstractTester;
|
||||
import com.google.common.collect.testing.FeatureSpecificTestSuiteBuilder;
|
||||
import com.google.common.collect.testing.Helpers;
|
||||
import com.google.common.collect.testing.OneSizeTestContainerGenerator;
|
||||
import com.google.common.collect.testing.SampleElements;
|
||||
import com.google.common.collect.testing.SetTestSuiteBuilder;
|
||||
import com.google.common.collect.testing.TestSetGenerator;
|
||||
import com.google.common.collect.testing.features.Feature;
|
||||
import com.google.common.collect.testing.testers.CollectionSerializationEqualTester;
|
||||
import com.google.common.collect.testing.testers.SetAddAllTester;
|
||||
import com.google.common.collect.testing.testers.SetAddTester;
|
||||
import com.google.common.collect.testing.testers.SetCreationTester;
|
||||
import com.google.common.collect.testing.testers.SetEqualsTester;
|
||||
import com.google.common.collect.testing.testers.SetHashCodeTester;
|
||||
import com.google.common.collect.testing.testers.SetRemoveTester;
|
||||
import com.google.common.testing.SerializableTester;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
import speiger.src.testers.PACKAGE.generators.TEST_SET_GENERATOR;
|
||||
import speiger.src.testers.PACKAGE.tests.set.FILE_KEY_TYPESetAddAllTester;
|
||||
import speiger.src.testers.PACKAGE.tests.set.FILE_KEY_TYPESetAddTester;
|
||||
import speiger.src.testers.PACKAGE.tests.set.FILE_KEY_TYPESetCreationTester;
|
||||
import speiger.src.testers.PACKAGE.tests.set.FILE_KEY_TYPESetEqualsTester;
|
||||
import speiger.src.testers.PACKAGE.tests.set.FILE_KEY_TYPESetRemoveTester;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public class SET_TEST_BUILDER KEY_GENERIC_TYPE extends COLLECTION_TEST_BUILDER KEY_GENERIC_TYPE {
|
||||
public static GENERIC_KEY_BRACES SET_TEST_BUILDER KEY_GENERIC_TYPE using(TEST_SET_GENERATOR KEY_GENERIC_TYPE generator) {
|
||||
return (SET_TEST_BUILDER KEY_GENERIC_TYPE) new SET_TEST_BUILDER KEY_GENERIC_TYPE().usingGenerator(generator);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("rawtypes")
|
||||
protected List<Class<? extends AbstractTester>> getTesters() {
|
||||
List<Class<? extends AbstractTester>> testers = Helpers.copyToList(super.getTesters());
|
||||
testers.add(CollectionSerializationEqualTester.class);
|
||||
testers.add(SetAddAllTester.class);
|
||||
testers.add(SetAddTester.class);
|
||||
testers.add(SetCreationTester.class);
|
||||
testers.add(SetHashCodeTester.class);
|
||||
testers.add(SetEqualsTester.class);
|
||||
testers.add(SetRemoveTester.class);
|
||||
|
||||
testers.add(FILE_KEY_TYPESetAddAllTester.class);
|
||||
testers.add(FILE_KEY_TYPESetAddTester.class);
|
||||
testers.add(FILE_KEY_TYPESetCreationTester.class);
|
||||
testers.add(FILE_KEY_TYPESetEqualsTester.class);
|
||||
testers.add(FILE_KEY_TYPESetRemoveTester.class);
|
||||
return testers;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<TestSuite> createDerivedSuites(
|
||||
FeatureSpecificTestSuiteBuilder<?, ? extends OneSizeTestContainerGenerator<Collection<CLASS_TYPE>, CLASS_TYPE>> parentBuilder) {
|
||||
List<TestSuite> derivedSuites = new ArrayList<>(super.createDerivedSuites(parentBuilder));
|
||||
|
||||
if (parentBuilder.getFeatures().contains(SERIALIZABLE)) {
|
||||
derivedSuites.add(SetTestSuiteBuilder.using(new ReserializedSetGenerator<CLASS_TYPE>(parentBuilder.getSubjectGenerator()))
|
||||
.named(getName() + " reserialized")
|
||||
.withFeatures(computeReserializedCollectionFeatures(parentBuilder.getFeatures()))
|
||||
.suppressing(parentBuilder.getSuppressedTests()).withSetUp(parentBuilder.getSetUp())
|
||||
.withTearDown(parentBuilder.getTearDown()).createTestSuite());
|
||||
}
|
||||
return derivedSuites;
|
||||
}
|
||||
|
||||
static class ReserializedSetGenerator<E> implements TestSetGenerator<E> {
|
||||
final OneSizeTestContainerGenerator<Collection<E>, E> gen;
|
||||
|
||||
private ReserializedSetGenerator(OneSizeTestContainerGenerator<Collection<E>, E> gen) {
|
||||
this.gen = gen;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SampleElements<E> samples() {
|
||||
return gen.samples();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<E> create(Object... elements) {
|
||||
return (Set<E>) SerializableTester.reserialize(gen.create(elements));
|
||||
}
|
||||
|
||||
@Override
|
||||
public E[] createArray(int length) {
|
||||
return gen.createArray(length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<E> order(List<E> insertionOrder) {
|
||||
return gen.order(insertionOrder);
|
||||
}
|
||||
}
|
||||
|
||||
private static Set<Feature<?>> computeReserializedCollectionFeatures(Set<Feature<?>> features) {
|
||||
Set<Feature<?>> derivedFeatures = new HashSet<>(features);
|
||||
#ignore
|
||||
derivedFeatures.remove(SERIALIZABLE);
|
||||
derivedFeatures.remove(SERIALIZABLE_INCLUDING_VIEWS);
|
||||
#endignore
|
||||
return derivedFeatures;
|
||||
}
|
||||
}
|
||||
package speiger.src.testers.PACKAGE.builder;
|
||||
|
||||
#ignore
|
||||
import static com.google.common.collect.testing.features.CollectionFeature.SERIALIZABLE;
|
||||
import static com.google.common.collect.testing.features.CollectionFeature.SERIALIZABLE_INCLUDING_VIEWS;
|
||||
#endignore
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.collect.testing.AbstractTester;
|
||||
import com.google.common.collect.testing.FeatureSpecificTestSuiteBuilder;
|
||||
import com.google.common.collect.testing.Helpers;
|
||||
import com.google.common.collect.testing.OneSizeTestContainerGenerator;
|
||||
import com.google.common.collect.testing.SampleElements;
|
||||
import com.google.common.collect.testing.SetTestSuiteBuilder;
|
||||
import com.google.common.collect.testing.TestSetGenerator;
|
||||
import com.google.common.collect.testing.features.Feature;
|
||||
import com.google.common.collect.testing.testers.CollectionSerializationEqualTester;
|
||||
import com.google.common.collect.testing.testers.SetAddAllTester;
|
||||
import com.google.common.collect.testing.testers.SetAddTester;
|
||||
import com.google.common.collect.testing.testers.SetCreationTester;
|
||||
import com.google.common.collect.testing.testers.SetEqualsTester;
|
||||
import com.google.common.collect.testing.testers.SetHashCodeTester;
|
||||
import com.google.common.collect.testing.testers.SetRemoveTester;
|
||||
import com.google.common.testing.SerializableTester;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
import speiger.src.testers.PACKAGE.generators.TEST_SET_GENERATOR;
|
||||
import speiger.src.testers.PACKAGE.tests.set.FILE_KEY_TYPESetAddAllTester;
|
||||
import speiger.src.testers.PACKAGE.tests.set.FILE_KEY_TYPESetAddTester;
|
||||
import speiger.src.testers.PACKAGE.tests.set.FILE_KEY_TYPESetCreationTester;
|
||||
import speiger.src.testers.PACKAGE.tests.set.FILE_KEY_TYPESetEqualsTester;
|
||||
import speiger.src.testers.PACKAGE.tests.set.FILE_KEY_TYPESetRemoveTester;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public class SET_TEST_BUILDER KEY_GENERIC_TYPE extends COLLECTION_TEST_BUILDER KEY_GENERIC_TYPE {
|
||||
public static GENERIC_KEY_BRACES SET_TEST_BUILDER KEY_GENERIC_TYPE using(TEST_SET_GENERATOR KEY_GENERIC_TYPE generator) {
|
||||
return (SET_TEST_BUILDER KEY_GENERIC_TYPE) new SET_TEST_BUILDER KEY_GENERIC_TYPE().usingGenerator(generator);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("rawtypes")
|
||||
protected List<Class<? extends AbstractTester>> getTesters() {
|
||||
List<Class<? extends AbstractTester>> testers = Helpers.copyToList(super.getTesters());
|
||||
testers.add(CollectionSerializationEqualTester.class);
|
||||
testers.add(SetAddAllTester.class);
|
||||
testers.add(SetAddTester.class);
|
||||
testers.add(SetCreationTester.class);
|
||||
testers.add(SetHashCodeTester.class);
|
||||
testers.add(SetEqualsTester.class);
|
||||
testers.add(SetRemoveTester.class);
|
||||
|
||||
testers.add(FILE_KEY_TYPESetAddAllTester.class);
|
||||
testers.add(FILE_KEY_TYPESetAddTester.class);
|
||||
testers.add(FILE_KEY_TYPESetCreationTester.class);
|
||||
testers.add(FILE_KEY_TYPESetEqualsTester.class);
|
||||
testers.add(FILE_KEY_TYPESetRemoveTester.class);
|
||||
return testers;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<TestSuite> createDerivedSuites(
|
||||
FeatureSpecificTestSuiteBuilder<?, ? extends OneSizeTestContainerGenerator<Collection<CLASS_TYPE>, CLASS_TYPE>> parentBuilder) {
|
||||
List<TestSuite> derivedSuites = new ArrayList<>(super.createDerivedSuites(parentBuilder));
|
||||
|
||||
if (parentBuilder.getFeatures().contains(SERIALIZABLE)) {
|
||||
derivedSuites.add(SetTestSuiteBuilder.using(new ReserializedSetGenerator<CLASS_TYPE>(parentBuilder.getSubjectGenerator()))
|
||||
.named(getName() + " reserialized")
|
||||
.withFeatures(computeReserializedCollectionFeatures(parentBuilder.getFeatures()))
|
||||
.suppressing(parentBuilder.getSuppressedTests()).withSetUp(parentBuilder.getSetUp())
|
||||
.withTearDown(parentBuilder.getTearDown()).createTestSuite());
|
||||
}
|
||||
return derivedSuites;
|
||||
}
|
||||
|
||||
static class ReserializedSetGenerator<E> implements TestSetGenerator<E> {
|
||||
final OneSizeTestContainerGenerator<Collection<E>, E> gen;
|
||||
|
||||
private ReserializedSetGenerator(OneSizeTestContainerGenerator<Collection<E>, E> gen) {
|
||||
this.gen = gen;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SampleElements<E> samples() {
|
||||
return gen.samples();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<E> create(Object... elements) {
|
||||
return (Set<E>) SerializableTester.reserialize(gen.create(elements));
|
||||
}
|
||||
|
||||
@Override
|
||||
public E[] createArray(int length) {
|
||||
return gen.createArray(length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<E> order(List<E> insertionOrder) {
|
||||
return gen.order(insertionOrder);
|
||||
}
|
||||
}
|
||||
|
||||
private static Set<Feature<?>> computeReserializedCollectionFeatures(Set<Feature<?>> features) {
|
||||
Set<Feature<?>> derivedFeatures = new HashSet<>(features);
|
||||
#ignore
|
||||
derivedFeatures.remove(SERIALIZABLE);
|
||||
derivedFeatures.remove(SERIALIZABLE_INCLUDING_VIEWS);
|
||||
#endignore
|
||||
return derivedFeatures;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,88 +1,88 @@
|
|||
package speiger.src.testers.PACKAGE.builder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.testing.AbstractTester;
|
||||
import com.google.common.collect.testing.DerivedCollectionGenerators.Bound;
|
||||
import com.google.common.collect.testing.FeatureSpecificTestSuiteBuilder;
|
||||
import com.google.common.collect.testing.Helpers;
|
||||
import com.google.common.collect.testing.OneSizeTestContainerGenerator;
|
||||
import com.google.common.collect.testing.features.CollectionFeature;
|
||||
import com.google.common.collect.testing.features.Feature;
|
||||
import com.google.common.collect.testing.testers.SortedSetNavigationTester;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
import speiger.src.testers.PACKAGE.generators.TEST_SORTED_SET_GENERATOR;
|
||||
import speiger.src.testers.PACKAGE.impl.SUB_SORTED_SET_CLASS_GENERATOR;
|
||||
import speiger.src.testers.PACKAGE.tests.set.FILE_KEY_TYPESortedSetIterationTester;
|
||||
import speiger.src.testers.PACKAGE.tests.set.FILE_KEY_TYPESortedSetNaviationTester;
|
||||
import speiger.src.testers.utils.SpecialFeature;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public class SORTED_SET_TEST_BUILDER KEY_GENERIC_TYPE extends SET_TEST_BUILDER KEY_GENERIC_TYPE {
|
||||
public static GENERIC_KEY_BRACES SORTED_SET_TEST_BUILDER KEY_GENERIC_TYPE using(TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE generator) {
|
||||
return (SORTED_SET_TEST_BUILDER KEY_GENERIC_TYPE) new SORTED_SET_TEST_BUILDER KEY_GENERIC_TYPE().usingGenerator(generator);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("rawtypes")
|
||||
protected List<Class<? extends AbstractTester>> getTesters() {
|
||||
List<Class<? extends AbstractTester>> testers = Helpers.copyToList(super.getTesters());
|
||||
testers.add(SortedSetNavigationTester.class);
|
||||
testers.add(FILE_KEY_TYPESortedSetIterationTester.class);
|
||||
testers.add(FILE_KEY_TYPESortedSetNaviationTester.class);
|
||||
return testers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TestSuite createTestSuite() {
|
||||
if (!getFeatures().contains(CollectionFeature.KNOWN_ORDER)) {
|
||||
List<Feature<?>> features = Helpers.copyToList(getFeatures());
|
||||
#ignore
|
||||
features.add(CollectionFeature.KNOWN_ORDER);
|
||||
#endignore
|
||||
withFeatures(features);
|
||||
}
|
||||
return super.createTestSuite();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<TestSuite> createDerivedSuites(
|
||||
FeatureSpecificTestSuiteBuilder<?, ? extends OneSizeTestContainerGenerator<Collection<CLASS_TYPE>, CLASS_TYPE>> parentBuilder) {
|
||||
List<TestSuite> derivedSuites = super.createDerivedSuites(parentBuilder);
|
||||
|
||||
#ignore
|
||||
if (!parentBuilder.getFeatures().contains(CollectionFeature.SUBSET_VIEW)) {
|
||||
#endignore
|
||||
derivedSuites.add(createSubsetSuite(parentBuilder, Bound.NO_BOUND, Bound.EXCLUSIVE));
|
||||
derivedSuites.add(createSubsetSuite(parentBuilder, Bound.INCLUSIVE, Bound.NO_BOUND));
|
||||
derivedSuites.add(createSubsetSuite(parentBuilder, Bound.INCLUSIVE, Bound.EXCLUSIVE));
|
||||
}
|
||||
|
||||
return derivedSuites;
|
||||
}
|
||||
|
||||
final TestSuite createSubsetSuite(
|
||||
FeatureSpecificTestSuiteBuilder<?, ? extends OneSizeTestContainerGenerator<Collection<CLASS_TYPE>, CLASS_TYPE>> parentBuilder,
|
||||
Bound from, Bound to) {
|
||||
TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE delegate = (TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE) parentBuilder.getSubjectGenerator().getInnerGenerator();
|
||||
|
||||
List<Feature<?>> features = new ArrayList<>(parentBuilder.getFeatures());
|
||||
#ignore
|
||||
features.remove(CollectionFeature.ALLOWS_NULL_VALUES);
|
||||
features.add(CollectionFeature.SUBSET_VIEW);
|
||||
features.remove(SpecialFeature.COPYING);
|
||||
features.remove(SpecialFeature.CHILDREN_COPY);
|
||||
#endignore
|
||||
|
||||
return newBuilderUsing(delegate, to, from).named(parentBuilder.getName() + " subSet " + from + "-" + to)
|
||||
.withFeatures(features).suppressing(parentBuilder.getSuppressedTests())
|
||||
.withSetUp(parentBuilder.getSetUp()).withTearDown(parentBuilder.getTearDown()).createTestSuite();
|
||||
}
|
||||
|
||||
SORTED_SET_TEST_BUILDER KEY_GENERIC_TYPE newBuilderUsing(TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE delegate, Bound to, Bound from) {
|
||||
return using(new SUB_SORTED_SET_CLASS_GENERATORBRACES(delegate, to, from));
|
||||
}
|
||||
}
|
||||
package speiger.src.testers.PACKAGE.builder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.testing.AbstractTester;
|
||||
import com.google.common.collect.testing.DerivedCollectionGenerators.Bound;
|
||||
import com.google.common.collect.testing.FeatureSpecificTestSuiteBuilder;
|
||||
import com.google.common.collect.testing.Helpers;
|
||||
import com.google.common.collect.testing.OneSizeTestContainerGenerator;
|
||||
import com.google.common.collect.testing.features.CollectionFeature;
|
||||
import com.google.common.collect.testing.features.Feature;
|
||||
import com.google.common.collect.testing.testers.SortedSetNavigationTester;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
import speiger.src.testers.PACKAGE.generators.TEST_SORTED_SET_GENERATOR;
|
||||
import speiger.src.testers.PACKAGE.impl.SUB_SORTED_SET_CLASS_GENERATOR;
|
||||
import speiger.src.testers.PACKAGE.tests.set.FILE_KEY_TYPESortedSetIterationTester;
|
||||
import speiger.src.testers.PACKAGE.tests.set.FILE_KEY_TYPESortedSetNaviationTester;
|
||||
import speiger.src.testers.utils.SpecialFeature;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public class SORTED_SET_TEST_BUILDER KEY_GENERIC_TYPE extends SET_TEST_BUILDER KEY_GENERIC_TYPE {
|
||||
public static GENERIC_KEY_BRACES SORTED_SET_TEST_BUILDER KEY_GENERIC_TYPE using(TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE generator) {
|
||||
return (SORTED_SET_TEST_BUILDER KEY_GENERIC_TYPE) new SORTED_SET_TEST_BUILDER KEY_GENERIC_TYPE().usingGenerator(generator);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("rawtypes")
|
||||
protected List<Class<? extends AbstractTester>> getTesters() {
|
||||
List<Class<? extends AbstractTester>> testers = Helpers.copyToList(super.getTesters());
|
||||
testers.add(SortedSetNavigationTester.class);
|
||||
testers.add(FILE_KEY_TYPESortedSetIterationTester.class);
|
||||
testers.add(FILE_KEY_TYPESortedSetNaviationTester.class);
|
||||
return testers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TestSuite createTestSuite() {
|
||||
if (!getFeatures().contains(CollectionFeature.KNOWN_ORDER)) {
|
||||
List<Feature<?>> features = Helpers.copyToList(getFeatures());
|
||||
#ignore
|
||||
features.add(CollectionFeature.KNOWN_ORDER);
|
||||
#endignore
|
||||
withFeatures(features);
|
||||
}
|
||||
return super.createTestSuite();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<TestSuite> createDerivedSuites(
|
||||
FeatureSpecificTestSuiteBuilder<?, ? extends OneSizeTestContainerGenerator<Collection<CLASS_TYPE>, CLASS_TYPE>> parentBuilder) {
|
||||
List<TestSuite> derivedSuites = super.createDerivedSuites(parentBuilder);
|
||||
|
||||
#ignore
|
||||
if (!parentBuilder.getFeatures().contains(CollectionFeature.SUBSET_VIEW)) {
|
||||
#endignore
|
||||
derivedSuites.add(createSubsetSuite(parentBuilder, Bound.NO_BOUND, Bound.EXCLUSIVE));
|
||||
derivedSuites.add(createSubsetSuite(parentBuilder, Bound.INCLUSIVE, Bound.NO_BOUND));
|
||||
derivedSuites.add(createSubsetSuite(parentBuilder, Bound.INCLUSIVE, Bound.EXCLUSIVE));
|
||||
}
|
||||
|
||||
return derivedSuites;
|
||||
}
|
||||
|
||||
final TestSuite createSubsetSuite(
|
||||
FeatureSpecificTestSuiteBuilder<?, ? extends OneSizeTestContainerGenerator<Collection<CLASS_TYPE>, CLASS_TYPE>> parentBuilder,
|
||||
Bound from, Bound to) {
|
||||
TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE delegate = (TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE) parentBuilder.getSubjectGenerator().getInnerGenerator();
|
||||
|
||||
List<Feature<?>> features = new ArrayList<>(parentBuilder.getFeatures());
|
||||
#ignore
|
||||
features.remove(CollectionFeature.ALLOWS_NULL_VALUES);
|
||||
features.add(CollectionFeature.SUBSET_VIEW);
|
||||
features.remove(SpecialFeature.COPYING);
|
||||
features.remove(SpecialFeature.CHILDREN_COPY);
|
||||
#endignore
|
||||
|
||||
return newBuilderUsing(delegate, to, from).named(parentBuilder.getName() + " subSet " + from + "-" + to)
|
||||
.withFeatures(features).suppressing(parentBuilder.getSuppressedTests())
|
||||
.withSetUp(parentBuilder.getSetUp()).withTearDown(parentBuilder.getTearDown()).createTestSuite();
|
||||
}
|
||||
|
||||
SORTED_SET_TEST_BUILDER KEY_GENERIC_TYPE newBuilderUsing(TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE delegate, Bound to, Bound from) {
|
||||
return using(new SUB_SORTED_SET_CLASS_GENERATORBRACES(delegate, to, from));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,304 +1,304 @@
|
|||
package speiger.src.testers.PACKAGE.builder.maps;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.collect.testing.AbstractTester;
|
||||
import com.google.common.collect.testing.FeatureSpecificTestSuiteBuilder;
|
||||
import com.google.common.collect.testing.MapTestSuiteBuilder;
|
||||
import com.google.common.collect.testing.OneSizeTestContainerGenerator;
|
||||
import com.google.common.collect.testing.features.CollectionFeature;
|
||||
import com.google.common.collect.testing.features.Feature;
|
||||
import com.google.common.collect.testing.features.MapFeature;
|
||||
import com.google.common.collect.testing.testers.CollectionIteratorTester;
|
||||
#if VALUE_BOOLEAN
|
||||
import com.google.common.collect.testing.testers.CollectionRemoveTester;
|
||||
import com.google.common.collect.testing.testers.CollectionRetainAllTester;
|
||||
#endif
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
||||
import speiger.src.testers.VALUE_PACKAGE.builder.VALUE_COLLECTION_TEST_BUILDER;
|
||||
import speiger.src.testers.VALUE_PACKAGE.generators.VALUE_TEST_COLLECTION_GENERATOR;
|
||||
#if !TYPE_OBJECT
|
||||
import speiger.src.testers.PACKAGE.builder.SET_TEST_BUILDER;
|
||||
import speiger.src.testers.PACKAGE.generators.TEST_SET_GENERATOR;
|
||||
#endif
|
||||
import speiger.src.testers.PACKAGE.generators.maps.TEST_MAP_GENERATOR;
|
||||
import speiger.src.testers.PACKAGE.impl.maps.DERIVED_MAP_GENERATORS;
|
||||
#if TYPE_CHAR || TYPE_FLOAT || TYPE_DOUBLE
|
||||
import speiger.src.testers.PACKAGE.tests.collection.FILE_KEY_TYPECollectionIteratorTester;
|
||||
#if !SAME_TYPE && !VALUE_OBJECT
|
||||
import speiger.src.testers.VALUE_PACKAGE.tests.collection.FILE_VALUE_TYPECollectionIteratorTester;
|
||||
#endif
|
||||
#else if TYPE_OBJECT && !VALUE_OBJECT
|
||||
import speiger.src.testers.VALUE_PACKAGE.tests.collection.FILE_VALUE_TYPECollectionIteratorTester;
|
||||
#endif
|
||||
#if VALUE_PRIMITIVES
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapAddToTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapSubFromTester;
|
||||
#endif
|
||||
#if VALUE_BOOLEAN
|
||||
#if !TYPE_CHAR && !TYPE_FLOAT && !TYPE_DOUBLE && !TYPE_OBJECT
|
||||
import speiger.src.testers.VALUE_PACKAGE.tests.collection.FILE_VALUE_TYPECollectionIteratorTester;
|
||||
#endif
|
||||
import speiger.src.testers.VALUE_PACKAGE.tests.collection.FILE_VALUE_TYPECollectionRemoveAllTester;
|
||||
import speiger.src.testers.VALUE_PACKAGE.tests.collection.FILE_VALUE_TYPECollectionRetainAllTester;
|
||||
#endif
|
||||
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapClearTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfAbsentTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfPresentTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapCopyTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapContainsTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapContainsKeyTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapContainsValueTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapEntrySetTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapEqualsTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapForEachTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapGetOrDefaultTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapGetTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapHashCodeTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapIsEmptyTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapMergeTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapMergeBulkTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapPutAllArrayTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapPutAllTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapPutIfAbsentTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapPutTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapRemoveEntryTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapRemoveOrDefaultTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapRemoveTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapReplaceAllTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapReplaceEntryTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapReplaceTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapSizeTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapSupplyIfAbsentTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapToStringTester;
|
||||
import speiger.src.testers.objects.builder.ObjectSetTestSuiteBuilder;
|
||||
import speiger.src.testers.objects.generators.TestObjectSetGenerator;
|
||||
import speiger.src.testers.objects.tests.collection.ObjectCollectionIteratorTester;
|
||||
import speiger.src.testers.objects.tests.collection.ObjectCollectionRemoveAllTester;
|
||||
import speiger.src.testers.objects.tests.collection.ObjectCollectionRetainAllTester;
|
||||
import speiger.src.testers.utils.SpecialFeature;
|
||||
import speiger.src.testers.utils.TestUtils;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public class MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE extends MapTestSuiteBuilder<CLASS_TYPE, CLASS_VALUE_TYPE> {
|
||||
boolean shouldBlockKeys;
|
||||
|
||||
public static GENERIC_KEY_VALUE_BRACES MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE using(TEST_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE generator) {
|
||||
return (MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE) new MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE().usingGenerator(generator);
|
||||
}
|
||||
|
||||
public MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE shouldBlockKeys(boolean value) {
|
||||
shouldBlockKeys = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("rawtypes")
|
||||
protected List<Class<? extends AbstractTester>> getTesters() {
|
||||
List<Class<? extends AbstractTester>> testers = new ArrayList<>();
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapClearTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfAbsentTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfPresentTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapSupplyIfAbsentTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapCopyTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapContainsTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapContainsKeyTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapContainsValueTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapEntrySetTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapEqualsTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapForEachTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapGetTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapGetOrDefaultTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapHashCodeTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapIsEmptyTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapMergeTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapMergeBulkTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapPutTester.class);
|
||||
#if VALUE_PRIMITIVES
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapAddToTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapSubFromTester.class);
|
||||
#endif
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapPutAllTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapPutAllArrayTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapPutIfAbsentTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapRemoveTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapRemoveEntryTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapRemoveOrDefaultTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapReplaceTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapReplaceAllTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapReplaceEntryTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapSizeTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapToStringTester.class);
|
||||
return testers;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<TestSuite> createDerivedSuites(FeatureSpecificTestSuiteBuilder<?, ? extends OneSizeTestContainerGenerator<Map<CLASS_TYPE, CLASS_VALUE_TYPE>, Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>>> parentBuilder) {
|
||||
List<TestSuite> derivedSuites = new ArrayList<>();
|
||||
derivedSuites.add(createDerivedEntrySetSuite(
|
||||
DERIVED_MAP_GENERATORS.entrySetGenerator(parentBuilder.getSubjectGenerator()))
|
||||
.withFeatures(computeEntrySetFeatures(parentBuilder.getFeatures()))
|
||||
.named(parentBuilder.getName() + " entrySet")
|
||||
.suppressing(getEntrySetSuppressing(parentBuilder.getSuppressedTests())).suppressing(getSuppressing(1))
|
||||
.withSetUp(parentBuilder.getSetUp()).withTearDown(parentBuilder.getTearDown())
|
||||
.createTestSuite());
|
||||
|
||||
derivedSuites.add(createDerivedKeySetSuite(
|
||||
DERIVED_MAP_GENERATORS.keySetGenerator(parentBuilder.getSubjectGenerator()))
|
||||
.withFeatures(computeKeySetFeatures(parentBuilder.getFeatures()))
|
||||
.named(parentBuilder.getName() + " keys").suppressing(parentBuilder.getSuppressedTests()).suppressing(getSuppressing(0))
|
||||
.withSetUp(parentBuilder.getSetUp()).withTearDown(parentBuilder.getTearDown())
|
||||
.createTestSuite());
|
||||
#if !TYPE_CHAR && !TYPE_OBJECT && !TYPE_FLOAT && !TYPE_DOUBLE || !VALUE_BOOLEAN
|
||||
derivedSuites.add(createDerivedValueCollectionSuite(
|
||||
new DERIVED_MAP_GENERATORS.MapValueCollectionGeneratorKV_BRACES(parentBuilder.getSubjectGenerator()))
|
||||
.named(parentBuilder.getName() + " values")
|
||||
.withFeatures(computeValuesCollectionFeatures(parentBuilder.getFeatures()))
|
||||
.suppressing(parentBuilder.getSuppressedTests()).suppressing(getSuppressing(2)).withSetUp(parentBuilder.getSetUp())
|
||||
.withTearDown(parentBuilder.getTearDown()).createTestSuite());
|
||||
#endif
|
||||
return derivedSuites;
|
||||
}
|
||||
|
||||
protected ObjectSetTestSuiteBuilder<MAP.Entry KEY_VALUE_GENERIC_TYPE> createDerivedEntrySetSuite(TestObjectSetGenerator<MAP.Entry KEY_VALUE_GENERIC_TYPE> entrySetGenerator) {
|
||||
return ObjectSetTestSuiteBuilder.using(entrySetGenerator);
|
||||
}
|
||||
|
||||
protected SET_TEST_BUILDER KEY_GENERIC_TYPE createDerivedKeySetSuite(TEST_SET_GENERATOR KEY_GENERIC_TYPE generator) {
|
||||
return SET_TEST_BUILDER.using(generator);
|
||||
}
|
||||
|
||||
protected VALUE_COLLECTION_TEST_BUILDER VALUE_GENERIC_TYPE createDerivedValueCollectionSuite(VALUE_TEST_COLLECTION_GENERATOR VALUE_GENERIC_TYPE generator) {
|
||||
return VALUE_COLLECTION_TEST_BUILDER.using(generator);
|
||||
}
|
||||
|
||||
private Method[] getSuppressing(int type) {
|
||||
#if TYPE_CHAR || TYPE_OBJECT || TYPE_FLOAT || TYPE_DOUBLE
|
||||
if(shouldBlockKeys) {
|
||||
switch(type) {
|
||||
case 0: return TestUtils.getSurpession(FILE_KEY_TYPECollectionIteratorTester.class, "testIterator_unknownOrderRemoveSupported");
|
||||
case 1: return TestUtils.getSurpession(ObjectCollectionIteratorTester.class, "testIterator_unknownOrderRemoveSupported");
|
||||
case 2: {
|
||||
List<Method> result = new ArrayList<>();
|
||||
TestUtils.getSurpession(result, FILE_VALUE_TYPECollectionIteratorTester.class, "testIterator_unknownOrderRemoveSupported");
|
||||
#if VALUE_BOOLEAN
|
||||
TestUtils.getSurpession(result, CollectionRemoveTester.class, "testRemove_present");
|
||||
TestUtils.getSurpession(result, CollectionRetainAllTester.class);
|
||||
TestUtils.getSurpession(result, FILE_VALUE_TYPECollectionIteratorTester.class, "testIterator_removeAffectsBackingCollection");
|
||||
TestUtils.getSurpession(result, FILE_VALUE_TYPECollectionRemoveAllTester.class, "testRemoveAll_someFetchRemovedElements");
|
||||
TestUtils.getSurpession(result, FILE_VALUE_TYPECollectionRetainAllTester.class);
|
||||
#endif
|
||||
return result.toArray(new Method[result.size()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return new Method[0];
|
||||
#else if VALUE_BOOLEAN
|
||||
if(type == 2) {
|
||||
List<Method> result = new ArrayList<>();
|
||||
TestUtils.getSurpession(result, FILE_VALUE_TYPECollectionIteratorTester.class, "testIterator_unknownOrderRemoveSupported");
|
||||
#if VALUE_BOOLEAN
|
||||
TestUtils.getSurpession(result, CollectionRemoveTester.class, "testRemove_present");
|
||||
TestUtils.getSurpession(result, CollectionRetainAllTester.class);
|
||||
TestUtils.getSurpession(result, FILE_VALUE_TYPECollectionIteratorTester.class, "testIterator_removeAffectsBackingCollection");
|
||||
TestUtils.getSurpession(result, FILE_VALUE_TYPECollectionRemoveAllTester.class, "testRemoveAll_someFetchRemovedElements");
|
||||
TestUtils.getSurpession(result, FILE_VALUE_TYPECollectionRetainAllTester.class);
|
||||
#endif
|
||||
return result.toArray(new Method[result.size()]);
|
||||
}
|
||||
return new Method[0];
|
||||
#else
|
||||
return new Method[0];
|
||||
#endif
|
||||
}
|
||||
|
||||
private static Set<Feature<?>> computeEntrySetFeatures(Set<Feature<?>> mapFeatures) {
|
||||
Set<Feature<?>> entrySetFeatures = MapTestSuiteBuilder.computeCommonDerivedCollectionFeatures(mapFeatures);
|
||||
#ignore
|
||||
if (mapFeatures.contains(MapFeature.ALLOWS_NULL_ENTRY_QUERIES)) {
|
||||
entrySetFeatures.add(CollectionFeature.ALLOWS_NULL_QUERIES);
|
||||
}
|
||||
if(mapFeatures.contains(SpecialFeature.CHILDREN_COPY)) {
|
||||
entrySetFeatures.add(SpecialFeature.COPYING);
|
||||
}
|
||||
else {
|
||||
entrySetFeatures.remove(SpecialFeature.COPYING);
|
||||
}
|
||||
if(mapFeatures.contains(SpecialFeature.MODIFIABLE)) {
|
||||
entrySetFeatures.add(SpecialFeature.MODIFIABLE);
|
||||
}
|
||||
else {
|
||||
entrySetFeatures.remove(SpecialFeature.MODIFIABLE);
|
||||
}
|
||||
entrySetFeatures.add(SpecialFeature.MAP_ENTRY);
|
||||
#endignore
|
||||
return entrySetFeatures;
|
||||
}
|
||||
|
||||
private static Set<Feature<?>> computeKeySetFeatures(Set<Feature<?>> mapFeatures) {
|
||||
Set<Feature<?>> keySetFeatures = MapTestSuiteBuilder.computeCommonDerivedCollectionFeatures(mapFeatures);
|
||||
#ignore
|
||||
keySetFeatures.add(CollectionFeature.SUBSET_VIEW);
|
||||
if (mapFeatures.contains(MapFeature.ALLOWS_NULL_KEYS)) {
|
||||
keySetFeatures.add(CollectionFeature.ALLOWS_NULL_VALUES);
|
||||
} else if (mapFeatures.contains(MapFeature.ALLOWS_NULL_KEY_QUERIES)) {
|
||||
keySetFeatures.add(CollectionFeature.ALLOWS_NULL_QUERIES);
|
||||
}
|
||||
if(mapFeatures.contains(SpecialFeature.CHILDREN_COPY)) {
|
||||
keySetFeatures.add(SpecialFeature.COPYING);
|
||||
}
|
||||
else {
|
||||
keySetFeatures.remove(SpecialFeature.COPYING);
|
||||
}
|
||||
if(mapFeatures.contains(SpecialFeature.MODIFIABLE)) {
|
||||
keySetFeatures.add(SpecialFeature.MODIFIABLE);
|
||||
}
|
||||
else {
|
||||
keySetFeatures.remove(SpecialFeature.MODIFIABLE);
|
||||
}
|
||||
#endignore
|
||||
return keySetFeatures;
|
||||
}
|
||||
|
||||
#if !TYPE_CHAR && !TYPE_OBJECT && !TYPE_FLOAT && !TYPE_DOUBLE || !VALUE_BOOLEAN
|
||||
private static Set<Feature<?>> computeValuesCollectionFeatures(Set<Feature<?>> mapFeatures) {
|
||||
Set<Feature<?>> valuesCollectionFeatures = MapTestSuiteBuilder.computeCommonDerivedCollectionFeatures(mapFeatures);
|
||||
#ignore
|
||||
if (mapFeatures.contains(MapFeature.ALLOWS_NULL_VALUE_QUERIES)) {
|
||||
valuesCollectionFeatures.add(CollectionFeature.ALLOWS_NULL_QUERIES);
|
||||
}
|
||||
if (mapFeatures.contains(MapFeature.ALLOWS_NULL_VALUES)) {
|
||||
valuesCollectionFeatures.add(CollectionFeature.ALLOWS_NULL_VALUES);
|
||||
}
|
||||
if(mapFeatures.contains(SpecialFeature.CHILDREN_COPY)) {
|
||||
valuesCollectionFeatures.add(SpecialFeature.COPYING);
|
||||
}
|
||||
else {
|
||||
valuesCollectionFeatures.remove(SpecialFeature.COPYING);
|
||||
}
|
||||
#endignore
|
||||
return valuesCollectionFeatures;
|
||||
}
|
||||
|
||||
#endif
|
||||
private static Set<Method> getEntrySetSuppressing(Set<Method> suppressing) {
|
||||
TestUtils.getSurpession(suppressing, CollectionIteratorTester.class, "testIterator_removeAffectsBackingCollection");
|
||||
TestUtils.getSurpession(suppressing, ObjectCollectionIteratorTester.class, "testIterator_removeAffectsBackingCollection");
|
||||
TestUtils.getSurpession(suppressing, ObjectCollectionRemoveAllTester.class, "testRemoveAll_someFetchRemovedElements");
|
||||
TestUtils.getSurpession(suppressing, ObjectCollectionRetainAllTester.class, "testRetainAllExtra_disjointPreviouslyNonEmpty", "testRetainAllExtra_containsDuplicatesSizeSeveral", "testRetainAllExtra_subset", "testRetainAllExtra_partialOverlap");
|
||||
#if TYPE_DOUBLE || TYPE_FLOAT
|
||||
TestUtils.getSurpession(suppressing, CollectionIteratorTester.class, "testIterator_unknownOrderRemoveSupported");
|
||||
TestUtils.getSurpession(suppressing, ObjectCollectionIteratorTester.class, "testIterator_unknownOrderRemoveSupported");
|
||||
#endif
|
||||
return suppressing;
|
||||
}
|
||||
package speiger.src.testers.PACKAGE.builder.maps;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.collect.testing.AbstractTester;
|
||||
import com.google.common.collect.testing.FeatureSpecificTestSuiteBuilder;
|
||||
import com.google.common.collect.testing.MapTestSuiteBuilder;
|
||||
import com.google.common.collect.testing.OneSizeTestContainerGenerator;
|
||||
import com.google.common.collect.testing.features.CollectionFeature;
|
||||
import com.google.common.collect.testing.features.Feature;
|
||||
import com.google.common.collect.testing.features.MapFeature;
|
||||
import com.google.common.collect.testing.testers.CollectionIteratorTester;
|
||||
#if VALUE_BOOLEAN
|
||||
import com.google.common.collect.testing.testers.CollectionRemoveTester;
|
||||
import com.google.common.collect.testing.testers.CollectionRetainAllTester;
|
||||
#endif
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
||||
import speiger.src.testers.VALUE_PACKAGE.builder.VALUE_COLLECTION_TEST_BUILDER;
|
||||
import speiger.src.testers.VALUE_PACKAGE.generators.VALUE_TEST_COLLECTION_GENERATOR;
|
||||
#if !TYPE_OBJECT
|
||||
import speiger.src.testers.PACKAGE.builder.SET_TEST_BUILDER;
|
||||
import speiger.src.testers.PACKAGE.generators.TEST_SET_GENERATOR;
|
||||
#endif
|
||||
import speiger.src.testers.PACKAGE.generators.maps.TEST_MAP_GENERATOR;
|
||||
import speiger.src.testers.PACKAGE.impl.maps.DERIVED_MAP_GENERATORS;
|
||||
#if TYPE_CHAR || TYPE_FLOAT || TYPE_DOUBLE
|
||||
import speiger.src.testers.PACKAGE.tests.collection.FILE_KEY_TYPECollectionIteratorTester;
|
||||
#if !SAME_TYPE && !VALUE_OBJECT
|
||||
import speiger.src.testers.VALUE_PACKAGE.tests.collection.FILE_VALUE_TYPECollectionIteratorTester;
|
||||
#endif
|
||||
#else if TYPE_OBJECT && !VALUE_OBJECT
|
||||
import speiger.src.testers.VALUE_PACKAGE.tests.collection.FILE_VALUE_TYPECollectionIteratorTester;
|
||||
#endif
|
||||
#if VALUE_PRIMITIVES
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapAddToTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapSubFromTester;
|
||||
#endif
|
||||
#if VALUE_BOOLEAN
|
||||
#if !TYPE_CHAR && !TYPE_FLOAT && !TYPE_DOUBLE && !TYPE_OBJECT
|
||||
import speiger.src.testers.VALUE_PACKAGE.tests.collection.FILE_VALUE_TYPECollectionIteratorTester;
|
||||
#endif
|
||||
import speiger.src.testers.VALUE_PACKAGE.tests.collection.FILE_VALUE_TYPECollectionRemoveAllTester;
|
||||
import speiger.src.testers.VALUE_PACKAGE.tests.collection.FILE_VALUE_TYPECollectionRetainAllTester;
|
||||
#endif
|
||||
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapClearTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfAbsentTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfPresentTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapCopyTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapContainsTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapContainsKeyTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapContainsValueTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapEntrySetTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapEqualsTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapForEachTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapGetOrDefaultTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapGetTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapHashCodeTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapIsEmptyTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapMergeTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapMergeBulkTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapPutAllArrayTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapPutAllTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapPutIfAbsentTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapPutTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapRemoveEntryTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapRemoveOrDefaultTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapRemoveTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapReplaceAllTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapReplaceEntryTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapReplaceTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapSizeTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapSupplyIfAbsentTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapToStringTester;
|
||||
import speiger.src.testers.objects.builder.ObjectSetTestSuiteBuilder;
|
||||
import speiger.src.testers.objects.generators.TestObjectSetGenerator;
|
||||
import speiger.src.testers.objects.tests.collection.ObjectCollectionIteratorTester;
|
||||
import speiger.src.testers.objects.tests.collection.ObjectCollectionRemoveAllTester;
|
||||
import speiger.src.testers.objects.tests.collection.ObjectCollectionRetainAllTester;
|
||||
import speiger.src.testers.utils.SpecialFeature;
|
||||
import speiger.src.testers.utils.TestUtils;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public class MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE extends MapTestSuiteBuilder<CLASS_TYPE, CLASS_VALUE_TYPE> {
|
||||
boolean shouldBlockKeys;
|
||||
|
||||
public static GENERIC_KEY_VALUE_BRACES MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE using(TEST_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE generator) {
|
||||
return (MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE) new MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE().usingGenerator(generator);
|
||||
}
|
||||
|
||||
public MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE shouldBlockKeys(boolean value) {
|
||||
shouldBlockKeys = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("rawtypes")
|
||||
protected List<Class<? extends AbstractTester>> getTesters() {
|
||||
List<Class<? extends AbstractTester>> testers = new ArrayList<>();
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapClearTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfAbsentTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfPresentTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapSupplyIfAbsentTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapCopyTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapContainsTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapContainsKeyTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapContainsValueTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapEntrySetTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapEqualsTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapForEachTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapGetTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapGetOrDefaultTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapHashCodeTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapIsEmptyTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapMergeTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapMergeBulkTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapPutTester.class);
|
||||
#if VALUE_PRIMITIVES
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapAddToTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapSubFromTester.class);
|
||||
#endif
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapPutAllTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapPutAllArrayTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapPutIfAbsentTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapRemoveTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapRemoveEntryTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapRemoveOrDefaultTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapReplaceTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapReplaceAllTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapReplaceEntryTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapSizeTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapToStringTester.class);
|
||||
return testers;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<TestSuite> createDerivedSuites(FeatureSpecificTestSuiteBuilder<?, ? extends OneSizeTestContainerGenerator<Map<CLASS_TYPE, CLASS_VALUE_TYPE>, Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>>> parentBuilder) {
|
||||
List<TestSuite> derivedSuites = new ArrayList<>();
|
||||
derivedSuites.add(createDerivedEntrySetSuite(
|
||||
DERIVED_MAP_GENERATORS.entrySetGenerator(parentBuilder.getSubjectGenerator()))
|
||||
.withFeatures(computeEntrySetFeatures(parentBuilder.getFeatures()))
|
||||
.named(parentBuilder.getName() + " entrySet")
|
||||
.suppressing(getEntrySetSuppressing(parentBuilder.getSuppressedTests())).suppressing(getSuppressing(1))
|
||||
.withSetUp(parentBuilder.getSetUp()).withTearDown(parentBuilder.getTearDown())
|
||||
.createTestSuite());
|
||||
|
||||
derivedSuites.add(createDerivedKeySetSuite(
|
||||
DERIVED_MAP_GENERATORS.keySetGenerator(parentBuilder.getSubjectGenerator()))
|
||||
.withFeatures(computeKeySetFeatures(parentBuilder.getFeatures()))
|
||||
.named(parentBuilder.getName() + " keys").suppressing(parentBuilder.getSuppressedTests()).suppressing(getSuppressing(0))
|
||||
.withSetUp(parentBuilder.getSetUp()).withTearDown(parentBuilder.getTearDown())
|
||||
.createTestSuite());
|
||||
#if !TYPE_CHAR && !TYPE_OBJECT && !TYPE_FLOAT && !TYPE_DOUBLE || !VALUE_BOOLEAN
|
||||
derivedSuites.add(createDerivedValueCollectionSuite(
|
||||
new DERIVED_MAP_GENERATORS.MapValueCollectionGeneratorKV_BRACES(parentBuilder.getSubjectGenerator()))
|
||||
.named(parentBuilder.getName() + " values")
|
||||
.withFeatures(computeValuesCollectionFeatures(parentBuilder.getFeatures()))
|
||||
.suppressing(parentBuilder.getSuppressedTests()).suppressing(getSuppressing(2)).withSetUp(parentBuilder.getSetUp())
|
||||
.withTearDown(parentBuilder.getTearDown()).createTestSuite());
|
||||
#endif
|
||||
return derivedSuites;
|
||||
}
|
||||
|
||||
protected ObjectSetTestSuiteBuilder<MAP.Entry KEY_VALUE_GENERIC_TYPE> createDerivedEntrySetSuite(TestObjectSetGenerator<MAP.Entry KEY_VALUE_GENERIC_TYPE> entrySetGenerator) {
|
||||
return ObjectSetTestSuiteBuilder.using(entrySetGenerator);
|
||||
}
|
||||
|
||||
protected SET_TEST_BUILDER KEY_GENERIC_TYPE createDerivedKeySetSuite(TEST_SET_GENERATOR KEY_GENERIC_TYPE generator) {
|
||||
return SET_TEST_BUILDER.using(generator);
|
||||
}
|
||||
|
||||
protected VALUE_COLLECTION_TEST_BUILDER VALUE_GENERIC_TYPE createDerivedValueCollectionSuite(VALUE_TEST_COLLECTION_GENERATOR VALUE_GENERIC_TYPE generator) {
|
||||
return VALUE_COLLECTION_TEST_BUILDER.using(generator);
|
||||
}
|
||||
|
||||
private Method[] getSuppressing(int type) {
|
||||
#if TYPE_CHAR || TYPE_OBJECT || TYPE_FLOAT || TYPE_DOUBLE
|
||||
if(shouldBlockKeys) {
|
||||
switch(type) {
|
||||
case 0: return TestUtils.getSurpession(FILE_KEY_TYPECollectionIteratorTester.class, "testIterator_unknownOrderRemoveSupported");
|
||||
case 1: return TestUtils.getSurpession(ObjectCollectionIteratorTester.class, "testIterator_unknownOrderRemoveSupported");
|
||||
case 2: {
|
||||
List<Method> result = new ArrayList<>();
|
||||
TestUtils.getSurpession(result, FILE_VALUE_TYPECollectionIteratorTester.class, "testIterator_unknownOrderRemoveSupported");
|
||||
#if VALUE_BOOLEAN
|
||||
TestUtils.getSurpession(result, CollectionRemoveTester.class, "testRemove_present");
|
||||
TestUtils.getSurpession(result, CollectionRetainAllTester.class);
|
||||
TestUtils.getSurpession(result, FILE_VALUE_TYPECollectionIteratorTester.class, "testIterator_removeAffectsBackingCollection");
|
||||
TestUtils.getSurpession(result, FILE_VALUE_TYPECollectionRemoveAllTester.class, "testRemoveAll_someFetchRemovedElements");
|
||||
TestUtils.getSurpession(result, FILE_VALUE_TYPECollectionRetainAllTester.class);
|
||||
#endif
|
||||
return result.toArray(new Method[result.size()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return new Method[0];
|
||||
#else if VALUE_BOOLEAN
|
||||
if(type == 2) {
|
||||
List<Method> result = new ArrayList<>();
|
||||
TestUtils.getSurpession(result, FILE_VALUE_TYPECollectionIteratorTester.class, "testIterator_unknownOrderRemoveSupported");
|
||||
#if VALUE_BOOLEAN
|
||||
TestUtils.getSurpession(result, CollectionRemoveTester.class, "testRemove_present");
|
||||
TestUtils.getSurpession(result, CollectionRetainAllTester.class);
|
||||
TestUtils.getSurpession(result, FILE_VALUE_TYPECollectionIteratorTester.class, "testIterator_removeAffectsBackingCollection");
|
||||
TestUtils.getSurpession(result, FILE_VALUE_TYPECollectionRemoveAllTester.class, "testRemoveAll_someFetchRemovedElements");
|
||||
TestUtils.getSurpession(result, FILE_VALUE_TYPECollectionRetainAllTester.class);
|
||||
#endif
|
||||
return result.toArray(new Method[result.size()]);
|
||||
}
|
||||
return new Method[0];
|
||||
#else
|
||||
return new Method[0];
|
||||
#endif
|
||||
}
|
||||
|
||||
private static Set<Feature<?>> computeEntrySetFeatures(Set<Feature<?>> mapFeatures) {
|
||||
Set<Feature<?>> entrySetFeatures = MapTestSuiteBuilder.computeCommonDerivedCollectionFeatures(mapFeatures);
|
||||
#ignore
|
||||
if (mapFeatures.contains(MapFeature.ALLOWS_NULL_ENTRY_QUERIES)) {
|
||||
entrySetFeatures.add(CollectionFeature.ALLOWS_NULL_QUERIES);
|
||||
}
|
||||
if(mapFeatures.contains(SpecialFeature.CHILDREN_COPY)) {
|
||||
entrySetFeatures.add(SpecialFeature.COPYING);
|
||||
}
|
||||
else {
|
||||
entrySetFeatures.remove(SpecialFeature.COPYING);
|
||||
}
|
||||
if(mapFeatures.contains(SpecialFeature.MODIFIABLE)) {
|
||||
entrySetFeatures.add(SpecialFeature.MODIFIABLE);
|
||||
}
|
||||
else {
|
||||
entrySetFeatures.remove(SpecialFeature.MODIFIABLE);
|
||||
}
|
||||
entrySetFeatures.add(SpecialFeature.MAP_ENTRY);
|
||||
#endignore
|
||||
return entrySetFeatures;
|
||||
}
|
||||
|
||||
private static Set<Feature<?>> computeKeySetFeatures(Set<Feature<?>> mapFeatures) {
|
||||
Set<Feature<?>> keySetFeatures = MapTestSuiteBuilder.computeCommonDerivedCollectionFeatures(mapFeatures);
|
||||
#ignore
|
||||
keySetFeatures.add(CollectionFeature.SUBSET_VIEW);
|
||||
if (mapFeatures.contains(MapFeature.ALLOWS_NULL_KEYS)) {
|
||||
keySetFeatures.add(CollectionFeature.ALLOWS_NULL_VALUES);
|
||||
} else if (mapFeatures.contains(MapFeature.ALLOWS_NULL_KEY_QUERIES)) {
|
||||
keySetFeatures.add(CollectionFeature.ALLOWS_NULL_QUERIES);
|
||||
}
|
||||
if(mapFeatures.contains(SpecialFeature.CHILDREN_COPY)) {
|
||||
keySetFeatures.add(SpecialFeature.COPYING);
|
||||
}
|
||||
else {
|
||||
keySetFeatures.remove(SpecialFeature.COPYING);
|
||||
}
|
||||
if(mapFeatures.contains(SpecialFeature.MODIFIABLE)) {
|
||||
keySetFeatures.add(SpecialFeature.MODIFIABLE);
|
||||
}
|
||||
else {
|
||||
keySetFeatures.remove(SpecialFeature.MODIFIABLE);
|
||||
}
|
||||
#endignore
|
||||
return keySetFeatures;
|
||||
}
|
||||
|
||||
#if !TYPE_CHAR && !TYPE_OBJECT && !TYPE_FLOAT && !TYPE_DOUBLE || !VALUE_BOOLEAN
|
||||
private static Set<Feature<?>> computeValuesCollectionFeatures(Set<Feature<?>> mapFeatures) {
|
||||
Set<Feature<?>> valuesCollectionFeatures = MapTestSuiteBuilder.computeCommonDerivedCollectionFeatures(mapFeatures);
|
||||
#ignore
|
||||
if (mapFeatures.contains(MapFeature.ALLOWS_NULL_VALUE_QUERIES)) {
|
||||
valuesCollectionFeatures.add(CollectionFeature.ALLOWS_NULL_QUERIES);
|
||||
}
|
||||
if (mapFeatures.contains(MapFeature.ALLOWS_NULL_VALUES)) {
|
||||
valuesCollectionFeatures.add(CollectionFeature.ALLOWS_NULL_VALUES);
|
||||
}
|
||||
if(mapFeatures.contains(SpecialFeature.CHILDREN_COPY)) {
|
||||
valuesCollectionFeatures.add(SpecialFeature.COPYING);
|
||||
}
|
||||
else {
|
||||
valuesCollectionFeatures.remove(SpecialFeature.COPYING);
|
||||
}
|
||||
#endignore
|
||||
return valuesCollectionFeatures;
|
||||
}
|
||||
|
||||
#endif
|
||||
private static Set<Method> getEntrySetSuppressing(Set<Method> suppressing) {
|
||||
TestUtils.getSurpession(suppressing, CollectionIteratorTester.class, "testIterator_removeAffectsBackingCollection");
|
||||
TestUtils.getSurpession(suppressing, ObjectCollectionIteratorTester.class, "testIterator_removeAffectsBackingCollection");
|
||||
TestUtils.getSurpession(suppressing, ObjectCollectionRemoveAllTester.class, "testRemoveAll_someFetchRemovedElements");
|
||||
TestUtils.getSurpession(suppressing, ObjectCollectionRetainAllTester.class, "testRetainAllExtra_disjointPreviouslyNonEmpty", "testRetainAllExtra_containsDuplicatesSizeSeveral", "testRetainAllExtra_subset", "testRetainAllExtra_partialOverlap");
|
||||
#if TYPE_DOUBLE || TYPE_FLOAT
|
||||
TestUtils.getSurpession(suppressing, CollectionIteratorTester.class, "testIterator_unknownOrderRemoveSupported");
|
||||
TestUtils.getSurpession(suppressing, ObjectCollectionIteratorTester.class, "testIterator_unknownOrderRemoveSupported");
|
||||
#endif
|
||||
return suppressing;
|
||||
}
|
||||
}
|
|
@ -1,79 +1,79 @@
|
|||
package speiger.src.testers.PACKAGE.builder.maps;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.testing.AbstractTester;
|
||||
import com.google.common.collect.testing.DerivedCollectionGenerators.Bound;
|
||||
import com.google.common.collect.testing.FeatureSpecificTestSuiteBuilder;
|
||||
import com.google.common.collect.testing.OneSizeTestContainerGenerator;
|
||||
import com.google.common.collect.testing.features.Feature;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
import speiger.src.testers.PACKAGE.builder.NAVIGABLE_SET_TEST_BUILDER;
|
||||
import speiger.src.testers.PACKAGE.generators.TEST_SET_GENERATOR;
|
||||
import speiger.src.testers.PACKAGE.generators.TEST_NAVIGABLE_SET_GENERATOR;
|
||||
import speiger.src.testers.PACKAGE.generators.maps.TEST_SORTED_MAP_GENERATOR;
|
||||
import speiger.src.testers.PACKAGE.impl.maps.DERIVED_MAP_GENERATORS;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPENavigableMapNavigationTester;
|
||||
import speiger.src.testers.utils.SpecialFeature;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public class NAVIGABLE_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE extends SORTED_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE
|
||||
{
|
||||
public static GENERIC_KEY_VALUE_BRACES NAVIGABLE_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE using(TEST_SORTED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE generator) {
|
||||
return (NAVIGABLE_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE)new NAVIGABLE_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE().usingGenerator(generator);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("rawtypes")
|
||||
protected List<Class<? extends AbstractTester>> getTesters() {
|
||||
List<Class<? extends AbstractTester>> testers = super.getTesters();
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPENavigableMapNavigationTester.class);
|
||||
return testers;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<TestSuite> createDerivedSuites(FeatureSpecificTestSuiteBuilder<?, ? extends OneSizeTestContainerGenerator<Map<CLASS_TYPE, CLASS_VALUE_TYPE>, Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>>> parentBuilder) {
|
||||
List<TestSuite> derivedSuites = super.createDerivedSuites(parentBuilder);
|
||||
#ignore
|
||||
if (!parentBuilder.getFeatures().contains(SpecialFeature.DESCENDING)) {
|
||||
derivedSuites.add(createDescendingSuite(parentBuilder));
|
||||
}
|
||||
if (!parentBuilder.getFeatures().contains(SpecialFeature.SUBMAP)) {
|
||||
derivedSuites.add(createSubmapSuite(parentBuilder, Bound.NO_BOUND, Bound.INCLUSIVE));
|
||||
derivedSuites.add(createSubmapSuite(parentBuilder, Bound.EXCLUSIVE, Bound.NO_BOUND));
|
||||
derivedSuites.add(createSubmapSuite(parentBuilder, Bound.EXCLUSIVE, Bound.EXCLUSIVE));
|
||||
derivedSuites.add(createSubmapSuite(parentBuilder, Bound.EXCLUSIVE, Bound.INCLUSIVE));
|
||||
derivedSuites.add(createSubmapSuite(parentBuilder, Bound.INCLUSIVE, Bound.INCLUSIVE));
|
||||
}
|
||||
#endignore
|
||||
return derivedSuites;
|
||||
}
|
||||
|
||||
@Override
|
||||
NAVIGABLE_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE newBuilderUsing(TEST_SORTED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE delegate, Bound to, Bound from) {
|
||||
return NAVIGABLE_MAP_TEST_BUILDER.using(new DERIVED_MAP_GENERATORS.NavigableMapGeneratorKV_BRACES(delegate, to, from));
|
||||
}
|
||||
|
||||
private TestSuite createDescendingSuite(FeatureSpecificTestSuiteBuilder<?, ? extends OneSizeTestContainerGenerator<Map<CLASS_TYPE, CLASS_VALUE_TYPE>, Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>>> parentBuilder) {
|
||||
TEST_SORTED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE delegate = (TEST_SORTED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE) parentBuilder.getSubjectGenerator().getInnerGenerator();
|
||||
|
||||
List<Feature<?>> features = new ArrayList<>();
|
||||
#ignore
|
||||
features.add(SpecialFeature.DESCENDING);
|
||||
features.addAll(parentBuilder.getFeatures());
|
||||
features.remove(SpecialFeature.COPYING);
|
||||
features.remove(SpecialFeature.CHILDREN_COPY);
|
||||
#endignore
|
||||
return NAVIGABLE_MAP_TEST_BUILDER.using(new DERIVED_MAP_GENERATORS.DescendingTestMapGeneratorKV_BRACES(delegate))
|
||||
.named(parentBuilder.getName() + " descending").withFeatures(features)
|
||||
.suppressing(parentBuilder.getSuppressedTests()).createTestSuite();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NAVIGABLE_SET_TEST_BUILDER KEY_GENERIC_TYPE createDerivedKeySetSuite(TEST_SET_GENERATOR KEY_GENERIC_TYPE keySetGenerator) {
|
||||
return NAVIGABLE_SET_TEST_BUILDER.using((TEST_NAVIGABLE_SET_GENERATOR KEY_GENERIC_TYPE) keySetGenerator);
|
||||
}
|
||||
}
|
||||
package speiger.src.testers.PACKAGE.builder.maps;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.testing.AbstractTester;
|
||||
import com.google.common.collect.testing.DerivedCollectionGenerators.Bound;
|
||||
import com.google.common.collect.testing.FeatureSpecificTestSuiteBuilder;
|
||||
import com.google.common.collect.testing.OneSizeTestContainerGenerator;
|
||||
import com.google.common.collect.testing.features.Feature;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
import speiger.src.testers.PACKAGE.builder.NAVIGABLE_SET_TEST_BUILDER;
|
||||
import speiger.src.testers.PACKAGE.generators.TEST_SET_GENERATOR;
|
||||
import speiger.src.testers.PACKAGE.generators.TEST_NAVIGABLE_SET_GENERATOR;
|
||||
import speiger.src.testers.PACKAGE.generators.maps.TEST_SORTED_MAP_GENERATOR;
|
||||
import speiger.src.testers.PACKAGE.impl.maps.DERIVED_MAP_GENERATORS;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPENavigableMapNavigationTester;
|
||||
import speiger.src.testers.utils.SpecialFeature;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public class NAVIGABLE_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE extends SORTED_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE
|
||||
{
|
||||
public static GENERIC_KEY_VALUE_BRACES NAVIGABLE_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE using(TEST_SORTED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE generator) {
|
||||
return (NAVIGABLE_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE)new NAVIGABLE_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE().usingGenerator(generator);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("rawtypes")
|
||||
protected List<Class<? extends AbstractTester>> getTesters() {
|
||||
List<Class<? extends AbstractTester>> testers = super.getTesters();
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPENavigableMapNavigationTester.class);
|
||||
return testers;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<TestSuite> createDerivedSuites(FeatureSpecificTestSuiteBuilder<?, ? extends OneSizeTestContainerGenerator<Map<CLASS_TYPE, CLASS_VALUE_TYPE>, Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>>> parentBuilder) {
|
||||
List<TestSuite> derivedSuites = super.createDerivedSuites(parentBuilder);
|
||||
#ignore
|
||||
if (!parentBuilder.getFeatures().contains(SpecialFeature.DESCENDING)) {
|
||||
derivedSuites.add(createDescendingSuite(parentBuilder));
|
||||
}
|
||||
if (!parentBuilder.getFeatures().contains(SpecialFeature.SUBMAP)) {
|
||||
derivedSuites.add(createSubmapSuite(parentBuilder, Bound.NO_BOUND, Bound.INCLUSIVE));
|
||||
derivedSuites.add(createSubmapSuite(parentBuilder, Bound.EXCLUSIVE, Bound.NO_BOUND));
|
||||
derivedSuites.add(createSubmapSuite(parentBuilder, Bound.EXCLUSIVE, Bound.EXCLUSIVE));
|
||||
derivedSuites.add(createSubmapSuite(parentBuilder, Bound.EXCLUSIVE, Bound.INCLUSIVE));
|
||||
derivedSuites.add(createSubmapSuite(parentBuilder, Bound.INCLUSIVE, Bound.INCLUSIVE));
|
||||
}
|
||||
#endignore
|
||||
return derivedSuites;
|
||||
}
|
||||
|
||||
@Override
|
||||
NAVIGABLE_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE newBuilderUsing(TEST_SORTED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE delegate, Bound to, Bound from) {
|
||||
return NAVIGABLE_MAP_TEST_BUILDER.using(new DERIVED_MAP_GENERATORS.NavigableMapGeneratorKV_BRACES(delegate, to, from));
|
||||
}
|
||||
|
||||
private TestSuite createDescendingSuite(FeatureSpecificTestSuiteBuilder<?, ? extends OneSizeTestContainerGenerator<Map<CLASS_TYPE, CLASS_VALUE_TYPE>, Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>>> parentBuilder) {
|
||||
TEST_SORTED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE delegate = (TEST_SORTED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE) parentBuilder.getSubjectGenerator().getInnerGenerator();
|
||||
|
||||
List<Feature<?>> features = new ArrayList<>();
|
||||
#ignore
|
||||
features.add(SpecialFeature.DESCENDING);
|
||||
features.addAll(parentBuilder.getFeatures());
|
||||
features.remove(SpecialFeature.COPYING);
|
||||
features.remove(SpecialFeature.CHILDREN_COPY);
|
||||
#endignore
|
||||
return NAVIGABLE_MAP_TEST_BUILDER.using(new DERIVED_MAP_GENERATORS.DescendingTestMapGeneratorKV_BRACES(delegate))
|
||||
.named(parentBuilder.getName() + " descending").withFeatures(features)
|
||||
.suppressing(parentBuilder.getSuppressedTests()).createTestSuite();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NAVIGABLE_SET_TEST_BUILDER KEY_GENERIC_TYPE createDerivedKeySetSuite(TEST_SET_GENERATOR KEY_GENERIC_TYPE keySetGenerator) {
|
||||
return NAVIGABLE_SET_TEST_BUILDER.using((TEST_NAVIGABLE_SET_GENERATOR KEY_GENERIC_TYPE) keySetGenerator);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,55 +1,55 @@
|
|||
package speiger.src.testers.PACKAGE.builder.maps;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.testing.AbstractTester;
|
||||
import com.google.common.collect.testing.features.CollectionFeature;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
||||
import speiger.src.testers.PACKAGE.builder.ORDERED_SET_TEST_BUILDER;
|
||||
import speiger.src.testers.PACKAGE.builder.SET_TEST_BUILDER;
|
||||
import speiger.src.testers.PACKAGE.generators.TEST_ORDERED_SET_GENERATOR;
|
||||
import speiger.src.testers.PACKAGE.generators.TEST_SET_GENERATOR;
|
||||
import speiger.src.testers.PACKAGE.generators.maps.TEST_ORDERED_MAP_GENERATOR;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEOrderedMapMoveTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEOrderedMapNavigationTester;
|
||||
#if !TYPE_OBJECT
|
||||
import speiger.src.testers.objects.builder.ObjectSetTestSuiteBuilder;
|
||||
import speiger.src.testers.objects.generators.TestObjectSetGenerator;
|
||||
import speiger.src.testers.objects.builder.ObjectOrderedSetTestSuiteBuilder;
|
||||
import speiger.src.testers.objects.generators.TestObjectOrderedSetGenerator;
|
||||
#endif
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public class ORDERED_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE extends MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE
|
||||
{
|
||||
public static GENERIC_KEY_VALUE_BRACES ORDERED_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE using(TEST_ORDERED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE generator) {
|
||||
return (ORDERED_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE) new ORDERED_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE().usingGenerator(generator);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("rawtypes")
|
||||
protected List<Class<? extends AbstractTester>> getTesters() {
|
||||
List<Class<? extends AbstractTester>> testers = super.getTesters();
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEOrderedMapMoveTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEOrderedMapNavigationTester.class);
|
||||
return testers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TestSuite createTestSuite() {
|
||||
#ignore
|
||||
withFeatures(CollectionFeature.KNOWN_ORDER);
|
||||
#endignore
|
||||
return super.createTestSuite();
|
||||
}
|
||||
|
||||
protected ObjectSetTestSuiteBuilder<MAP.Entry KEY_VALUE_GENERIC_TYPE> createDerivedEntrySetSuite(TestObjectSetGenerator<MAP.Entry KEY_VALUE_GENERIC_TYPE> entrySetGenerator) {
|
||||
return ObjectOrderedSetTestSuiteBuilder.using((TestObjectOrderedSetGenerator<MAP.Entry KEY_VALUE_GENERIC_TYPE>)entrySetGenerator);
|
||||
}
|
||||
|
||||
protected SET_TEST_BUILDER KEY_GENERIC_TYPE createDerivedKeySetSuite(TEST_SET_GENERATOR KEY_GENERIC_TYPE generator) {
|
||||
return ORDERED_SET_TEST_BUILDER.using((TEST_ORDERED_SET_GENERATOR KEY_GENERIC_TYPE)generator);
|
||||
}
|
||||
}
|
||||
package speiger.src.testers.PACKAGE.builder.maps;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.testing.AbstractTester;
|
||||
import com.google.common.collect.testing.features.CollectionFeature;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
||||
import speiger.src.testers.PACKAGE.builder.ORDERED_SET_TEST_BUILDER;
|
||||
import speiger.src.testers.PACKAGE.builder.SET_TEST_BUILDER;
|
||||
import speiger.src.testers.PACKAGE.generators.TEST_ORDERED_SET_GENERATOR;
|
||||
import speiger.src.testers.PACKAGE.generators.TEST_SET_GENERATOR;
|
||||
import speiger.src.testers.PACKAGE.generators.maps.TEST_ORDERED_MAP_GENERATOR;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEOrderedMapMoveTester;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEOrderedMapNavigationTester;
|
||||
#if !TYPE_OBJECT
|
||||
import speiger.src.testers.objects.builder.ObjectSetTestSuiteBuilder;
|
||||
import speiger.src.testers.objects.generators.TestObjectSetGenerator;
|
||||
import speiger.src.testers.objects.builder.ObjectOrderedSetTestSuiteBuilder;
|
||||
import speiger.src.testers.objects.generators.TestObjectOrderedSetGenerator;
|
||||
#endif
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public class ORDERED_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE extends MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE
|
||||
{
|
||||
public static GENERIC_KEY_VALUE_BRACES ORDERED_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE using(TEST_ORDERED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE generator) {
|
||||
return (ORDERED_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE) new ORDERED_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE().usingGenerator(generator);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("rawtypes")
|
||||
protected List<Class<? extends AbstractTester>> getTesters() {
|
||||
List<Class<? extends AbstractTester>> testers = super.getTesters();
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEOrderedMapMoveTester.class);
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEOrderedMapNavigationTester.class);
|
||||
return testers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TestSuite createTestSuite() {
|
||||
#ignore
|
||||
withFeatures(CollectionFeature.KNOWN_ORDER);
|
||||
#endignore
|
||||
return super.createTestSuite();
|
||||
}
|
||||
|
||||
protected ObjectSetTestSuiteBuilder<MAP.Entry KEY_VALUE_GENERIC_TYPE> createDerivedEntrySetSuite(TestObjectSetGenerator<MAP.Entry KEY_VALUE_GENERIC_TYPE> entrySetGenerator) {
|
||||
return ObjectOrderedSetTestSuiteBuilder.using((TestObjectOrderedSetGenerator<MAP.Entry KEY_VALUE_GENERIC_TYPE>)entrySetGenerator);
|
||||
}
|
||||
|
||||
protected SET_TEST_BUILDER KEY_GENERIC_TYPE createDerivedKeySetSuite(TEST_SET_GENERATOR KEY_GENERIC_TYPE generator) {
|
||||
return ORDERED_SET_TEST_BUILDER.using((TEST_ORDERED_SET_GENERATOR KEY_GENERIC_TYPE)generator);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,90 +1,90 @@
|
|||
package speiger.src.testers.PACKAGE.builder.maps;
|
||||
|
||||
#ignore
|
||||
import static com.google.common.collect.testing.features.CollectionFeature.KNOWN_ORDER;
|
||||
#endignore
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.testing.AbstractTester;
|
||||
import com.google.common.collect.testing.DerivedCollectionGenerators.Bound;
|
||||
import com.google.common.collect.testing.FeatureSpecificTestSuiteBuilder;
|
||||
import com.google.common.collect.testing.Helpers;
|
||||
import com.google.common.collect.testing.OneSizeTestContainerGenerator;
|
||||
import com.google.common.collect.testing.features.Feature;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
import speiger.src.testers.PACKAGE.generators.maps.TEST_SORTED_MAP_GENERATOR;
|
||||
import speiger.src.testers.PACKAGE.impl.maps.DERIVED_MAP_GENERATORS;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPESortedMapNavigationTester;
|
||||
import speiger.src.testers.PACKAGE.builder.SET_TEST_BUILDER;
|
||||
import speiger.src.testers.PACKAGE.builder.SORTED_SET_TEST_BUILDER;
|
||||
import speiger.src.testers.PACKAGE.generators.TEST_SET_GENERATOR;
|
||||
import speiger.src.testers.PACKAGE.generators.TEST_SORTED_SET_GENERATOR;
|
||||
import speiger.src.testers.utils.SpecialFeature;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public class SORTED_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE extends MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE {
|
||||
public static GENERIC_KEY_VALUE_BRACES SORTED_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE using(TEST_SORTED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE generator) {
|
||||
return (SORTED_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE) new SORTED_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE().usingGenerator(generator);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("rawtypes")
|
||||
protected List<Class<? extends AbstractTester>> getTesters() {
|
||||
List<Class<? extends AbstractTester>> testers = super.getTesters();
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPESortedMapNavigationTester.class);
|
||||
return testers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TestSuite createTestSuite() {
|
||||
#ignore
|
||||
if (!getFeatures().contains(KNOWN_ORDER)) {
|
||||
List<Feature<?>> features = Helpers.copyToList(getFeatures());
|
||||
features.add(KNOWN_ORDER);
|
||||
withFeatures(features);
|
||||
}
|
||||
#endignore
|
||||
return super.createTestSuite();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<TestSuite> createDerivedSuites(FeatureSpecificTestSuiteBuilder<?, ? extends OneSizeTestContainerGenerator<Map<CLASS_TYPE, CLASS_VALUE_TYPE>, Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>>> parentBuilder) {
|
||||
List<TestSuite> derivedSuites = super.createDerivedSuites(parentBuilder);
|
||||
#ignore
|
||||
if (!parentBuilder.getFeatures().contains(SpecialFeature.SUBMAP)) {
|
||||
derivedSuites.add(createSubmapSuite(parentBuilder, Bound.NO_BOUND, Bound.EXCLUSIVE));
|
||||
derivedSuites.add(createSubmapSuite(parentBuilder, Bound.INCLUSIVE, Bound.NO_BOUND));
|
||||
derivedSuites.add(createSubmapSuite(parentBuilder, Bound.INCLUSIVE, Bound.EXCLUSIVE));
|
||||
}
|
||||
#endignore
|
||||
return derivedSuites;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SET_TEST_BUILDER KEY_GENERIC_TYPE createDerivedKeySetSuite(TEST_SET_GENERATOR KEY_GENERIC_TYPE keySetGenerator) {
|
||||
return keySetGenerator instanceof TEST_SORTED_SET_GENERATOR ? SORTED_SET_TEST_BUILDER.using((TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE) keySetGenerator) : SET_TEST_BUILDER.using(keySetGenerator);
|
||||
}
|
||||
|
||||
TestSuite createSubmapSuite(FeatureSpecificTestSuiteBuilder<?, ? extends OneSizeTestContainerGenerator<Map<CLASS_TYPE, CLASS_VALUE_TYPE>, Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>>> parentBuilder, Bound from, Bound to) {
|
||||
TEST_SORTED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE delegate = (TEST_SORTED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE) parentBuilder.getSubjectGenerator().getInnerGenerator();
|
||||
List<Feature<?>> features = new ArrayList<>();
|
||||
#ignore
|
||||
features.add(SpecialFeature.SUBMAP);
|
||||
features.addAll(parentBuilder.getFeatures());
|
||||
features.remove(SpecialFeature.COPYING);
|
||||
features.remove(SpecialFeature.CHILDREN_COPY);
|
||||
#endignore
|
||||
|
||||
return newBuilderUsing(delegate, to, from).named(parentBuilder.getName() + " subMap " + from + "-" + to)
|
||||
.withFeatures(features).suppressing(parentBuilder.getSuppressedTests())
|
||||
.withSetUp(parentBuilder.getSetUp()).withTearDown(parentBuilder.getTearDown()).createTestSuite();
|
||||
}
|
||||
|
||||
SORTED_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE newBuilderUsing(TEST_SORTED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE delegate, Bound to, Bound from) {
|
||||
return using(new DERIVED_MAP_GENERATORS.SortedMapGeneratorKV_BRACES(delegate, to, from));
|
||||
}
|
||||
}
|
||||
package speiger.src.testers.PACKAGE.builder.maps;
|
||||
|
||||
#ignore
|
||||
import static com.google.common.collect.testing.features.CollectionFeature.KNOWN_ORDER;
|
||||
#endignore
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.testing.AbstractTester;
|
||||
import com.google.common.collect.testing.DerivedCollectionGenerators.Bound;
|
||||
import com.google.common.collect.testing.FeatureSpecificTestSuiteBuilder;
|
||||
import com.google.common.collect.testing.Helpers;
|
||||
import com.google.common.collect.testing.OneSizeTestContainerGenerator;
|
||||
import com.google.common.collect.testing.features.Feature;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
import speiger.src.testers.PACKAGE.generators.maps.TEST_SORTED_MAP_GENERATOR;
|
||||
import speiger.src.testers.PACKAGE.impl.maps.DERIVED_MAP_GENERATORS;
|
||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPESortedMapNavigationTester;
|
||||
import speiger.src.testers.PACKAGE.builder.SET_TEST_BUILDER;
|
||||
import speiger.src.testers.PACKAGE.builder.SORTED_SET_TEST_BUILDER;
|
||||
import speiger.src.testers.PACKAGE.generators.TEST_SET_GENERATOR;
|
||||
import speiger.src.testers.PACKAGE.generators.TEST_SORTED_SET_GENERATOR;
|
||||
import speiger.src.testers.utils.SpecialFeature;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public class SORTED_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE extends MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE {
|
||||
public static GENERIC_KEY_VALUE_BRACES SORTED_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE using(TEST_SORTED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE generator) {
|
||||
return (SORTED_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE) new SORTED_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE().usingGenerator(generator);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("rawtypes")
|
||||
protected List<Class<? extends AbstractTester>> getTesters() {
|
||||
List<Class<? extends AbstractTester>> testers = super.getTesters();
|
||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPESortedMapNavigationTester.class);
|
||||
return testers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TestSuite createTestSuite() {
|
||||
#ignore
|
||||
if (!getFeatures().contains(KNOWN_ORDER)) {
|
||||
List<Feature<?>> features = Helpers.copyToList(getFeatures());
|
||||
features.add(KNOWN_ORDER);
|
||||
withFeatures(features);
|
||||
}
|
||||
#endignore
|
||||
return super.createTestSuite();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<TestSuite> createDerivedSuites(FeatureSpecificTestSuiteBuilder<?, ? extends OneSizeTestContainerGenerator<Map<CLASS_TYPE, CLASS_VALUE_TYPE>, Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>>> parentBuilder) {
|
||||
List<TestSuite> derivedSuites = super.createDerivedSuites(parentBuilder);
|
||||
#ignore
|
||||
if (!parentBuilder.getFeatures().contains(SpecialFeature.SUBMAP)) {
|
||||
derivedSuites.add(createSubmapSuite(parentBuilder, Bound.NO_BOUND, Bound.EXCLUSIVE));
|
||||
derivedSuites.add(createSubmapSuite(parentBuilder, Bound.INCLUSIVE, Bound.NO_BOUND));
|
||||
derivedSuites.add(createSubmapSuite(parentBuilder, Bound.INCLUSIVE, Bound.EXCLUSIVE));
|
||||
}
|
||||
#endignore
|
||||
return derivedSuites;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SET_TEST_BUILDER KEY_GENERIC_TYPE createDerivedKeySetSuite(TEST_SET_GENERATOR KEY_GENERIC_TYPE keySetGenerator) {
|
||||
return keySetGenerator instanceof TEST_SORTED_SET_GENERATOR ? SORTED_SET_TEST_BUILDER.using((TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE) keySetGenerator) : SET_TEST_BUILDER.using(keySetGenerator);
|
||||
}
|
||||
|
||||
TestSuite createSubmapSuite(FeatureSpecificTestSuiteBuilder<?, ? extends OneSizeTestContainerGenerator<Map<CLASS_TYPE, CLASS_VALUE_TYPE>, Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>>> parentBuilder, Bound from, Bound to) {
|
||||
TEST_SORTED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE delegate = (TEST_SORTED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE) parentBuilder.getSubjectGenerator().getInnerGenerator();
|
||||
List<Feature<?>> features = new ArrayList<>();
|
||||
#ignore
|
||||
features.add(SpecialFeature.SUBMAP);
|
||||
features.addAll(parentBuilder.getFeatures());
|
||||
features.remove(SpecialFeature.COPYING);
|
||||
features.remove(SpecialFeature.CHILDREN_COPY);
|
||||
#endignore
|
||||
|
||||
return newBuilderUsing(delegate, to, from).named(parentBuilder.getName() + " subMap " + from + "-" + to)
|
||||
.withFeatures(features).suppressing(parentBuilder.getSuppressedTests())
|
||||
.withSetUp(parentBuilder.getSetUp()).withTearDown(parentBuilder.getTearDown()).createTestSuite();
|
||||
}
|
||||
|
||||
SORTED_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE newBuilderUsing(TEST_SORTED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE delegate, Bound to, Bound from) {
|
||||
return using(new DERIVED_MAP_GENERATORS.SortedMapGeneratorKV_BRACES(delegate, to, from));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,30 +1,30 @@
|
|||
package speiger.src.testers.PACKAGE.generators;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.testing.SampleElements;
|
||||
import com.google.common.collect.testing.TestCollectionGenerator;
|
||||
|
||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||
import speiger.src.collections.PACKAGE.collections.ITERABLE;
|
||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||
import speiger.src.testers.PACKAGE.utils.SAMPLE_ELEMENTS;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public interface TEST_COLLECTION_GENERATOR KEY_GENERIC_TYPE extends TestCollectionGenerator<CLASS_TYPE>
|
||||
{
|
||||
public SAMPLE_ELEMENTS KEY_GENERIC_TYPE getSamples();
|
||||
#if !TYPE_OBJECT
|
||||
public COLLECTION KEY_GENERIC_TYPE create(KEY_TYPE...elements);
|
||||
#endif
|
||||
public ITERABLE KEY_GENERIC_TYPE order(LIST KEY_GENERIC_TYPE insertionOrder);
|
||||
|
||||
@Override
|
||||
public default SampleElements<CLASS_TYPE> samples() {return getSamples().toSamples();}
|
||||
@Override
|
||||
public COLLECTION KEY_GENERIC_TYPE create(Object... elements);
|
||||
@Override
|
||||
public default CLASS_TYPE[] createArray(int length) { return NEW_CLASS_ARRAY(length); }
|
||||
@Override
|
||||
public Iterable<CLASS_TYPE> order(List<CLASS_TYPE> insertionOrder);
|
||||
}
|
||||
package speiger.src.testers.PACKAGE.generators;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.testing.SampleElements;
|
||||
import com.google.common.collect.testing.TestCollectionGenerator;
|
||||
|
||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||
import speiger.src.collections.PACKAGE.collections.ITERABLE;
|
||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||
import speiger.src.testers.PACKAGE.utils.SAMPLE_ELEMENTS;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public interface TEST_COLLECTION_GENERATOR KEY_GENERIC_TYPE extends TestCollectionGenerator<CLASS_TYPE>
|
||||
{
|
||||
public SAMPLE_ELEMENTS KEY_GENERIC_TYPE getSamples();
|
||||
#if !TYPE_OBJECT
|
||||
public COLLECTION KEY_GENERIC_TYPE create(KEY_TYPE...elements);
|
||||
#endif
|
||||
public ITERABLE KEY_GENERIC_TYPE order(LIST KEY_GENERIC_TYPE insertionOrder);
|
||||
|
||||
@Override
|
||||
public default SampleElements<CLASS_TYPE> samples() {return getSamples().toSamples();}
|
||||
@Override
|
||||
public COLLECTION KEY_GENERIC_TYPE create(Object... elements);
|
||||
@Override
|
||||
public default CLASS_TYPE[] createArray(int length) { return NEW_CLASS_ARRAY(length); }
|
||||
@Override
|
||||
public Iterable<CLASS_TYPE> order(List<CLASS_TYPE> insertionOrder);
|
||||
}
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
package speiger.src.testers.PACKAGE.generators;
|
||||
|
||||
import com.google.common.collect.testing.TestListGenerator;
|
||||
|
||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public interface TEST_LIST_GENERATOR KEY_GENERIC_TYPE extends TestListGenerator<CLASS_TYPE>, TEST_COLLECTION_GENERATOR KEY_GENERIC_TYPE
|
||||
{
|
||||
@Override
|
||||
LIST KEY_GENERIC_TYPE create(Object... elements);
|
||||
#if !TYPE_OBJECT
|
||||
@Override
|
||||
LIST KEY_GENERIC_TYPE create(KEY_TYPE... elements);
|
||||
#endif
|
||||
}
|
||||
package speiger.src.testers.PACKAGE.generators;
|
||||
|
||||
import com.google.common.collect.testing.TestListGenerator;
|
||||
|
||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public interface TEST_LIST_GENERATOR KEY_GENERIC_TYPE extends TestListGenerator<CLASS_TYPE>, TEST_COLLECTION_GENERATOR KEY_GENERIC_TYPE
|
||||
{
|
||||
@Override
|
||||
LIST KEY_GENERIC_TYPE create(Object... elements);
|
||||
#if !TYPE_OBJECT
|
||||
@Override
|
||||
LIST KEY_GENERIC_TYPE create(KEY_TYPE... elements);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package speiger.src.testers.PACKAGE.generators;
|
||||
|
||||
import speiger.src.collections.PACKAGE.sets.NAVIGABLE_SET;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public interface TEST_NAVIGABLE_SET_GENERATOR KEY_GENERIC_TYPE extends TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE {
|
||||
#if !TYPE_OBJECT
|
||||
@Override
|
||||
NAVIGABLE_SET KEY_GENERIC_TYPE create(KEY_TYPE... elements);
|
||||
#endif
|
||||
@Override
|
||||
NAVIGABLE_SET KEY_GENERIC_TYPE create(Object... elements);
|
||||
}
|
||||
package speiger.src.testers.PACKAGE.generators;
|
||||
|
||||
import speiger.src.collections.PACKAGE.sets.NAVIGABLE_SET;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public interface TEST_NAVIGABLE_SET_GENERATOR KEY_GENERIC_TYPE extends TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE {
|
||||
#if !TYPE_OBJECT
|
||||
@Override
|
||||
NAVIGABLE_SET KEY_GENERIC_TYPE create(KEY_TYPE... elements);
|
||||
#endif
|
||||
@Override
|
||||
NAVIGABLE_SET KEY_GENERIC_TYPE create(Object... elements);
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package speiger.src.testers.PACKAGE.generators;
|
||||
|
||||
import speiger.src.collections.PACKAGE.sets.ORDERED_SET;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public interface TEST_ORDERED_SET_GENERATOR KEY_GENERIC_TYPE extends TEST_SET_GENERATOR KEY_GENERIC_TYPE {
|
||||
#if !TYPE_OBJECT
|
||||
@Override
|
||||
ORDERED_SET KEY_GENERIC_TYPE create(KEY_TYPE... elements);
|
||||
#endif
|
||||
@Override
|
||||
ORDERED_SET KEY_GENERIC_TYPE create(Object... elements);
|
||||
}
|
||||
package speiger.src.testers.PACKAGE.generators;
|
||||
|
||||
import speiger.src.collections.PACKAGE.sets.ORDERED_SET;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public interface TEST_ORDERED_SET_GENERATOR KEY_GENERIC_TYPE extends TEST_SET_GENERATOR KEY_GENERIC_TYPE {
|
||||
#if !TYPE_OBJECT
|
||||
@Override
|
||||
ORDERED_SET KEY_GENERIC_TYPE create(KEY_TYPE... elements);
|
||||
#endif
|
||||
@Override
|
||||
ORDERED_SET KEY_GENERIC_TYPE create(Object... elements);
|
||||
}
|
||||
|
|
|
@ -1,30 +1,30 @@
|
|||
package speiger.src.testers.PACKAGE.generators;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.testing.SampleElements;
|
||||
import com.google.common.collect.testing.TestContainerGenerator;
|
||||
|
||||
import speiger.src.collections.PACKAGE.queues.PRIORITY_QUEUE;
|
||||
import speiger.src.collections.PACKAGE.collections.ITERABLE;
|
||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||
import speiger.src.testers.PACKAGE.utils.SAMPLE_ELEMENTS;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public interface TEST_QUEUE_GENERATOR KEY_GENERIC_TYPE extends TestContainerGenerator<PRIORITY_QUEUE KEY_GENERIC_TYPE, CLASS_TYPE>
|
||||
{
|
||||
public SAMPLE_ELEMENTS KEY_GENERIC_TYPE getSamples();
|
||||
#if !TYPE_OBJECT
|
||||
public PRIORITY_QUEUE KEY_GENERIC_TYPE create(KEY_TYPE...elements);
|
||||
#endif
|
||||
public ITERABLE KEY_GENERIC_TYPE order(LIST KEY_GENERIC_TYPE insertionOrder);
|
||||
|
||||
@Override
|
||||
public default SampleElements<CLASS_TYPE> samples() {return getSamples().toSamples();}
|
||||
@Override
|
||||
public PRIORITY_QUEUE KEY_GENERIC_TYPE create(Object... elements);
|
||||
@Override
|
||||
public default CLASS_TYPE[] createArray(int length) { return NEW_CLASS_ARRAY(length); }
|
||||
@Override
|
||||
public Iterable<CLASS_TYPE> order(List<CLASS_TYPE> insertionOrder);
|
||||
}
|
||||
package speiger.src.testers.PACKAGE.generators;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.testing.SampleElements;
|
||||
import com.google.common.collect.testing.TestContainerGenerator;
|
||||
|
||||
import speiger.src.collections.PACKAGE.queues.PRIORITY_QUEUE;
|
||||
import speiger.src.collections.PACKAGE.collections.ITERABLE;
|
||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||
import speiger.src.testers.PACKAGE.utils.SAMPLE_ELEMENTS;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public interface TEST_QUEUE_GENERATOR KEY_GENERIC_TYPE extends TestContainerGenerator<PRIORITY_QUEUE KEY_GENERIC_TYPE, CLASS_TYPE>
|
||||
{
|
||||
public SAMPLE_ELEMENTS KEY_GENERIC_TYPE getSamples();
|
||||
#if !TYPE_OBJECT
|
||||
public PRIORITY_QUEUE KEY_GENERIC_TYPE create(KEY_TYPE...elements);
|
||||
#endif
|
||||
public ITERABLE KEY_GENERIC_TYPE order(LIST KEY_GENERIC_TYPE insertionOrder);
|
||||
|
||||
@Override
|
||||
public default SampleElements<CLASS_TYPE> samples() {return getSamples().toSamples();}
|
||||
@Override
|
||||
public PRIORITY_QUEUE KEY_GENERIC_TYPE create(Object... elements);
|
||||
@Override
|
||||
public default CLASS_TYPE[] createArray(int length) { return NEW_CLASS_ARRAY(length); }
|
||||
@Override
|
||||
public Iterable<CLASS_TYPE> order(List<CLASS_TYPE> insertionOrder);
|
||||
}
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
package speiger.src.testers.PACKAGE.generators;
|
||||
|
||||
import com.google.common.collect.testing.TestSetGenerator;
|
||||
|
||||
import speiger.src.collections.PACKAGE.sets.SET;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public interface TEST_SET_GENERATOR KEY_GENERIC_TYPE extends TEST_COLLECTION_GENERATOR KEY_GENERIC_TYPE, TestSetGenerator<CLASS_TYPE> {
|
||||
#if !TYPE_OBJECT
|
||||
@Override
|
||||
SET KEY_GENERIC_TYPE create(KEY_TYPE...elements);
|
||||
#endif
|
||||
@Override
|
||||
SET KEY_GENERIC_TYPE create(Object...elements);
|
||||
}
|
||||
package speiger.src.testers.PACKAGE.generators;
|
||||
|
||||
import com.google.common.collect.testing.TestSetGenerator;
|
||||
|
||||
import speiger.src.collections.PACKAGE.sets.SET;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public interface TEST_SET_GENERATOR KEY_GENERIC_TYPE extends TEST_COLLECTION_GENERATOR KEY_GENERIC_TYPE, TestSetGenerator<CLASS_TYPE> {
|
||||
#if !TYPE_OBJECT
|
||||
@Override
|
||||
SET KEY_GENERIC_TYPE create(KEY_TYPE...elements);
|
||||
#endif
|
||||
@Override
|
||||
SET KEY_GENERIC_TYPE create(Object...elements);
|
||||
}
|
||||
|
|
|
@ -1,38 +1,38 @@
|
|||
package speiger.src.testers.PACKAGE.generators;
|
||||
|
||||
import speiger.src.collections.PACKAGE.sets.SORTED_SET;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public interface TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE extends TEST_SET_GENERATOR KEY_GENERIC_TYPE {
|
||||
#if !TYPE_OBJECT
|
||||
@Override
|
||||
SORTED_SET KEY_GENERIC_TYPE create(KEY_TYPE... elements);
|
||||
#endif
|
||||
@Override
|
||||
SORTED_SET KEY_GENERIC_TYPE create(Object... elements);
|
||||
|
||||
|
||||
/**
|
||||
* Returns an element less than the {@link #samples()} and less than {@link
|
||||
* #belowSamplesGreater()}.
|
||||
*/
|
||||
KEY_TYPE belowSamplesLesser();
|
||||
|
||||
/**
|
||||
* Returns an element less than the {@link #samples()} but greater than {@link
|
||||
* #belowSamplesLesser()}.
|
||||
*/
|
||||
KEY_TYPE belowSamplesGreater();
|
||||
|
||||
/**
|
||||
* Returns an element greater than the {@link #samples()} but less than {@link
|
||||
* #aboveSamplesGreater()}.
|
||||
*/
|
||||
KEY_TYPE aboveSamplesLesser();
|
||||
|
||||
/**
|
||||
* Returns an element greater than the {@link #samples()} and greater than {@link
|
||||
* #aboveSamplesLesser()}.
|
||||
*/
|
||||
KEY_TYPE aboveSamplesGreater();
|
||||
}
|
||||
package speiger.src.testers.PACKAGE.generators;
|
||||
|
||||
import speiger.src.collections.PACKAGE.sets.SORTED_SET;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public interface TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE extends TEST_SET_GENERATOR KEY_GENERIC_TYPE {
|
||||
#if !TYPE_OBJECT
|
||||
@Override
|
||||
SORTED_SET KEY_GENERIC_TYPE create(KEY_TYPE... elements);
|
||||
#endif
|
||||
@Override
|
||||
SORTED_SET KEY_GENERIC_TYPE create(Object... elements);
|
||||
|
||||
|
||||
/**
|
||||
* Returns an element less than the {@link #samples()} and less than {@link
|
||||
* #belowSamplesGreater()}.
|
||||
*/
|
||||
KEY_TYPE belowSamplesLesser();
|
||||
|
||||
/**
|
||||
* Returns an element less than the {@link #samples()} but greater than {@link
|
||||
* #belowSamplesLesser()}.
|
||||
*/
|
||||
KEY_TYPE belowSamplesGreater();
|
||||
|
||||
/**
|
||||
* Returns an element greater than the {@link #samples()} but less than {@link
|
||||
* #aboveSamplesGreater()}.
|
||||
*/
|
||||
KEY_TYPE aboveSamplesLesser();
|
||||
|
||||
/**
|
||||
* Returns an element greater than the {@link #samples()} and greater than {@link
|
||||
* #aboveSamplesLesser()}.
|
||||
*/
|
||||
KEY_TYPE aboveSamplesGreater();
|
||||
}
|
||||
|
|
|
@ -1,46 +1,46 @@
|
|||
package speiger.src.testers.PACKAGE.generators.maps;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.testing.Helpers;
|
||||
import com.google.common.collect.testing.SampleElements;
|
||||
import com.google.common.collect.testing.TestMapGenerator;
|
||||
|
||||
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
||||
import speiger.src.collections.objects.collections.ObjectIterable;
|
||||
import speiger.src.collections.objects.lists.ObjectList;
|
||||
import speiger.src.testers.objects.utils.ObjectSamples;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public interface TEST_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE extends TestMapGenerator<CLASS_TYPE, CLASS_VALUE_TYPE> {
|
||||
public ObjectSamples<MAP.Entry KEY_VALUE_GENERIC_TYPE> getSamples();
|
||||
public ObjectIterable<MAP.Entry KEY_VALUE_GENERIC_TYPE> order(ObjectList<MAP.Entry KEY_VALUE_GENERIC_TYPE> insertionOrder);
|
||||
public MAP KEY_VALUE_GENERIC_TYPE create(MAP.Entry KEY_VALUE_GENERIC_TYPE... elements);
|
||||
@Override
|
||||
default MAP KEY_VALUE_GENERIC_TYPE create(Object... elements) {
|
||||
MAP.Entry KEY_VALUE_GENERIC_TYPE[] result = new MAP.Entry[elements.length];
|
||||
for(int i = 0;i<elements.length;i++) {
|
||||
result[i] = (MAP.Entry KEY_VALUE_GENERIC_TYPE) elements[i];
|
||||
}
|
||||
return create(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
default CLASS_TYPE[] createKeyArray(int length) { return NEW_CLASS_ARRAY(length); }
|
||||
@Override
|
||||
default CLASS_VALUE_TYPE[] createValueArray(int length) { return NEW_CLASS_VALUE_ARRAY(length); }
|
||||
@Override
|
||||
default MAP.Entry KEY_VALUE_GENERIC_TYPE[] createArray(int length) { return new MAP.Entry[length]; }
|
||||
|
||||
@Override
|
||||
default SampleElements<Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>> samples() {
|
||||
ObjectSamples<MAP.Entry KEY_VALUE_GENERIC_TYPE> samples = getSamples();
|
||||
return new SampleElements<>(
|
||||
Helpers.mapEntry(samples.e0().ENTRY_KEY(), samples.e0().ENTRY_VALUE()),
|
||||
Helpers.mapEntry(samples.e1().ENTRY_KEY(), samples.e1().ENTRY_VALUE()),
|
||||
Helpers.mapEntry(samples.e2().ENTRY_KEY(), samples.e2().ENTRY_VALUE()),
|
||||
Helpers.mapEntry(samples.e3().ENTRY_KEY(), samples.e3().ENTRY_VALUE()),
|
||||
Helpers.mapEntry(samples.e4().ENTRY_KEY(), samples.e4().ENTRY_VALUE())
|
||||
);
|
||||
}
|
||||
}
|
||||
package speiger.src.testers.PACKAGE.generators.maps;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.testing.Helpers;
|
||||
import com.google.common.collect.testing.SampleElements;
|
||||
import com.google.common.collect.testing.TestMapGenerator;
|
||||
|
||||
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
||||
import speiger.src.collections.objects.collections.ObjectIterable;
|
||||
import speiger.src.collections.objects.lists.ObjectList;
|
||||
import speiger.src.testers.objects.utils.ObjectSamples;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public interface TEST_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE extends TestMapGenerator<CLASS_TYPE, CLASS_VALUE_TYPE> {
|
||||
public ObjectSamples<MAP.Entry KEY_VALUE_GENERIC_TYPE> getSamples();
|
||||
public ObjectIterable<MAP.Entry KEY_VALUE_GENERIC_TYPE> order(ObjectList<MAP.Entry KEY_VALUE_GENERIC_TYPE> insertionOrder);
|
||||
public MAP KEY_VALUE_GENERIC_TYPE create(MAP.Entry KEY_VALUE_GENERIC_TYPE... elements);
|
||||
@Override
|
||||
default MAP KEY_VALUE_GENERIC_TYPE create(Object... elements) {
|
||||
MAP.Entry KEY_VALUE_GENERIC_TYPE[] result = new MAP.Entry[elements.length];
|
||||
for(int i = 0;i<elements.length;i++) {
|
||||
result[i] = (MAP.Entry KEY_VALUE_GENERIC_TYPE) elements[i];
|
||||
}
|
||||
return create(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
default CLASS_TYPE[] createKeyArray(int length) { return NEW_CLASS_ARRAY(length); }
|
||||
@Override
|
||||
default CLASS_VALUE_TYPE[] createValueArray(int length) { return NEW_CLASS_VALUE_ARRAY(length); }
|
||||
@Override
|
||||
default MAP.Entry KEY_VALUE_GENERIC_TYPE[] createArray(int length) { return new MAP.Entry[length]; }
|
||||
|
||||
@Override
|
||||
default SampleElements<Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>> samples() {
|
||||
ObjectSamples<MAP.Entry KEY_VALUE_GENERIC_TYPE> samples = getSamples();
|
||||
return new SampleElements<>(
|
||||
Helpers.mapEntry(samples.e0().ENTRY_KEY(), samples.e0().ENTRY_VALUE()),
|
||||
Helpers.mapEntry(samples.e1().ENTRY_KEY(), samples.e1().ENTRY_VALUE()),
|
||||
Helpers.mapEntry(samples.e2().ENTRY_KEY(), samples.e2().ENTRY_VALUE()),
|
||||
Helpers.mapEntry(samples.e3().ENTRY_KEY(), samples.e3().ENTRY_VALUE()),
|
||||
Helpers.mapEntry(samples.e4().ENTRY_KEY(), samples.e4().ENTRY_VALUE())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package speiger.src.testers.PACKAGE.generators.maps;
|
||||
|
||||
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
||||
import speiger.src.collections.PACKAGE.maps.interfaces.ORDERED_MAP;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public interface TEST_ORDERED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE extends TEST_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE
|
||||
{
|
||||
@Override
|
||||
default ORDERED_MAP KEY_VALUE_GENERIC_TYPE create(Object... elements) { return (ORDERED_MAP KEY_VALUE_GENERIC_TYPE) TEST_MAP_GENERATOR.super.create(elements); }
|
||||
@Override
|
||||
ORDERED_MAP KEY_VALUE_GENERIC_TYPE create(MAP.Entry KEY_VALUE_GENERIC_TYPE... elements);
|
||||
}
|
||||
package speiger.src.testers.PACKAGE.generators.maps;
|
||||
|
||||
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
||||
import speiger.src.collections.PACKAGE.maps.interfaces.ORDERED_MAP;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public interface TEST_ORDERED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE extends TEST_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE
|
||||
{
|
||||
@Override
|
||||
default ORDERED_MAP KEY_VALUE_GENERIC_TYPE create(Object... elements) { return (ORDERED_MAP KEY_VALUE_GENERIC_TYPE) TEST_MAP_GENERATOR.super.create(elements); }
|
||||
@Override
|
||||
ORDERED_MAP KEY_VALUE_GENERIC_TYPE create(MAP.Entry KEY_VALUE_GENERIC_TYPE... elements);
|
||||
}
|
||||
|
|
|
@ -1,25 +1,25 @@
|
|||
package speiger.src.testers.PACKAGE.generators.maps;
|
||||
|
||||
import com.google.common.collect.testing.TestSortedMapGenerator;
|
||||
|
||||
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
||||
import speiger.src.collections.PACKAGE.maps.interfaces.MAP.Entry;
|
||||
import speiger.src.collections.PACKAGE.maps.interfaces.SORTED_MAP;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public interface TEST_SORTED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE extends TEST_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE, TestSortedMapGenerator<CLASS_TYPE, CLASS_VALUE_TYPE>
|
||||
{
|
||||
@Override
|
||||
default SORTED_MAP KEY_VALUE_GENERIC_TYPE create(Object... elements) { return (SORTED_MAP KEY_VALUE_GENERIC_TYPE) TEST_MAP_GENERATOR.super.create(elements); }
|
||||
@Override
|
||||
SORTED_MAP KEY_VALUE_GENERIC_TYPE create(MAP.Entry KEY_VALUE_GENERIC_TYPE... elements);
|
||||
|
||||
@Override
|
||||
Entry KEY_VALUE_GENERIC_TYPE belowSamplesLesser();
|
||||
@Override
|
||||
Entry KEY_VALUE_GENERIC_TYPE belowSamplesGreater();
|
||||
@Override
|
||||
Entry KEY_VALUE_GENERIC_TYPE aboveSamplesLesser();
|
||||
@Override
|
||||
Entry KEY_VALUE_GENERIC_TYPE aboveSamplesGreater();
|
||||
}
|
||||
package speiger.src.testers.PACKAGE.generators.maps;
|
||||
|
||||
import com.google.common.collect.testing.TestSortedMapGenerator;
|
||||
|
||||
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
||||
import speiger.src.collections.PACKAGE.maps.interfaces.MAP.Entry;
|
||||
import speiger.src.collections.PACKAGE.maps.interfaces.SORTED_MAP;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public interface TEST_SORTED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE extends TEST_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE, TestSortedMapGenerator<CLASS_TYPE, CLASS_VALUE_TYPE>
|
||||
{
|
||||
@Override
|
||||
default SORTED_MAP KEY_VALUE_GENERIC_TYPE create(Object... elements) { return (SORTED_MAP KEY_VALUE_GENERIC_TYPE) TEST_MAP_GENERATOR.super.create(elements); }
|
||||
@Override
|
||||
SORTED_MAP KEY_VALUE_GENERIC_TYPE create(MAP.Entry KEY_VALUE_GENERIC_TYPE... elements);
|
||||
|
||||
@Override
|
||||
Entry KEY_VALUE_GENERIC_TYPE belowSamplesLesser();
|
||||
@Override
|
||||
Entry KEY_VALUE_GENERIC_TYPE belowSamplesGreater();
|
||||
@Override
|
||||
Entry KEY_VALUE_GENERIC_TYPE aboveSamplesLesser();
|
||||
@Override
|
||||
Entry KEY_VALUE_GENERIC_TYPE aboveSamplesGreater();
|
||||
}
|
||||
|
|
|
@ -1,314 +1,314 @@
|
|||
package speiger.src.testers.PACKAGE.impl;
|
||||
|
||||
#if TYPE_OBJECT
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.Objects;
|
||||
#endif
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
||||
import speiger.src.collections.PACKAGE.lists.LINKED_LIST;
|
||||
import speiger.src.collections.PACKAGE.lists.COPY_ON_WRITE_LIST;
|
||||
import speiger.src.collections.PACKAGE.lists.IMMUTABLE_LIST;
|
||||
#if !TYPE_BOOLEAN
|
||||
import speiger.src.collections.PACKAGE.sets.AVL_TREE_SET;
|
||||
import speiger.src.collections.PACKAGE.sets.ARRAY_SET;
|
||||
import speiger.src.collections.PACKAGE.sets.LINKED_CUSTOM_HASH_SET;
|
||||
import speiger.src.collections.PACKAGE.sets.LINKED_HASH_SET;
|
||||
import speiger.src.collections.PACKAGE.sets.CUSTOM_HASH_SET;
|
||||
import speiger.src.collections.PACKAGE.sets.HASH_SET;
|
||||
import speiger.src.collections.PACKAGE.sets.RB_TREE_SET;
|
||||
import speiger.src.collections.PACKAGE.sets.IMMUTABLE_HASH_SET;
|
||||
import speiger.src.collections.PACKAGE.utils.STRATEGY;
|
||||
#endif
|
||||
#if TYPE_OBJECT
|
||||
import speiger.src.collections.objects.utils.StringSortTest;
|
||||
#endif
|
||||
import speiger.src.testers.PACKAGE.tests.collection.FILE_KEY_TYPECollectionConstructorTester;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class COLLECTION_CONSTRUCTOR_TESTS
|
||||
{
|
||||
public static class ArrayList extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
||||
{
|
||||
@SuppressWarnings("deprecation")
|
||||
public ArrayList() {
|
||||
setSimpleConstructor(ARRAY_LIST::new);
|
||||
setSizeConstructor(T -> new ARRAY_LISTBRACES(T));
|
||||
setPArrayConstructor(T -> new ARRAY_LISTBRACES(T));
|
||||
setPCollectionConstructor(T -> new ARRAY_LISTBRACES(T));
|
||||
setCollectionConstructor(T -> new ARRAY_LISTBRACES(T));
|
||||
}
|
||||
|
||||
#if TYPE_OBJECT
|
||||
@Override
|
||||
protected String[] createKeyElements() {
|
||||
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public static class LinkedList extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
||||
{
|
||||
@SuppressWarnings("deprecation")
|
||||
public LinkedList() {
|
||||
setSimpleConstructor(LINKED_LIST::new);
|
||||
setPArrayConstructor(T -> new LINKED_LISTBRACES(T));
|
||||
setPCollectionConstructor(T -> new LINKED_LISTBRACES(T));
|
||||
setCollectionConstructor(T -> new LINKED_LISTBRACES(T));
|
||||
}
|
||||
|
||||
#if TYPE_OBJECT
|
||||
@Override
|
||||
protected String[] createKeyElements() {
|
||||
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public static class CopyOnWriteArrayList extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
||||
{
|
||||
@SuppressWarnings("deprecation")
|
||||
public CopyOnWriteArrayList() {
|
||||
setSimpleConstructor(COPY_ON_WRITE_LIST::new);
|
||||
setPArrayConstructor(T -> new COPY_ON_WRITE_LISTBRACES(T));
|
||||
setPCollectionConstructor(T -> new COPY_ON_WRITE_LISTBRACES(T));
|
||||
setCollectionConstructor(T -> new COPY_ON_WRITE_LISTBRACES(T));
|
||||
}
|
||||
|
||||
#if TYPE_OBJECT
|
||||
@Override
|
||||
protected String[] createKeyElements() {
|
||||
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public static class ImmutableList extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
||||
{
|
||||
@SuppressWarnings("deprecation")
|
||||
public ImmutableList() {
|
||||
setPArrayConstructor(T -> new IMMUTABLE_LISTBRACES(T));
|
||||
setPCollectionConstructor(T -> new IMMUTABLE_LISTBRACES(T));
|
||||
setCollectionConstructor(T -> new IMMUTABLE_LISTBRACES(T));
|
||||
}
|
||||
|
||||
#if TYPE_OBJECT
|
||||
@Override
|
||||
protected String[] createKeyElements() {
|
||||
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !TYPE_BOOLEAN
|
||||
public static class HashSet extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
||||
{
|
||||
@SuppressWarnings("deprecation")
|
||||
public HashSet() {
|
||||
setSimpleConstructor(HASH_SET::new);
|
||||
setSizeConstructor(T -> new HASH_SETBRACES(T));
|
||||
setPArrayConstructor(T -> new HASH_SETBRACES(T));
|
||||
setPCollectionConstructor(T -> new HASH_SETBRACES(T));
|
||||
setCollectionConstructor(T -> new HASH_SETBRACES(T));
|
||||
}
|
||||
|
||||
#if TYPE_OBJECT
|
||||
@Override
|
||||
protected String[] createKeyElements() {
|
||||
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public static class LinkedHashSet extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
||||
{
|
||||
@SuppressWarnings("deprecation")
|
||||
public LinkedHashSet() {
|
||||
setSimpleConstructor(LINKED_HASH_SET::new);
|
||||
setSizeConstructor(T -> new LINKED_HASH_SETBRACES(T));
|
||||
setPArrayConstructor(T -> new LINKED_HASH_SETBRACES(T));
|
||||
setPCollectionConstructor(T -> new LINKED_HASH_SETBRACES(T));
|
||||
setCollectionConstructor(T -> new LINKED_HASH_SETBRACES(T));
|
||||
}
|
||||
|
||||
#if TYPE_OBJECT
|
||||
@Override
|
||||
protected String[] createKeyElements() {
|
||||
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public static class CustomHashSet extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
||||
{
|
||||
@SuppressWarnings("deprecation")
|
||||
public CustomHashSet() {
|
||||
setSimpleConstructor(() -> new CUSTOM_HASH_SET KEY_STRING_GENERIC_TYPE(HashStrategy.INSTANCE));
|
||||
setSizeConstructor(T -> new CUSTOM_HASH_SET KEY_STRING_GENERIC_TYPE(T, HashStrategy.INSTANCE));
|
||||
setPArrayConstructor(T -> new CUSTOM_HASH_SET KEY_STRING_GENERIC_TYPE(T, HashStrategy.INSTANCE));
|
||||
setPCollectionConstructor(T -> new CUSTOM_HASH_SET KEY_STRING_GENERIC_TYPE(T, HashStrategy.INSTANCE));
|
||||
setCollectionConstructor(T -> new CUSTOM_HASH_SET KEY_STRING_GENERIC_TYPE(T, HashStrategy.INSTANCE));
|
||||
}
|
||||
|
||||
#if TYPE_OBJECT
|
||||
@Override
|
||||
protected String[] createKeyElements() {
|
||||
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public static class LinkedCustomHashSet extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
||||
{
|
||||
@SuppressWarnings("deprecation")
|
||||
public LinkedCustomHashSet() {
|
||||
setSimpleConstructor(() -> new LINKED_CUSTOM_HASH_SET KEY_STRING_GENERIC_TYPE(HashStrategy.INSTANCE));
|
||||
setSizeConstructor(T -> new LINKED_CUSTOM_HASH_SET KEY_STRING_GENERIC_TYPE(T, HashStrategy.INSTANCE));
|
||||
setPArrayConstructor(T -> new LINKED_CUSTOM_HASH_SET KEY_STRING_GENERIC_TYPE(T, HashStrategy.INSTANCE));
|
||||
setPCollectionConstructor(T -> new LINKED_CUSTOM_HASH_SET KEY_STRING_GENERIC_TYPE(T, HashStrategy.INSTANCE));
|
||||
setCollectionConstructor(T -> new LINKED_CUSTOM_HASH_SET KEY_STRING_GENERIC_TYPE(T, HashStrategy.INSTANCE));
|
||||
}
|
||||
|
||||
#if TYPE_OBJECT
|
||||
@Override
|
||||
protected String[] createKeyElements() {
|
||||
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public static class ImmutableHashSet extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
||||
{
|
||||
@SuppressWarnings("deprecation")
|
||||
public ImmutableHashSet() {
|
||||
setPArrayConstructor(T -> new IMMUTABLE_HASH_SETBRACES(T));
|
||||
setPCollectionConstructor(T -> new IMMUTABLE_HASH_SETBRACES(T));
|
||||
setCollectionConstructor(T -> new IMMUTABLE_HASH_SETBRACES(T));
|
||||
}
|
||||
|
||||
#if TYPE_OBJECT
|
||||
@Override
|
||||
protected String[] createKeyElements() {
|
||||
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public static class ArraySet extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
||||
{
|
||||
@SuppressWarnings("deprecation")
|
||||
public ArraySet() {
|
||||
setSimpleConstructor(ARRAY_SET::new);
|
||||
setSizeConstructor(T -> new ARRAY_SETBRACES(T));
|
||||
setPArrayConstructor(T -> new ARRAY_SETBRACES(T));
|
||||
setPCollectionConstructor(T -> new ARRAY_SETBRACES(T));
|
||||
setCollectionConstructor(T -> new ARRAY_SETBRACES(T));
|
||||
}
|
||||
|
||||
#if TYPE_OBJECT
|
||||
@Override
|
||||
protected String[] createKeyElements() {
|
||||
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public static class RBTreeSet extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
||||
{
|
||||
@SuppressWarnings("deprecation")
|
||||
public RBTreeSet() {
|
||||
setSimpleConstructor(RB_TREE_SET::new);
|
||||
setPArrayConstructor(T -> new RB_TREE_SETBRACES(T));
|
||||
setPCollectionConstructor(T -> new RB_TREE_SETBRACES(T));
|
||||
setCollectionConstructor(T -> new RB_TREE_SETBRACES(T));
|
||||
}
|
||||
|
||||
#if TYPE_OBJECT
|
||||
@Override
|
||||
protected String[] createKeyElements() {
|
||||
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public static class AVLTreeSet extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
||||
{
|
||||
@SuppressWarnings("deprecation")
|
||||
public AVLTreeSet() {
|
||||
setSimpleConstructor(AVL_TREE_SET::new);
|
||||
setPArrayConstructor(T -> new AVL_TREE_SETBRACES(T));
|
||||
setPCollectionConstructor(T -> new AVL_TREE_SETBRACES(T));
|
||||
setCollectionConstructor(T -> new AVL_TREE_SETBRACES(T));
|
||||
}
|
||||
|
||||
#if TYPE_OBJECT
|
||||
@Override
|
||||
protected String[] createKeyElements() {
|
||||
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public static class RBTreeSetComparator extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
||||
{
|
||||
@SuppressWarnings("deprecation")
|
||||
public RBTreeSetComparator() {
|
||||
#if TYPE_OBJECT
|
||||
setSimpleConstructor(() -> new RB_TREE_SET<String>(Comparator.naturalOrder()));
|
||||
setPArrayConstructor(T -> new RB_TREE_SET<>(T, Comparator.naturalOrder()));
|
||||
setPCollectionConstructor(T -> new RB_TREE_SET<>(T, Comparator.naturalOrder()));
|
||||
setCollectionConstructor(T -> new RB_TREE_SET<>(T, Comparator.naturalOrder()));
|
||||
#else
|
||||
setSimpleConstructor(() -> new RB_TREE_SET(CLASS_TYPE::compare));
|
||||
setPArrayConstructor(T -> new RB_TREE_SET(T, CLASS_TYPE::compare));
|
||||
setPCollectionConstructor(T -> new RB_TREE_SET(T, CLASS_TYPE::compare));
|
||||
setCollectionConstructor(T -> new RB_TREE_SET(T, CLASS_TYPE::compare));
|
||||
#endif
|
||||
}
|
||||
|
||||
#if TYPE_OBJECT
|
||||
@Override
|
||||
protected String[] createKeyElements() {
|
||||
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public static class AVLTreeSetComparator extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
||||
{
|
||||
@SuppressWarnings("deprecation")
|
||||
public AVLTreeSetComparator() {
|
||||
#if TYPE_OBJECT
|
||||
setSimpleConstructor(() -> new AVL_TREE_SET<String>(Comparator.naturalOrder()));
|
||||
setPArrayConstructor(T -> new AVL_TREE_SET<>(T, Comparator.naturalOrder()));
|
||||
setPCollectionConstructor(T -> new AVL_TREE_SET<>(T, Comparator.naturalOrder()));
|
||||
setCollectionConstructor(T -> new AVL_TREE_SET<>(T, Comparator.naturalOrder()));
|
||||
#else
|
||||
setSimpleConstructor(() -> new AVL_TREE_SET(CLASS_TYPE::compare));
|
||||
setPArrayConstructor(T -> new AVL_TREE_SET(T, CLASS_TYPE::compare));
|
||||
setPCollectionConstructor(T -> new AVL_TREE_SET(T, CLASS_TYPE::compare));
|
||||
setCollectionConstructor(T -> new AVL_TREE_SET(T, CLASS_TYPE::compare));
|
||||
#endif
|
||||
}
|
||||
|
||||
#if TYPE_OBJECT
|
||||
@Override
|
||||
protected String[] createKeyElements() {
|
||||
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
private static class HashStrategy implements STRATEGY KEY_STRING_GENERIC_TYPE {
|
||||
static final HashStrategy INSTANCE = new HashStrategy();
|
||||
@Override
|
||||
public int hashCode(KEY_STRING_TYPE o) { return KEY_TO_HASH(o); }
|
||||
@Override
|
||||
public boolean equals(KEY_STRING_TYPE key, KEY_STRING_TYPE value) { return KEY_EQUALS(key, value); }
|
||||
}
|
||||
#endif
|
||||
package speiger.src.testers.PACKAGE.impl;
|
||||
|
||||
#if TYPE_OBJECT
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.Objects;
|
||||
#endif
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
||||
import speiger.src.collections.PACKAGE.lists.LINKED_LIST;
|
||||
import speiger.src.collections.PACKAGE.lists.COPY_ON_WRITE_LIST;
|
||||
import speiger.src.collections.PACKAGE.lists.IMMUTABLE_LIST;
|
||||
#if !TYPE_BOOLEAN
|
||||
import speiger.src.collections.PACKAGE.sets.AVL_TREE_SET;
|
||||
import speiger.src.collections.PACKAGE.sets.ARRAY_SET;
|
||||
import speiger.src.collections.PACKAGE.sets.LINKED_CUSTOM_HASH_SET;
|
||||
import speiger.src.collections.PACKAGE.sets.LINKED_HASH_SET;
|
||||
import speiger.src.collections.PACKAGE.sets.CUSTOM_HASH_SET;
|
||||
import speiger.src.collections.PACKAGE.sets.HASH_SET;
|
||||
import speiger.src.collections.PACKAGE.sets.RB_TREE_SET;
|
||||
import speiger.src.collections.PACKAGE.sets.IMMUTABLE_HASH_SET;
|
||||
import speiger.src.collections.PACKAGE.utils.STRATEGY;
|
||||
#endif
|
||||
#if TYPE_OBJECT
|
||||
import speiger.src.collections.objects.utils.StringSortTest;
|
||||
#endif
|
||||
import speiger.src.testers.PACKAGE.tests.collection.FILE_KEY_TYPECollectionConstructorTester;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class COLLECTION_CONSTRUCTOR_TESTS
|
||||
{
|
||||
public static class ArrayList extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
||||
{
|
||||
@SuppressWarnings("deprecation")
|
||||
public ArrayList() {
|
||||
setSimpleConstructor(ARRAY_LIST::new);
|
||||
setSizeConstructor(T -> new ARRAY_LISTBRACES(T));
|
||||
setPArrayConstructor(T -> new ARRAY_LISTBRACES(T));
|
||||
setPCollectionConstructor(T -> new ARRAY_LISTBRACES(T));
|
||||
setCollectionConstructor(T -> new ARRAY_LISTBRACES(T));
|
||||
}
|
||||
|
||||
#if TYPE_OBJECT
|
||||
@Override
|
||||
protected String[] createKeyElements() {
|
||||
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public static class LinkedList extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
||||
{
|
||||
@SuppressWarnings("deprecation")
|
||||
public LinkedList() {
|
||||
setSimpleConstructor(LINKED_LIST::new);
|
||||
setPArrayConstructor(T -> new LINKED_LISTBRACES(T));
|
||||
setPCollectionConstructor(T -> new LINKED_LISTBRACES(T));
|
||||
setCollectionConstructor(T -> new LINKED_LISTBRACES(T));
|
||||
}
|
||||
|
||||
#if TYPE_OBJECT
|
||||
@Override
|
||||
protected String[] createKeyElements() {
|
||||
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public static class CopyOnWriteArrayList extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
||||
{
|
||||
@SuppressWarnings("deprecation")
|
||||
public CopyOnWriteArrayList() {
|
||||
setSimpleConstructor(COPY_ON_WRITE_LIST::new);
|
||||
setPArrayConstructor(T -> new COPY_ON_WRITE_LISTBRACES(T));
|
||||
setPCollectionConstructor(T -> new COPY_ON_WRITE_LISTBRACES(T));
|
||||
setCollectionConstructor(T -> new COPY_ON_WRITE_LISTBRACES(T));
|
||||
}
|
||||
|
||||
#if TYPE_OBJECT
|
||||
@Override
|
||||
protected String[] createKeyElements() {
|
||||
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public static class ImmutableList extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
||||
{
|
||||
@SuppressWarnings("deprecation")
|
||||
public ImmutableList() {
|
||||
setPArrayConstructor(T -> new IMMUTABLE_LISTBRACES(T));
|
||||
setPCollectionConstructor(T -> new IMMUTABLE_LISTBRACES(T));
|
||||
setCollectionConstructor(T -> new IMMUTABLE_LISTBRACES(T));
|
||||
}
|
||||
|
||||
#if TYPE_OBJECT
|
||||
@Override
|
||||
protected String[] createKeyElements() {
|
||||
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !TYPE_BOOLEAN
|
||||
public static class HashSet extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
||||
{
|
||||
@SuppressWarnings("deprecation")
|
||||
public HashSet() {
|
||||
setSimpleConstructor(HASH_SET::new);
|
||||
setSizeConstructor(T -> new HASH_SETBRACES(T));
|
||||
setPArrayConstructor(T -> new HASH_SETBRACES(T));
|
||||
setPCollectionConstructor(T -> new HASH_SETBRACES(T));
|
||||
setCollectionConstructor(T -> new HASH_SETBRACES(T));
|
||||
}
|
||||
|
||||
#if TYPE_OBJECT
|
||||
@Override
|
||||
protected String[] createKeyElements() {
|
||||
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public static class LinkedHashSet extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
||||
{
|
||||
@SuppressWarnings("deprecation")
|
||||
public LinkedHashSet() {
|
||||
setSimpleConstructor(LINKED_HASH_SET::new);
|
||||
setSizeConstructor(T -> new LINKED_HASH_SETBRACES(T));
|
||||
setPArrayConstructor(T -> new LINKED_HASH_SETBRACES(T));
|
||||
setPCollectionConstructor(T -> new LINKED_HASH_SETBRACES(T));
|
||||
setCollectionConstructor(T -> new LINKED_HASH_SETBRACES(T));
|
||||
}
|
||||
|
||||
#if TYPE_OBJECT
|
||||
@Override
|
||||
protected String[] createKeyElements() {
|
||||
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public static class CustomHashSet extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
||||
{
|
||||
@SuppressWarnings("deprecation")
|
||||
public CustomHashSet() {
|
||||
setSimpleConstructor(() -> new CUSTOM_HASH_SET KEY_STRING_GENERIC_TYPE(HashStrategy.INSTANCE));
|
||||
setSizeConstructor(T -> new CUSTOM_HASH_SET KEY_STRING_GENERIC_TYPE(T, HashStrategy.INSTANCE));
|
||||
setPArrayConstructor(T -> new CUSTOM_HASH_SET KEY_STRING_GENERIC_TYPE(T, HashStrategy.INSTANCE));
|
||||
setPCollectionConstructor(T -> new CUSTOM_HASH_SET KEY_STRING_GENERIC_TYPE(T, HashStrategy.INSTANCE));
|
||||
setCollectionConstructor(T -> new CUSTOM_HASH_SET KEY_STRING_GENERIC_TYPE(T, HashStrategy.INSTANCE));
|
||||
}
|
||||
|
||||
#if TYPE_OBJECT
|
||||
@Override
|
||||
protected String[] createKeyElements() {
|
||||
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public static class LinkedCustomHashSet extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
||||
{
|
||||
@SuppressWarnings("deprecation")
|
||||
public LinkedCustomHashSet() {
|
||||
setSimpleConstructor(() -> new LINKED_CUSTOM_HASH_SET KEY_STRING_GENERIC_TYPE(HashStrategy.INSTANCE));
|
||||
setSizeConstructor(T -> new LINKED_CUSTOM_HASH_SET KEY_STRING_GENERIC_TYPE(T, HashStrategy.INSTANCE));
|
||||
setPArrayConstructor(T -> new LINKED_CUSTOM_HASH_SET KEY_STRING_GENERIC_TYPE(T, HashStrategy.INSTANCE));
|
||||
setPCollectionConstructor(T -> new LINKED_CUSTOM_HASH_SET KEY_STRING_GENERIC_TYPE(T, HashStrategy.INSTANCE));
|
||||
setCollectionConstructor(T -> new LINKED_CUSTOM_HASH_SET KEY_STRING_GENERIC_TYPE(T, HashStrategy.INSTANCE));
|
||||
}
|
||||
|
||||
#if TYPE_OBJECT
|
||||
@Override
|
||||
protected String[] createKeyElements() {
|
||||
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public static class ImmutableHashSet extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
||||
{
|
||||
@SuppressWarnings("deprecation")
|
||||
public ImmutableHashSet() {
|
||||
setPArrayConstructor(T -> new IMMUTABLE_HASH_SETBRACES(T));
|
||||
setPCollectionConstructor(T -> new IMMUTABLE_HASH_SETBRACES(T));
|
||||
setCollectionConstructor(T -> new IMMUTABLE_HASH_SETBRACES(T));
|
||||
}
|
||||
|
||||
#if TYPE_OBJECT
|
||||
@Override
|
||||
protected String[] createKeyElements() {
|
||||
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public static class ArraySet extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
||||
{
|
||||
@SuppressWarnings("deprecation")
|
||||
public ArraySet() {
|
||||
setSimpleConstructor(ARRAY_SET::new);
|
||||
setSizeConstructor(T -> new ARRAY_SETBRACES(T));
|
||||
setPArrayConstructor(T -> new ARRAY_SETBRACES(T));
|
||||
setPCollectionConstructor(T -> new ARRAY_SETBRACES(T));
|
||||
setCollectionConstructor(T -> new ARRAY_SETBRACES(T));
|
||||
}
|
||||
|
||||
#if TYPE_OBJECT
|
||||
@Override
|
||||
protected String[] createKeyElements() {
|
||||
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public static class RBTreeSet extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
||||
{
|
||||
@SuppressWarnings("deprecation")
|
||||
public RBTreeSet() {
|
||||
setSimpleConstructor(RB_TREE_SET::new);
|
||||
setPArrayConstructor(T -> new RB_TREE_SETBRACES(T));
|
||||
setPCollectionConstructor(T -> new RB_TREE_SETBRACES(T));
|
||||
setCollectionConstructor(T -> new RB_TREE_SETBRACES(T));
|
||||
}
|
||||
|
||||
#if TYPE_OBJECT
|
||||
@Override
|
||||
protected String[] createKeyElements() {
|
||||
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public static class AVLTreeSet extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
||||
{
|
||||
@SuppressWarnings("deprecation")
|
||||
public AVLTreeSet() {
|
||||
setSimpleConstructor(AVL_TREE_SET::new);
|
||||
setPArrayConstructor(T -> new AVL_TREE_SETBRACES(T));
|
||||
setPCollectionConstructor(T -> new AVL_TREE_SETBRACES(T));
|
||||
setCollectionConstructor(T -> new AVL_TREE_SETBRACES(T));
|
||||
}
|
||||
|
||||
#if TYPE_OBJECT
|
||||
@Override
|
||||
protected String[] createKeyElements() {
|
||||
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public static class RBTreeSetComparator extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
||||
{
|
||||
@SuppressWarnings("deprecation")
|
||||
public RBTreeSetComparator() {
|
||||
#if TYPE_OBJECT
|
||||
setSimpleConstructor(() -> new RB_TREE_SET<String>(Comparator.naturalOrder()));
|
||||
setPArrayConstructor(T -> new RB_TREE_SET<>(T, Comparator.naturalOrder()));
|
||||
setPCollectionConstructor(T -> new RB_TREE_SET<>(T, Comparator.naturalOrder()));
|
||||
setCollectionConstructor(T -> new RB_TREE_SET<>(T, Comparator.naturalOrder()));
|
||||
#else
|
||||
setSimpleConstructor(() -> new RB_TREE_SET(CLASS_TYPE::compare));
|
||||
setPArrayConstructor(T -> new RB_TREE_SET(T, CLASS_TYPE::compare));
|
||||
setPCollectionConstructor(T -> new RB_TREE_SET(T, CLASS_TYPE::compare));
|
||||
setCollectionConstructor(T -> new RB_TREE_SET(T, CLASS_TYPE::compare));
|
||||
#endif
|
||||
}
|
||||
|
||||
#if TYPE_OBJECT
|
||||
@Override
|
||||
protected String[] createKeyElements() {
|
||||
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public static class AVLTreeSetComparator extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
||||
{
|
||||
@SuppressWarnings("deprecation")
|
||||
public AVLTreeSetComparator() {
|
||||
#if TYPE_OBJECT
|
||||
setSimpleConstructor(() -> new AVL_TREE_SET<String>(Comparator.naturalOrder()));
|
||||
setPArrayConstructor(T -> new AVL_TREE_SET<>(T, Comparator.naturalOrder()));
|
||||
setPCollectionConstructor(T -> new AVL_TREE_SET<>(T, Comparator.naturalOrder()));
|
||||
setCollectionConstructor(T -> new AVL_TREE_SET<>(T, Comparator.naturalOrder()));
|
||||
#else
|
||||
setSimpleConstructor(() -> new AVL_TREE_SET(CLASS_TYPE::compare));
|
||||
setPArrayConstructor(T -> new AVL_TREE_SET(T, CLASS_TYPE::compare));
|
||||
setPCollectionConstructor(T -> new AVL_TREE_SET(T, CLASS_TYPE::compare));
|
||||
setCollectionConstructor(T -> new AVL_TREE_SET(T, CLASS_TYPE::compare));
|
||||
#endif
|
||||
}
|
||||
|
||||
#if TYPE_OBJECT
|
||||
@Override
|
||||
protected String[] createKeyElements() {
|
||||
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
private static class HashStrategy implements STRATEGY KEY_STRING_GENERIC_TYPE {
|
||||
static final HashStrategy INSTANCE = new HashStrategy();
|
||||
@Override
|
||||
public int hashCode(KEY_STRING_TYPE o) { return KEY_TO_HASH(o); }
|
||||
@Override
|
||||
public boolean equals(KEY_STRING_TYPE key, KEY_STRING_TYPE value) { return KEY_EQUALS(key, value); }
|
||||
}
|
||||
#endif
|
||||
}
|
|
@ -1,82 +1,82 @@
|
|||
package speiger.src.testers.PACKAGE.impl;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
import speiger.src.collections.PACKAGE.collections.ITERABLE;
|
||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||
import speiger.src.collections.PACKAGE.queues.PRIORITY_QUEUE;
|
||||
#if TYPE_OBJECT
|
||||
import speiger.src.collections.objects.utils.ObjectArrays;
|
||||
#endif
|
||||
import speiger.src.testers.PACKAGE.generators.TEST_QUEUE_GENERATOR;
|
||||
import speiger.src.testers.PACKAGE.utils.SAMPLE_ELEMENTS;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public class SIMPLE_QUEUE_TEST_GENERATOR KEY_GENERIC_TYPE implements TEST_QUEUE_GENERATOR KEY_GENERIC_TYPE
|
||||
{
|
||||
Function<KEY_TYPE[], PRIORITY_QUEUE KEY_GENERIC_TYPE> mapper;
|
||||
#if TYPE_OBJECT
|
||||
KEY_TYPE[] keys;
|
||||
#endif
|
||||
|
||||
public SIMPLE_QUEUE_TEST_GENERATOR(Function<KEY_TYPE[], PRIORITY_QUEUE KEY_GENERIC_TYPE> mapper) {
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
#if TYPE_OBJECT
|
||||
public SIMPLE_QUEUE_TEST_GENERATOR KEY_GENERIC_TYPE setElements(KEY_TYPE...keys) {
|
||||
this.keys = keys;
|
||||
return this;
|
||||
}
|
||||
|
||||
#endif
|
||||
public SAMPLE_ELEMENTS KEY_GENERIC_TYPE getSamples() {
|
||||
#if TYPE_BOOLEAN
|
||||
return new SAMPLE_ELEMENTS(true, false, true, false, true);
|
||||
#else if TYPE_BYTE
|
||||
return new SAMPLE_ELEMENTS((byte)0, (byte)1, (byte)2, (byte)3, (byte)4);
|
||||
#else if TYPE_SHORT
|
||||
return new SAMPLE_ELEMENTS((short)0, (short)1, (short)2, (short)3, (short)4);
|
||||
#else if TYPE_CHAR
|
||||
return new SAMPLE_ELEMENTS((char)0, (char)1, (char)2, (char)3, (char)4);
|
||||
#else if TYPE_OBJECT
|
||||
return new SAMPLE_ELEMENTSBRACES(keys[0], keys[1], keys[2], keys[3], keys[4]);
|
||||
#else
|
||||
return new SAMPLE_ELEMENTS(0, 1, 2, 3, 4);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
public PRIORITY_QUEUE KEY_GENERIC_TYPE create(KEY_TYPE... elements) {
|
||||
return mapper.apply(elements);
|
||||
}
|
||||
|
||||
public PRIORITY_QUEUE KEY_GENERIC_TYPE create(Object... elements) {
|
||||
KEY_TYPE[] array = NEW_KEY_ARRAY(elements.length);
|
||||
int i = 0;
|
||||
for (Object e : elements) {
|
||||
array[i++] = CLASS_TO_KEY(e);
|
||||
}
|
||||
return mapper.apply(array);
|
||||
}
|
||||
|
||||
#else
|
||||
public PRIORITY_QUEUE KEY_GENERIC_TYPE create(Object... elements) {
|
||||
T[] array = (T[])ObjectArrays.newArray(keys[0].getClass(), elements.length);
|
||||
int i = 0;
|
||||
for (Object e : elements) {
|
||||
array[i++] = CLASS_TO_KEY(e);
|
||||
}
|
||||
return mapper.apply(array);
|
||||
}
|
||||
|
||||
#endif
|
||||
public ITERABLE KEY_GENERIC_TYPE order(LIST KEY_GENERIC_TYPE insertionOrder) {
|
||||
return insertionOrder;
|
||||
}
|
||||
|
||||
public Iterable<CLASS_TYPE> order(List<CLASS_TYPE> insertionOrder) {
|
||||
return insertionOrder;
|
||||
}
|
||||
package speiger.src.testers.PACKAGE.impl;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
import speiger.src.collections.PACKAGE.collections.ITERABLE;
|
||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||
import speiger.src.collections.PACKAGE.queues.PRIORITY_QUEUE;
|
||||
#if TYPE_OBJECT
|
||||
import speiger.src.collections.objects.utils.ObjectArrays;
|
||||
#endif
|
||||
import speiger.src.testers.PACKAGE.generators.TEST_QUEUE_GENERATOR;
|
||||
import speiger.src.testers.PACKAGE.utils.SAMPLE_ELEMENTS;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public class SIMPLE_QUEUE_TEST_GENERATOR KEY_GENERIC_TYPE implements TEST_QUEUE_GENERATOR KEY_GENERIC_TYPE
|
||||
{
|
||||
Function<KEY_TYPE[], PRIORITY_QUEUE KEY_GENERIC_TYPE> mapper;
|
||||
#if TYPE_OBJECT
|
||||
KEY_TYPE[] keys;
|
||||
#endif
|
||||
|
||||
public SIMPLE_QUEUE_TEST_GENERATOR(Function<KEY_TYPE[], PRIORITY_QUEUE KEY_GENERIC_TYPE> mapper) {
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
#if TYPE_OBJECT
|
||||
public SIMPLE_QUEUE_TEST_GENERATOR KEY_GENERIC_TYPE setElements(KEY_TYPE...keys) {
|
||||
this.keys = keys;
|
||||
return this;
|
||||
}
|
||||
|
||||
#endif
|
||||
public SAMPLE_ELEMENTS KEY_GENERIC_TYPE getSamples() {
|
||||
#if TYPE_BOOLEAN
|
||||
return new SAMPLE_ELEMENTS(true, false, true, false, true);
|
||||
#else if TYPE_BYTE
|
||||
return new SAMPLE_ELEMENTS((byte)0, (byte)1, (byte)2, (byte)3, (byte)4);
|
||||
#else if TYPE_SHORT
|
||||
return new SAMPLE_ELEMENTS((short)0, (short)1, (short)2, (short)3, (short)4);
|
||||
#else if TYPE_CHAR
|
||||
return new SAMPLE_ELEMENTS((char)0, (char)1, (char)2, (char)3, (char)4);
|
||||
#else if TYPE_OBJECT
|
||||
return new SAMPLE_ELEMENTSBRACES(keys[0], keys[1], keys[2], keys[3], keys[4]);
|
||||
#else
|
||||
return new SAMPLE_ELEMENTS(0, 1, 2, 3, 4);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
public PRIORITY_QUEUE KEY_GENERIC_TYPE create(KEY_TYPE... elements) {
|
||||
return mapper.apply(elements);
|
||||
}
|
||||
|
||||
public PRIORITY_QUEUE KEY_GENERIC_TYPE create(Object... elements) {
|
||||
KEY_TYPE[] array = NEW_KEY_ARRAY(elements.length);
|
||||
int i = 0;
|
||||
for (Object e : elements) {
|
||||
array[i++] = CLASS_TO_KEY(e);
|
||||
}
|
||||
return mapper.apply(array);
|
||||
}
|
||||
|
||||
#else
|
||||
public PRIORITY_QUEUE KEY_GENERIC_TYPE create(Object... elements) {
|
||||
T[] array = (T[])ObjectArrays.newArray(keys[0].getClass(), elements.length);
|
||||
int i = 0;
|
||||
for (Object e : elements) {
|
||||
array[i++] = CLASS_TO_KEY(e);
|
||||
}
|
||||
return mapper.apply(array);
|
||||
}
|
||||
|
||||
#endif
|
||||
public ITERABLE KEY_GENERIC_TYPE order(LIST KEY_GENERIC_TYPE insertionOrder) {
|
||||
return insertionOrder;
|
||||
}
|
||||
|
||||
public Iterable<CLASS_TYPE> order(List<CLASS_TYPE> insertionOrder) {
|
||||
return insertionOrder;
|
||||
}
|
||||
}
|
|
@ -1,221 +1,221 @@
|
|||
package speiger.src.testers.PACKAGE.impl;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||
import speiger.src.collections.PACKAGE.collections.ITERABLE;
|
||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||
#if !TYPE_BOOLEAN
|
||||
import speiger.src.collections.PACKAGE.sets.NAVIGABLE_SET;
|
||||
import speiger.src.collections.PACKAGE.sets.ORDERED_SET;
|
||||
import speiger.src.collections.PACKAGE.sets.SET;
|
||||
import speiger.src.collections.PACKAGE.sets.SORTED_SET;
|
||||
#if TYPE_OBJECT
|
||||
import speiger.src.collections.objects.utils.ObjectArrays;
|
||||
#endif
|
||||
#endif
|
||||
import speiger.src.testers.PACKAGE.generators.TEST_COLLECTION_GENERATOR;
|
||||
import speiger.src.testers.PACKAGE.generators.TEST_LIST_GENERATOR;
|
||||
#if !TYPE_BOOLEAN
|
||||
import speiger.src.testers.PACKAGE.generators.TEST_NAVIGABLE_SET_GENERATOR;
|
||||
import speiger.src.testers.PACKAGE.generators.TEST_ORDERED_SET_GENERATOR;
|
||||
import speiger.src.testers.PACKAGE.generators.TEST_SET_GENERATOR;
|
||||
import speiger.src.testers.PACKAGE.generators.TEST_SORTED_SET_GENERATOR;
|
||||
#endif
|
||||
import speiger.src.testers.PACKAGE.utils.SAMPLE_ELEMENTS;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public class SIMPLE_TEST_GENERATOR KKS_GENERIC_TYPE<E extends COLLECTION KEY_GENERIC_TYPE> {
|
||||
Function<KEY_TYPE[], E> mapper;
|
||||
#if TYPE_OBJECT
|
||||
KEY_TYPE[] keys;
|
||||
#endif
|
||||
|
||||
public SIMPLE_TEST_GENERATOR(Function<KEY_TYPE[], E> mapper) {
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
#if TYPE_OBJECT
|
||||
public SIMPLE_TEST_GENERATOR KKS_GENERIC_TYPE<E> setElements(KEY_TYPE...keys) {
|
||||
this.keys = keys;
|
||||
return this;
|
||||
}
|
||||
|
||||
#endif
|
||||
public SAMPLE_ELEMENTS KEY_GENERIC_TYPE getSamples() {
|
||||
#if TYPE_BOOLEAN
|
||||
return new SAMPLE_ELEMENTS(true, false, true, false, true);
|
||||
#else if TYPE_BYTE
|
||||
return new SAMPLE_ELEMENTS((byte)0, (byte)1, (byte)2, (byte)3, (byte)4);
|
||||
#else if TYPE_SHORT
|
||||
return new SAMPLE_ELEMENTS((short)0, (short)1, (short)2, (short)3, (short)4);
|
||||
#else if TYPE_CHAR
|
||||
return new SAMPLE_ELEMENTS((char)0, (char)1, (char)2, (char)3, (char)4);
|
||||
#else if TYPE_OBJECT
|
||||
return new SAMPLE_ELEMENTSBRACES(keys[0], keys[1], keys[2], keys[3], keys[4]);
|
||||
#else
|
||||
return new SAMPLE_ELEMENTS(0, 1, 2, 3, 4);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
public E create(KEY_TYPE... elements) {
|
||||
return mapper.apply(elements);
|
||||
}
|
||||
|
||||
public E create(Object... elements) {
|
||||
KEY_TYPE[] array = NEW_KEY_ARRAY(elements.length);
|
||||
int i = 0;
|
||||
for (Object e : elements) {
|
||||
array[i++] = CLASS_TO_KEY(e);
|
||||
}
|
||||
return mapper.apply(array);
|
||||
}
|
||||
|
||||
#else
|
||||
public E create(Object... elements) {
|
||||
T[] array = (T[])ObjectArrays.newArray(keys[0].getClass(), elements.length);
|
||||
int i = 0;
|
||||
for (Object e : elements) {
|
||||
array[i++] = CLASS_TO_KEY(e);
|
||||
}
|
||||
return mapper.apply(array);
|
||||
}
|
||||
|
||||
#endif
|
||||
public ITERABLE KEY_GENERIC_TYPE order(LIST KEY_GENERIC_TYPE insertionOrder) {
|
||||
return insertionOrder;
|
||||
}
|
||||
|
||||
public Iterable<CLASS_TYPE> order(List<CLASS_TYPE> insertionOrder) {
|
||||
return insertionOrder;
|
||||
}
|
||||
|
||||
public static class Collections KEY_GENERIC_TYPE extends SIMPLE_TEST_GENERATOR KKS_GENERIC_TYPE<COLLECTION KEY_GENERIC_TYPE> implements TEST_COLLECTION_GENERATOR KEY_GENERIC_TYPE
|
||||
{
|
||||
public Collections(Function<KEY_TYPE[], COLLECTION KEY_GENERIC_TYPE> mapper) {
|
||||
super(mapper);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Lists KEY_GENERIC_TYPE extends SIMPLE_TEST_GENERATOR KKS_GENERIC_TYPE<LIST KEY_GENERIC_TYPE> implements TEST_LIST_GENERATOR KEY_GENERIC_TYPE
|
||||
{
|
||||
public Lists(Function<KEY_TYPE[], LIST KEY_GENERIC_TYPE> mapper) {
|
||||
super(mapper);
|
||||
}
|
||||
}
|
||||
|
||||
#if !TYPE_BOOLEAN
|
||||
public static class Sets KEY_GENERIC_TYPE extends SIMPLE_TEST_GENERATOR KKS_GENERIC_TYPE<SET KEY_GENERIC_TYPE> implements TEST_SET_GENERATOR KEY_GENERIC_TYPE
|
||||
{
|
||||
public Sets(Function<KEY_TYPE[], SET KEY_GENERIC_TYPE> mapper) {
|
||||
super(mapper);
|
||||
}
|
||||
}
|
||||
|
||||
public static class OrderedSets KEY_GENERIC_TYPE extends SIMPLE_TEST_GENERATOR KKS_GENERIC_TYPE<ORDERED_SET KEY_GENERIC_TYPE> implements TEST_ORDERED_SET_GENERATOR KEY_GENERIC_TYPE
|
||||
{
|
||||
public OrderedSets(Function<KEY_TYPE[], ORDERED_SET KEY_GENERIC_TYPE> mapper) {
|
||||
super(mapper);
|
||||
}
|
||||
}
|
||||
|
||||
public static class SortedSets KEY_GENERIC_TYPE extends SIMPLE_TEST_GENERATOR KKS_GENERIC_TYPE<SORTED_SET KEY_GENERIC_TYPE> implements TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE
|
||||
{
|
||||
public SortedSets(Function<KEY_TYPE[], SORTED_SET KEY_GENERIC_TYPE> mapper) {
|
||||
super(mapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITERABLE KEY_GENERIC_TYPE order(LIST KEY_GENERIC_TYPE insertionOrder) {
|
||||
insertionOrder.sort(null);
|
||||
return insertionOrder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<CLASS_TYPE> order(List<CLASS_TYPE> insertionOrder) {
|
||||
insertionOrder.sort(null);
|
||||
return insertionOrder;
|
||||
}
|
||||
|
||||
#if TYPE_CHAR
|
||||
@Override
|
||||
public KEY_TYPE belowSamplesLesser() { return '_'; }
|
||||
@Override
|
||||
public KEY_TYPE belowSamplesGreater() { return '`'; }
|
||||
@Override
|
||||
public KEY_TYPE aboveSamplesLesser() { return 'f'; }
|
||||
@Override
|
||||
public KEY_TYPE aboveSamplesGreater() { return 'g'; }
|
||||
#else if TYPE_OBJECT
|
||||
@Override
|
||||
public KEY_TYPE belowSamplesLesser() { return keys[5]; }
|
||||
@Override
|
||||
public KEY_TYPE belowSamplesGreater() { return keys[6]; }
|
||||
@Override
|
||||
public KEY_TYPE aboveSamplesLesser() { return keys[7]; }
|
||||
@Override
|
||||
public KEY_TYPE aboveSamplesGreater() { return keys[8]; }
|
||||
#else
|
||||
@Override
|
||||
public KEY_TYPE belowSamplesLesser() { return -2; }
|
||||
@Override
|
||||
public KEY_TYPE belowSamplesGreater() { return -1; }
|
||||
@Override
|
||||
public KEY_TYPE aboveSamplesLesser() { return 5; }
|
||||
@Override
|
||||
public KEY_TYPE aboveSamplesGreater() { return 6; }
|
||||
#endif
|
||||
}
|
||||
|
||||
public static class NavigableSets KEY_GENERIC_TYPE extends SIMPLE_TEST_GENERATOR KKS_GENERIC_TYPE<NAVIGABLE_SET KEY_GENERIC_TYPE> implements TEST_NAVIGABLE_SET_GENERATOR KEY_GENERIC_TYPE
|
||||
{
|
||||
public NavigableSets(Function<KEY_TYPE[], NAVIGABLE_SET KEY_GENERIC_TYPE> mapper) {
|
||||
super(mapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITERABLE KEY_GENERIC_TYPE order(LIST KEY_GENERIC_TYPE insertionOrder) {
|
||||
insertionOrder.sort(null);
|
||||
return insertionOrder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<CLASS_TYPE> order(List<CLASS_TYPE> insertionOrder) {
|
||||
insertionOrder.sort(null);
|
||||
return insertionOrder;
|
||||
}
|
||||
|
||||
#if TYPE_CHAR
|
||||
public SAMPLE_ELEMENTS KEY_GENERIC_TYPE getSamples() { return new SAMPLE_ELEMENTS('a', 'b', 'c', 'd', 'e'); }
|
||||
@Override
|
||||
public KEY_TYPE belowSamplesLesser() { return '_'; }
|
||||
@Override
|
||||
public KEY_TYPE belowSamplesGreater() { return '`'; }
|
||||
@Override
|
||||
public KEY_TYPE aboveSamplesLesser() { return 'f'; }
|
||||
@Override
|
||||
public KEY_TYPE aboveSamplesGreater() { return 'g'; }
|
||||
#else if TYPE_OBJECT
|
||||
@Override
|
||||
public KEY_TYPE belowSamplesLesser() { return keys[5]; }
|
||||
@Override
|
||||
public KEY_TYPE belowSamplesGreater() { return keys[6]; }
|
||||
@Override
|
||||
public KEY_TYPE aboveSamplesLesser() { return keys[7]; }
|
||||
@Override
|
||||
public KEY_TYPE aboveSamplesGreater() { return keys[8]; }
|
||||
#else
|
||||
@Override
|
||||
public KEY_TYPE belowSamplesLesser() { return -2; }
|
||||
@Override
|
||||
public KEY_TYPE belowSamplesGreater() { return -1; }
|
||||
@Override
|
||||
public KEY_TYPE aboveSamplesLesser() { return 5; }
|
||||
@Override
|
||||
public KEY_TYPE aboveSamplesGreater() { return 6; }
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
package speiger.src.testers.PACKAGE.impl;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||
import speiger.src.collections.PACKAGE.collections.ITERABLE;
|
||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||
#if !TYPE_BOOLEAN
|
||||
import speiger.src.collections.PACKAGE.sets.NAVIGABLE_SET;
|
||||
import speiger.src.collections.PACKAGE.sets.ORDERED_SET;
|
||||
import speiger.src.collections.PACKAGE.sets.SET;
|
||||
import speiger.src.collections.PACKAGE.sets.SORTED_SET;
|
||||
#if TYPE_OBJECT
|
||||
import speiger.src.collections.objects.utils.ObjectArrays;
|
||||
#endif
|
||||
#endif
|
||||
import speiger.src.testers.PACKAGE.generators.TEST_COLLECTION_GENERATOR;
|
||||
import speiger.src.testers.PACKAGE.generators.TEST_LIST_GENERATOR;
|
||||
#if !TYPE_BOOLEAN
|
||||
import speiger.src.testers.PACKAGE.generators.TEST_NAVIGABLE_SET_GENERATOR;
|
||||
import speiger.src.testers.PACKAGE.generators.TEST_ORDERED_SET_GENERATOR;
|
||||
import speiger.src.testers.PACKAGE.generators.TEST_SET_GENERATOR;
|
||||
import speiger.src.testers.PACKAGE.generators.TEST_SORTED_SET_GENERATOR;
|
||||
#endif
|
||||
import speiger.src.testers.PACKAGE.utils.SAMPLE_ELEMENTS;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public class SIMPLE_TEST_GENERATOR KKS_GENERIC_TYPE<E extends COLLECTION KEY_GENERIC_TYPE> {
|
||||
Function<KEY_TYPE[], E> mapper;
|
||||
#if TYPE_OBJECT
|
||||
KEY_TYPE[] keys;
|
||||
#endif
|
||||
|
||||
public SIMPLE_TEST_GENERATOR(Function<KEY_TYPE[], E> mapper) {
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
#if TYPE_OBJECT
|
||||
public SIMPLE_TEST_GENERATOR KKS_GENERIC_TYPE<E> setElements(KEY_TYPE...keys) {
|
||||
this.keys = keys;
|
||||
return this;
|
||||
}
|
||||
|
||||
#endif
|
||||
public SAMPLE_ELEMENTS KEY_GENERIC_TYPE getSamples() {
|
||||
#if TYPE_BOOLEAN
|
||||
return new SAMPLE_ELEMENTS(true, false, true, false, true);
|
||||
#else if TYPE_BYTE
|
||||
return new SAMPLE_ELEMENTS((byte)0, (byte)1, (byte)2, (byte)3, (byte)4);
|
||||
#else if TYPE_SHORT
|
||||
return new SAMPLE_ELEMENTS((short)0, (short)1, (short)2, (short)3, (short)4);
|
||||
#else if TYPE_CHAR
|
||||
return new SAMPLE_ELEMENTS((char)0, (char)1, (char)2, (char)3, (char)4);
|
||||
#else if TYPE_OBJECT
|
||||
return new SAMPLE_ELEMENTSBRACES(keys[0], keys[1], keys[2], keys[3], keys[4]);
|
||||
#else
|
||||
return new SAMPLE_ELEMENTS(0, 1, 2, 3, 4);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
public E create(KEY_TYPE... elements) {
|
||||
return mapper.apply(elements);
|
||||
}
|
||||
|
||||
public E create(Object... elements) {
|
||||
KEY_TYPE[] array = NEW_KEY_ARRAY(elements.length);
|
||||
int i = 0;
|
||||
for (Object e : elements) {
|
||||
array[i++] = CLASS_TO_KEY(e);
|
||||
}
|
||||
return mapper.apply(array);
|
||||
}
|
||||
|
||||
#else
|
||||
public E create(Object... elements) {
|
||||
T[] array = (T[])ObjectArrays.newArray(keys[0].getClass(), elements.length);
|
||||
int i = 0;
|
||||
for (Object e : elements) {
|
||||
array[i++] = CLASS_TO_KEY(e);
|
||||
}
|
||||
return mapper.apply(array);
|
||||
}
|
||||
|
||||
#endif
|
||||
public ITERABLE KEY_GENERIC_TYPE order(LIST KEY_GENERIC_TYPE insertionOrder) {
|
||||
return insertionOrder;
|
||||
}
|
||||
|
||||
public Iterable<CLASS_TYPE> order(List<CLASS_TYPE> insertionOrder) {
|
||||
return insertionOrder;
|
||||
}
|
||||
|
||||
public static class Collections KEY_GENERIC_TYPE extends SIMPLE_TEST_GENERATOR KKS_GENERIC_TYPE<COLLECTION KEY_GENERIC_TYPE> implements TEST_COLLECTION_GENERATOR KEY_GENERIC_TYPE
|
||||
{
|
||||
public Collections(Function<KEY_TYPE[], COLLECTION KEY_GENERIC_TYPE> mapper) {
|
||||
super(mapper);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Lists KEY_GENERIC_TYPE extends SIMPLE_TEST_GENERATOR KKS_GENERIC_TYPE<LIST KEY_GENERIC_TYPE> implements TEST_LIST_GENERATOR KEY_GENERIC_TYPE
|
||||
{
|
||||
public Lists(Function<KEY_TYPE[], LIST KEY_GENERIC_TYPE> mapper) {
|
||||
super(mapper);
|
||||
}
|
||||
}
|
||||
|
||||
#if !TYPE_BOOLEAN
|
||||
public static class Sets KEY_GENERIC_TYPE extends SIMPLE_TEST_GENERATOR KKS_GENERIC_TYPE<SET KEY_GENERIC_TYPE> implements TEST_SET_GENERATOR KEY_GENERIC_TYPE
|
||||
{
|
||||
public Sets(Function<KEY_TYPE[], SET KEY_GENERIC_TYPE> mapper) {
|
||||
super(mapper);
|
||||
}
|
||||
}
|
||||
|
||||
public static class OrderedSets KEY_GENERIC_TYPE extends SIMPLE_TEST_GENERATOR KKS_GENERIC_TYPE<ORDERED_SET KEY_GENERIC_TYPE> implements TEST_ORDERED_SET_GENERATOR KEY_GENERIC_TYPE
|
||||
{
|
||||
public OrderedSets(Function<KEY_TYPE[], ORDERED_SET KEY_GENERIC_TYPE> mapper) {
|
||||
super(mapper);
|
||||
}
|
||||
}
|
||||
|
||||
public static class SortedSets KEY_GENERIC_TYPE extends SIMPLE_TEST_GENERATOR KKS_GENERIC_TYPE<SORTED_SET KEY_GENERIC_TYPE> implements TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE
|
||||
{
|
||||
public SortedSets(Function<KEY_TYPE[], SORTED_SET KEY_GENERIC_TYPE> mapper) {
|
||||
super(mapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITERABLE KEY_GENERIC_TYPE order(LIST KEY_GENERIC_TYPE insertionOrder) {
|
||||
insertionOrder.sort(null);
|
||||
return insertionOrder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<CLASS_TYPE> order(List<CLASS_TYPE> insertionOrder) {
|
||||
insertionOrder.sort(null);
|
||||
return insertionOrder;
|
||||
}
|
||||
|
||||
#if TYPE_CHAR
|
||||
@Override
|
||||
public KEY_TYPE belowSamplesLesser() { return '_'; }
|
||||
@Override
|
||||
public KEY_TYPE belowSamplesGreater() { return '`'; }
|
||||
@Override
|
||||
public KEY_TYPE aboveSamplesLesser() { return 'f'; }
|
||||
@Override
|
||||
public KEY_TYPE aboveSamplesGreater() { return 'g'; }
|
||||
#else if TYPE_OBJECT
|
||||
@Override
|
||||
public KEY_TYPE belowSamplesLesser() { return keys[5]; }
|
||||
@Override
|
||||
public KEY_TYPE belowSamplesGreater() { return keys[6]; }
|
||||
@Override
|
||||
public KEY_TYPE aboveSamplesLesser() { return keys[7]; }
|
||||
@Override
|
||||
public KEY_TYPE aboveSamplesGreater() { return keys[8]; }
|
||||
#else
|
||||
@Override
|
||||
public KEY_TYPE belowSamplesLesser() { return -2; }
|
||||
@Override
|
||||
public KEY_TYPE belowSamplesGreater() { return -1; }
|
||||
@Override
|
||||
public KEY_TYPE aboveSamplesLesser() { return 5; }
|
||||
@Override
|
||||
public KEY_TYPE aboveSamplesGreater() { return 6; }
|
||||
#endif
|
||||
}
|
||||
|
||||
public static class NavigableSets KEY_GENERIC_TYPE extends SIMPLE_TEST_GENERATOR KKS_GENERIC_TYPE<NAVIGABLE_SET KEY_GENERIC_TYPE> implements TEST_NAVIGABLE_SET_GENERATOR KEY_GENERIC_TYPE
|
||||
{
|
||||
public NavigableSets(Function<KEY_TYPE[], NAVIGABLE_SET KEY_GENERIC_TYPE> mapper) {
|
||||
super(mapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITERABLE KEY_GENERIC_TYPE order(LIST KEY_GENERIC_TYPE insertionOrder) {
|
||||
insertionOrder.sort(null);
|
||||
return insertionOrder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<CLASS_TYPE> order(List<CLASS_TYPE> insertionOrder) {
|
||||
insertionOrder.sort(null);
|
||||
return insertionOrder;
|
||||
}
|
||||
|
||||
#if TYPE_CHAR
|
||||
public SAMPLE_ELEMENTS KEY_GENERIC_TYPE getSamples() { return new SAMPLE_ELEMENTS('a', 'b', 'c', 'd', 'e'); }
|
||||
@Override
|
||||
public KEY_TYPE belowSamplesLesser() { return '_'; }
|
||||
@Override
|
||||
public KEY_TYPE belowSamplesGreater() { return '`'; }
|
||||
@Override
|
||||
public KEY_TYPE aboveSamplesLesser() { return 'f'; }
|
||||
@Override
|
||||
public KEY_TYPE aboveSamplesGreater() { return 'g'; }
|
||||
#else if TYPE_OBJECT
|
||||
@Override
|
||||
public KEY_TYPE belowSamplesLesser() { return keys[5]; }
|
||||
@Override
|
||||
public KEY_TYPE belowSamplesGreater() { return keys[6]; }
|
||||
@Override
|
||||
public KEY_TYPE aboveSamplesLesser() { return keys[7]; }
|
||||
@Override
|
||||
public KEY_TYPE aboveSamplesGreater() { return keys[8]; }
|
||||
#else
|
||||
@Override
|
||||
public KEY_TYPE belowSamplesLesser() { return -2; }
|
||||
@Override
|
||||
public KEY_TYPE belowSamplesGreater() { return -1; }
|
||||
@Override
|
||||
public KEY_TYPE aboveSamplesLesser() { return 5; }
|
||||
@Override
|
||||
public KEY_TYPE aboveSamplesGreater() { return 6; }
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
|
@ -1,173 +1,173 @@
|
|||
package speiger.src.testers.PACKAGE.impl;
|
||||
|
||||
#if TYPE_OBJECT
|
||||
import java.util.Comparator;
|
||||
#endif
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.testing.DerivedCollectionGenerators.Bound;
|
||||
|
||||
import speiger.src.collections.PACKAGE.collections.ITERABLE;
|
||||
#if !TYPE_OBJECT
|
||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||
#endif
|
||||
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||
import speiger.src.collections.PACKAGE.sets.NAVIGABLE_SET;
|
||||
import speiger.src.collections.PACKAGE.sets.SORTED_SET;
|
||||
import speiger.src.testers.PACKAGE.generators.TEST_SORTED_SET_GENERATOR;
|
||||
import speiger.src.testers.PACKAGE.generators.TEST_NAVIGABLE_SET_GENERATOR;
|
||||
import speiger.src.testers.PACKAGE.utils.SAMPLE_ELEMENTS;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public class SUB_SORTED_SET_CLASS_GENERATOR KEY_GENERIC_TYPE implements TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE
|
||||
{
|
||||
final Bound to;
|
||||
final Bound from;
|
||||
final KEY_TYPE firstInclusive;
|
||||
final KEY_TYPE lastInclusive;
|
||||
private final COMPARATOR KEY_GENERIC_TYPE comparator;
|
||||
private final TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE delegate;
|
||||
|
||||
public SUB_SORTED_SET_CLASS_GENERATOR(TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE delegate, Bound to, Bound from) {
|
||||
this.to = to;
|
||||
this.from = from;
|
||||
this.delegate = delegate;
|
||||
|
||||
SORTED_SET KEY_GENERIC_TYPE emptySet = delegate.create(NEW_KEY_ARRAY(0));
|
||||
comparator = emptySet.comparator();
|
||||
|
||||
SAMPLE_ELEMENTS KEY_GENERIC_TYPE samples = delegate.getSamples();
|
||||
LIST KEY_GENERIC_TYPE samplesList = new ARRAY_LISTBRACES(samples.asList());
|
||||
samplesList.sort(comparator);
|
||||
firstInclusive = samplesList.GET_KEY(0);
|
||||
lastInclusive = samplesList.GET_KEY(samplesList.size() - 1);
|
||||
}
|
||||
|
||||
public final TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE getInnerGenerator() {
|
||||
return delegate;
|
||||
}
|
||||
|
||||
public final Bound getTo() {
|
||||
return to;
|
||||
}
|
||||
|
||||
public final Bound getFrom() {
|
||||
return from;
|
||||
}
|
||||
|
||||
SORTED_SET KEY_GENERIC_TYPE createSubSet(SORTED_SET KEY_GENERIC_TYPE set, KEY_TYPE firstExclusive, KEY_TYPE lastExclusive) {
|
||||
if (from == Bound.NO_BOUND && to == Bound.EXCLUSIVE) {
|
||||
return set.headSet(lastExclusive);
|
||||
} else if (from == Bound.INCLUSIVE && to == Bound.NO_BOUND) {
|
||||
return set.tailSet(firstInclusive);
|
||||
} else if (from == Bound.INCLUSIVE && to == Bound.EXCLUSIVE) {
|
||||
return set.subSet(firstInclusive, lastExclusive);
|
||||
} else {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public KEY_TYPE belowSamplesLesser() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public KEY_TYPE belowSamplesGreater() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public KEY_TYPE aboveSamplesLesser() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public KEY_TYPE aboveSamplesGreater() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SAMPLE_ELEMENTS KEY_GENERIC_TYPE getSamples() {
|
||||
return delegate.getSamples();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITERABLE KEY_GENERIC_TYPE order(LIST KEY_GENERIC_TYPE insertionOrder) {
|
||||
return delegate.order(insertionOrder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<CLASS_TYPE> order(List<CLASS_TYPE> insertionOrder) {
|
||||
return delegate.order(insertionOrder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SORTED_SET KEY_GENERIC_TYPE create(KEY_OBJECT_TYPE... elements) {
|
||||
#if TYPE_OBJECT
|
||||
LIST KEY_GENERIC_TYPE normalValues = (LIST KEY_GENERIC_TYPE)ARRAY_LIST.wrap(elements);
|
||||
#else
|
||||
LIST KEY_GENERIC_TYPE normalValues = ARRAY_LIST.wrap(elements);
|
||||
#endif
|
||||
LIST KEY_GENERIC_TYPE extremeValues = new ARRAY_LISTBRACES();
|
||||
KEY_TYPE firstExclusive = delegate.belowSamplesGreater();
|
||||
KEY_TYPE lastExclusive = delegate.aboveSamplesLesser();
|
||||
if (from != Bound.NO_BOUND) {
|
||||
extremeValues.add(delegate.belowSamplesLesser());
|
||||
extremeValues.add(delegate.belowSamplesGreater());
|
||||
}
|
||||
if (to != Bound.NO_BOUND) {
|
||||
extremeValues.add(delegate.aboveSamplesLesser());
|
||||
extremeValues.add(delegate.aboveSamplesGreater());
|
||||
}
|
||||
LIST KEY_GENERIC_TYPE allEntries = new ARRAY_LISTBRACES();
|
||||
allEntries.addAll(extremeValues);
|
||||
allEntries.addAll(normalValues);
|
||||
SORTED_SET KEY_GENERIC_TYPE set = delegate.create(allEntries.toArray());
|
||||
|
||||
return createSubSet(set, firstExclusive, lastExclusive);
|
||||
}
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
@Override
|
||||
public SORTED_SET KEY_GENERIC_TYPE create(Object... elements) {
|
||||
KEY_TYPE[] array = NEW_KEY_ARRAY(elements.length);
|
||||
int i = 0;
|
||||
for (Object e : elements) {
|
||||
array[i++] = CLASS_TO_KEY(e);
|
||||
}
|
||||
return create(array);
|
||||
}
|
||||
|
||||
#endif
|
||||
public static final class SUB_NAVIGABLE_SET_CLASS_GENERATOR KEY_GENERIC_TYPE extends SUB_SORTED_SET_CLASS_GENERATOR KEY_GENERIC_TYPE implements TEST_NAVIGABLE_SET_GENERATOR KEY_GENERIC_TYPE {
|
||||
public SUB_NAVIGABLE_SET_CLASS_GENERATOR(TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE delegate, Bound to, Bound from) {
|
||||
super(delegate, to, from);
|
||||
}
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
@Override
|
||||
public NAVIGABLE_SET KEY_GENERIC_TYPE create(KEY_TYPE... elements) {
|
||||
return (NAVIGABLE_SET KEY_GENERIC_TYPE)super.create(elements);
|
||||
}
|
||||
|
||||
#endif
|
||||
@Override
|
||||
public NAVIGABLE_SET KEY_GENERIC_TYPE create(Object... elements) {
|
||||
return (NAVIGABLE_SET KEY_GENERIC_TYPE)super.create(elements);
|
||||
}
|
||||
|
||||
@Override
|
||||
NAVIGABLE_SET KEY_GENERIC_TYPE createSubSet(SORTED_SET KEY_GENERIC_TYPE sortedSet, KEY_TYPE firstExclusive, KEY_TYPE lastExclusive) {
|
||||
NAVIGABLE_SET KEY_GENERIC_TYPE set = (NAVIGABLE_SET KEY_GENERIC_TYPE) sortedSet;
|
||||
if (from == Bound.NO_BOUND && to == Bound.INCLUSIVE) return set.headSet(lastInclusive, true);
|
||||
else if (from == Bound.EXCLUSIVE && to == Bound.NO_BOUND) return set.tailSet(firstExclusive, false);
|
||||
else if (from == Bound.EXCLUSIVE && to == Bound.EXCLUSIVE) return set.subSet(firstExclusive, false, lastExclusive, false);
|
||||
else if (from == Bound.EXCLUSIVE && to == Bound.INCLUSIVE) return set.subSet(firstExclusive, false, lastInclusive, true);
|
||||
else if (from == Bound.INCLUSIVE && to == Bound.INCLUSIVE) return set.subSet(firstInclusive, true, lastInclusive, true);
|
||||
return (NAVIGABLE_SET KEY_GENERIC_TYPE)super.createSubSet(set, firstExclusive, lastExclusive);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
package speiger.src.testers.PACKAGE.impl;
|
||||
|
||||
#if TYPE_OBJECT
|
||||
import java.util.Comparator;
|
||||
#endif
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.testing.DerivedCollectionGenerators.Bound;
|
||||
|
||||
import speiger.src.collections.PACKAGE.collections.ITERABLE;
|
||||
#if !TYPE_OBJECT
|
||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||
#endif
|
||||
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||
import speiger.src.collections.PACKAGE.sets.NAVIGABLE_SET;
|
||||
import speiger.src.collections.PACKAGE.sets.SORTED_SET;
|
||||
import speiger.src.testers.PACKAGE.generators.TEST_SORTED_SET_GENERATOR;
|
||||
import speiger.src.testers.PACKAGE.generators.TEST_NAVIGABLE_SET_GENERATOR;
|
||||
import speiger.src.testers.PACKAGE.utils.SAMPLE_ELEMENTS;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public class SUB_SORTED_SET_CLASS_GENERATOR KEY_GENERIC_TYPE implements TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE
|
||||
{
|
||||
final Bound to;
|
||||
final Bound from;
|
||||
final KEY_TYPE firstInclusive;
|
||||
final KEY_TYPE lastInclusive;
|
||||
private final COMPARATOR KEY_GENERIC_TYPE comparator;
|
||||
private final TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE delegate;
|
||||
|
||||
public SUB_SORTED_SET_CLASS_GENERATOR(TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE delegate, Bound to, Bound from) {
|
||||
this.to = to;
|
||||
this.from = from;
|
||||
this.delegate = delegate;
|
||||
|
||||
SORTED_SET KEY_GENERIC_TYPE emptySet = delegate.create(NEW_KEY_ARRAY(0));
|
||||
comparator = emptySet.comparator();
|
||||
|
||||
SAMPLE_ELEMENTS KEY_GENERIC_TYPE samples = delegate.getSamples();
|
||||
LIST KEY_GENERIC_TYPE samplesList = new ARRAY_LISTBRACES(samples.asList());
|
||||
samplesList.sort(comparator);
|
||||
firstInclusive = samplesList.GET_KEY(0);
|
||||
lastInclusive = samplesList.GET_KEY(samplesList.size() - 1);
|
||||
}
|
||||
|
||||
public final TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE getInnerGenerator() {
|
||||
return delegate;
|
||||
}
|
||||
|
||||
public final Bound getTo() {
|
||||
return to;
|
||||
}
|
||||
|
||||
public final Bound getFrom() {
|
||||
return from;
|
||||
}
|
||||
|
||||
SORTED_SET KEY_GENERIC_TYPE createSubSet(SORTED_SET KEY_GENERIC_TYPE set, KEY_TYPE firstExclusive, KEY_TYPE lastExclusive) {
|
||||
if (from == Bound.NO_BOUND && to == Bound.EXCLUSIVE) {
|
||||
return set.headSet(lastExclusive);
|
||||
} else if (from == Bound.INCLUSIVE && to == Bound.NO_BOUND) {
|
||||
return set.tailSet(firstInclusive);
|
||||
} else if (from == Bound.INCLUSIVE && to == Bound.EXCLUSIVE) {
|
||||
return set.subSet(firstInclusive, lastExclusive);
|
||||
} else {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public KEY_TYPE belowSamplesLesser() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public KEY_TYPE belowSamplesGreater() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public KEY_TYPE aboveSamplesLesser() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public KEY_TYPE aboveSamplesGreater() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SAMPLE_ELEMENTS KEY_GENERIC_TYPE getSamples() {
|
||||
return delegate.getSamples();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITERABLE KEY_GENERIC_TYPE order(LIST KEY_GENERIC_TYPE insertionOrder) {
|
||||
return delegate.order(insertionOrder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<CLASS_TYPE> order(List<CLASS_TYPE> insertionOrder) {
|
||||
return delegate.order(insertionOrder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SORTED_SET KEY_GENERIC_TYPE create(KEY_OBJECT_TYPE... elements) {
|
||||
#if TYPE_OBJECT
|
||||
LIST KEY_GENERIC_TYPE normalValues = (LIST KEY_GENERIC_TYPE)ARRAY_LIST.wrap(elements);
|
||||
#else
|
||||
LIST KEY_GENERIC_TYPE normalValues = ARRAY_LIST.wrap(elements);
|
||||
#endif
|
||||
LIST KEY_GENERIC_TYPE extremeValues = new ARRAY_LISTBRACES();
|
||||
KEY_TYPE firstExclusive = delegate.belowSamplesGreater();
|
||||
KEY_TYPE lastExclusive = delegate.aboveSamplesLesser();
|
||||
if (from != Bound.NO_BOUND) {
|
||||
extremeValues.add(delegate.belowSamplesLesser());
|
||||
extremeValues.add(delegate.belowSamplesGreater());
|
||||
}
|
||||
if (to != Bound.NO_BOUND) {
|
||||
extremeValues.add(delegate.aboveSamplesLesser());
|
||||
extremeValues.add(delegate.aboveSamplesGreater());
|
||||
}
|
||||
LIST KEY_GENERIC_TYPE allEntries = new ARRAY_LISTBRACES();
|
||||
allEntries.addAll(extremeValues);
|
||||
allEntries.addAll(normalValues);
|
||||
SORTED_SET KEY_GENERIC_TYPE set = delegate.create(allEntries.toArray());
|
||||
|
||||
return createSubSet(set, firstExclusive, lastExclusive);
|
||||
}
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
@Override
|
||||
public SORTED_SET KEY_GENERIC_TYPE create(Object... elements) {
|
||||
KEY_TYPE[] array = NEW_KEY_ARRAY(elements.length);
|
||||
int i = 0;
|
||||
for (Object e : elements) {
|
||||
array[i++] = CLASS_TO_KEY(e);
|
||||
}
|
||||
return create(array);
|
||||
}
|
||||
|
||||
#endif
|
||||
public static final class SUB_NAVIGABLE_SET_CLASS_GENERATOR KEY_GENERIC_TYPE extends SUB_SORTED_SET_CLASS_GENERATOR KEY_GENERIC_TYPE implements TEST_NAVIGABLE_SET_GENERATOR KEY_GENERIC_TYPE {
|
||||
public SUB_NAVIGABLE_SET_CLASS_GENERATOR(TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE delegate, Bound to, Bound from) {
|
||||
super(delegate, to, from);
|
||||
}
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
@Override
|
||||
public NAVIGABLE_SET KEY_GENERIC_TYPE create(KEY_TYPE... elements) {
|
||||
return (NAVIGABLE_SET KEY_GENERIC_TYPE)super.create(elements);
|
||||
}
|
||||
|
||||
#endif
|
||||
@Override
|
||||
public NAVIGABLE_SET KEY_GENERIC_TYPE create(Object... elements) {
|
||||
return (NAVIGABLE_SET KEY_GENERIC_TYPE)super.create(elements);
|
||||
}
|
||||
|
||||
@Override
|
||||
NAVIGABLE_SET KEY_GENERIC_TYPE createSubSet(SORTED_SET KEY_GENERIC_TYPE sortedSet, KEY_TYPE firstExclusive, KEY_TYPE lastExclusive) {
|
||||
NAVIGABLE_SET KEY_GENERIC_TYPE set = (NAVIGABLE_SET KEY_GENERIC_TYPE) sortedSet;
|
||||
if (from == Bound.NO_BOUND && to == Bound.INCLUSIVE) return set.headSet(lastInclusive, true);
|
||||
else if (from == Bound.EXCLUSIVE && to == Bound.NO_BOUND) return set.tailSet(firstExclusive, false);
|
||||
else if (from == Bound.EXCLUSIVE && to == Bound.EXCLUSIVE) return set.subSet(firstExclusive, false, lastExclusive, false);
|
||||
else if (from == Bound.EXCLUSIVE && to == Bound.INCLUSIVE) return set.subSet(firstExclusive, false, lastInclusive, true);
|
||||
else if (from == Bound.INCLUSIVE && to == Bound.INCLUSIVE) return set.subSet(firstInclusive, true, lastInclusive, true);
|
||||
return (NAVIGABLE_SET KEY_GENERIC_TYPE)super.createSubSet(set, firstExclusive, lastExclusive);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,200 +1,200 @@
|
|||
package speiger.src.testers.PACKAGE.impl.maps;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
#if TYPE_OBJECT
|
||||
import java.util.Objects;
|
||||
#endif
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import speiger.src.collections.PACKAGE.maps.abstracts.ABSTRACT_MAP;
|
||||
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
||||
import speiger.src.collections.PACKAGE.maps.interfaces.CONCURRENT_MAP;
|
||||
import speiger.src.collections.PACKAGE.maps.interfaces.ORDERED_MAP;
|
||||
import speiger.src.collections.PACKAGE.maps.interfaces.SORTED_MAP;
|
||||
import speiger.src.collections.objects.collections.ObjectIterable;
|
||||
#if TYPE_OBJECT || VALUE_OBJECT
|
||||
import speiger.src.collections.objects.utils.ObjectArrays;
|
||||
#endif
|
||||
import speiger.src.collections.objects.lists.ObjectList;
|
||||
import speiger.src.collections.objects.lists.ObjectArrayList;
|
||||
import speiger.src.testers.PACKAGE.generators.maps.TEST_MAP_GENERATOR;
|
||||
import speiger.src.testers.PACKAGE.generators.maps.TEST_ORDERED_MAP_GENERATOR;
|
||||
import speiger.src.testers.PACKAGE.generators.maps.TEST_SORTED_MAP_GENERATOR;
|
||||
import speiger.src.testers.objects.utils.ObjectSamples;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public class SIMPLE_MAP_TEST_GENERATOR KEY_VALUE_SPECIAL_GENERIC_TYPE<E extends MAP KEY_VALUE_GENERIC_TYPE>
|
||||
{
|
||||
BiFunction<KEY_TYPE[], VALUE_TYPE[], E> mapper;
|
||||
#if TYPE_BYTE
|
||||
KEY_TYPE[] keys = new KEY_TYPE[]{(byte)0, (byte)1, (byte)2, (byte)3, (byte)4, (byte)-2, (byte)-1, (byte)5, (byte)6};
|
||||
#else if TYPE_SHORT
|
||||
KEY_TYPE[] keys = new KEY_TYPE[]{(short)0, (short)1, (short)2, (short)3, (short)4, (short)-2, (short)-1, (short)5, (short)6};
|
||||
#else if TYPE_CHAR
|
||||
KEY_TYPE[] keys = new KEY_TYPE[]{(char)0, (char)1, (char)2, (char)3, (char)4};
|
||||
#else if TYPE_OBJECT
|
||||
KEY_TYPE[] keys;
|
||||
#else
|
||||
KEY_TYPE[] keys = new KEY_TYPE[]{0, 1, 2, 3, 4, -2, -1, 5, 6};
|
||||
#endif
|
||||
#if VALUE_BOOLEAN
|
||||
VALUE_TYPE[] values = new VALUE_TYPE[]{true, true, true, false, true, false, true, false, true};
|
||||
#else if VALUE_BYTE
|
||||
VALUE_TYPE[] values = new VALUE_TYPE[]{(byte)0, (byte)1, (byte)2, (byte)3, (byte)4, (byte)-2, (byte)-1, (byte)5, (byte)6};
|
||||
#else if VALUE_SHORT
|
||||
VALUE_TYPE[] values = new VALUE_TYPE[]{(short)0, (short)1, (short)2, (short)3, (short)4, (short)-2, (short)-1, (short)5, (short)6};
|
||||
#else if VALUE_CHAR
|
||||
VALUE_TYPE[] values = new VALUE_TYPE[]{(char)0, (char)1, (char)2, (char)3, (char)4};
|
||||
#else if VALUE_OBJECT
|
||||
VALUE_TYPE[] values;
|
||||
#else
|
||||
VALUE_TYPE[] values = new VALUE_TYPE[]{0, 1, 2, 3, 4, -2, -1, 5, 6};
|
||||
#endif
|
||||
|
||||
public SIMPLE_MAP_TEST_GENERATOR(BiFunction<KEY_TYPE[], VALUE_TYPE[], E> mapper) {
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
#if TYPE_OBJECT || TYPE_CHAR
|
||||
public void setKeys(KEY_TYPE... keys) {
|
||||
this.keys = keys;
|
||||
}
|
||||
|
||||
#endif
|
||||
#if VALUE_OBJECT || VALUE_CHAR
|
||||
public void setValues(VALUE_TYPE... values) {
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
#endif
|
||||
public ObjectSamples<MAP.Entry KEY_VALUE_GENERIC_TYPE> getSamples() {
|
||||
return new ObjectSamples<MAP.Entry KEY_VALUE_GENERIC_TYPE>(
|
||||
new ABSTRACT_MAP.BasicEntryKV_BRACES(keys[0], values[0]),
|
||||
new ABSTRACT_MAP.BasicEntryKV_BRACES(keys[1], values[1]),
|
||||
new ABSTRACT_MAP.BasicEntryKV_BRACES(keys[2], values[2]),
|
||||
new ABSTRACT_MAP.BasicEntryKV_BRACES(keys[3], values[3]),
|
||||
new ABSTRACT_MAP.BasicEntryKV_BRACES(keys[4], values[4])
|
||||
);
|
||||
}
|
||||
|
||||
public E create(MAP.Entry KEY_VALUE_GENERIC_TYPE... elements) {
|
||||
#if TYPE_OBJECT
|
||||
KEY_TYPE[] keys = (T[])ObjectArrays.newArray(getSamples().e0().ENTRY_KEY().getClass(), elements.length);
|
||||
#else
|
||||
KEY_TYPE[] keys = NEW_KEY_ARRAY(elements.length);
|
||||
#endif
|
||||
#if VALUE_OBJECT
|
||||
VALUE_TYPE[] values = (V[])ObjectArrays.newArray(getSamples().e0().ENTRY_VALUE().getClass(), elements.length);
|
||||
#else
|
||||
VALUE_TYPE[] values = NEW_VALUE_ARRAY(elements.length);
|
||||
#endif
|
||||
for(int i = 0;i<elements.length;i++) {
|
||||
keys[i] = elements[i].ENTRY_KEY();
|
||||
values[i] = elements[i].ENTRY_VALUE();
|
||||
}
|
||||
return mapper.apply(keys, values);
|
||||
}
|
||||
|
||||
public Iterable<Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>> order(List<Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>> insertionOrder) {
|
||||
return insertionOrder;
|
||||
}
|
||||
|
||||
public ObjectIterable<MAP.Entry KEY_VALUE_GENERIC_TYPE> order(ObjectList<MAP.Entry KEY_VALUE_GENERIC_TYPE> insertionOrder) {
|
||||
return insertionOrder;
|
||||
}
|
||||
|
||||
public static class Maps KEY_VALUE_GENERIC_TYPE extends SIMPLE_MAP_TEST_GENERATOR KEY_VALUE_SPECIAL_GENERIC_TYPE<MAP KEY_VALUE_GENERIC_TYPE> implements TEST_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE
|
||||
{
|
||||
public Maps(BiFunction<KEY_TYPE[], VALUE_TYPE[], MAP KEY_VALUE_GENERIC_TYPE> mapper) {
|
||||
super(mapper);
|
||||
}
|
||||
}
|
||||
|
||||
public static class OrderedMaps KEY_VALUE_GENERIC_TYPE extends SIMPLE_MAP_TEST_GENERATOR KEY_VALUE_SPECIAL_GENERIC_TYPE<ORDERED_MAP KEY_VALUE_GENERIC_TYPE> implements TEST_ORDERED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE
|
||||
{
|
||||
public OrderedMaps(BiFunction<KEY_TYPE[], VALUE_TYPE[], ORDERED_MAP KEY_VALUE_GENERIC_TYPE> mapper) {
|
||||
super(mapper);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ConcurrentMaps KEY_VALUE_GENERIC_TYPE extends SIMPLE_MAP_TEST_GENERATOR KEY_VALUE_SPECIAL_GENERIC_TYPE<CONCURRENT_MAP KEY_VALUE_GENERIC_TYPE> implements TEST_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE
|
||||
{
|
||||
Consumer<ObjectList<MAP.Entry KEY_VALUE_GENERIC_TYPE>> sorter;
|
||||
|
||||
public ConcurrentMaps(BiFunction<KEY_TYPE[], VALUE_TYPE[], CONCURRENT_MAP KEY_VALUE_GENERIC_TYPE> mapper, Consumer<ObjectList<MAP.Entry KEY_VALUE_GENERIC_TYPE>> sorter) {
|
||||
super(mapper);
|
||||
this.sorter = sorter;
|
||||
}
|
||||
|
||||
public Iterable<Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>> order(List<Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>> insertionOrder) {
|
||||
ObjectList<MAP.Entry KEY_VALUE_GENERIC_TYPE> newList = new ObjectArrayList<>();
|
||||
for(Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE> entry : insertionOrder) {
|
||||
newList.add(new ABSTRACT_MAP.BasicEntryKV_BRACES(entry.getKey(), entry.getValue()));
|
||||
}
|
||||
order(newList);
|
||||
insertionOrder.sort(new Comparator<Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>>() {
|
||||
@Override
|
||||
public int compare(Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE> key, Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE> value) {
|
||||
return Integer.signum(indexOf(OBJ_TO_KEY(key.getKey())) - indexOf(OBJ_TO_KEY(value.getKey())));
|
||||
}
|
||||
|
||||
protected int indexOf(KEY_TYPE key) {
|
||||
for(int i = 0,m=newList.size();i<m;i++) {
|
||||
if(KEY_EQUALS(newList.get(i).ENTRY_KEY(), key)) return i;
|
||||
}
|
||||
throw new IllegalArgumentException("MAP.entry sorter was corrupting data");
|
||||
}
|
||||
});
|
||||
return insertionOrder;
|
||||
}
|
||||
|
||||
public ObjectIterable<MAP.Entry KEY_VALUE_GENERIC_TYPE> order(ObjectList<MAP.Entry KEY_VALUE_GENERIC_TYPE> insertionOrder) {
|
||||
sorter.accept(insertionOrder);
|
||||
return insertionOrder;
|
||||
}
|
||||
}
|
||||
|
||||
public static class SortedMaps KEY_VALUE_GENERIC_TYPE extends SIMPLE_MAP_TEST_GENERATOR KEY_VALUE_SPECIAL_GENERIC_TYPE<SORTED_MAP KEY_VALUE_GENERIC_TYPE> implements TEST_SORTED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE
|
||||
{
|
||||
public SortedMaps(BiFunction<KEY_TYPE[], VALUE_TYPE[], SORTED_MAP KEY_VALUE_GENERIC_TYPE> mapper) {
|
||||
super(mapper);
|
||||
#if TYPE_CHAR
|
||||
setKeys(new KEY_TYPE[]{'a', 'b', 'c', 'd', 'e', '_', '`', 'f', 'g'});
|
||||
#endif
|
||||
#if VALUE_CHAR
|
||||
setValues(new VALUE_TYPE[]{'a', 'b', 'c', 'd', 'e', '_', '`', 'f', 'g'});
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
public Iterable<Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>> order(List<Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>> insertionOrder) {
|
||||
#if TYPE_OBJECT
|
||||
insertionOrder.sort(DERIVED_MAP_GENERATORS.entryObjectComparator((Comparator<T>)Comparator.naturalOrder()));
|
||||
#else
|
||||
insertionOrder.sort(DERIVED_MAP_GENERATORS.entryObjectComparator(CLASS_TYPE::compare));
|
||||
#endif
|
||||
return insertionOrder;
|
||||
}
|
||||
|
||||
public ObjectIterable<MAP.Entry KEY_VALUE_GENERIC_TYPE> order(ObjectList<MAP.Entry KEY_VALUE_GENERIC_TYPE> insertionOrder) {
|
||||
#if TYPE_OBJECT
|
||||
insertionOrder.sort(DERIVED_MAP_GENERATORS.entryComparator((Comparator<T>)Comparator.naturalOrder()));
|
||||
#else
|
||||
insertionOrder.sort(DERIVED_MAP_GENERATORS.entryComparator(CLASS_TYPE::compare));
|
||||
#endif
|
||||
return insertionOrder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE belowSamplesLesser() { return new ABSTRACT_MAP.BasicEntryKV_BRACES(keys[5], values[5]); }
|
||||
@Override
|
||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE belowSamplesGreater() { return new ABSTRACT_MAP.BasicEntryKV_BRACES(keys[6], values[6]); }
|
||||
@Override
|
||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE aboveSamplesLesser() { return new ABSTRACT_MAP.BasicEntryKV_BRACES(keys[7], values[7]); }
|
||||
@Override
|
||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE aboveSamplesGreater() { return new ABSTRACT_MAP.BasicEntryKV_BRACES(keys[8], values[8]); }
|
||||
}
|
||||
}
|
||||
package speiger.src.testers.PACKAGE.impl.maps;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
#if TYPE_OBJECT
|
||||
import java.util.Objects;
|
||||
#endif
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import speiger.src.collections.PACKAGE.maps.abstracts.ABSTRACT_MAP;
|
||||
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
||||
import speiger.src.collections.PACKAGE.maps.interfaces.CONCURRENT_MAP;
|
||||
import speiger.src.collections.PACKAGE.maps.interfaces.ORDERED_MAP;
|
||||
import speiger.src.collections.PACKAGE.maps.interfaces.SORTED_MAP;
|
||||
import speiger.src.collections.objects.collections.ObjectIterable;
|
||||
#if TYPE_OBJECT || VALUE_OBJECT
|
||||
import speiger.src.collections.objects.utils.ObjectArrays;
|
||||
#endif
|
||||
import speiger.src.collections.objects.lists.ObjectList;
|
||||
import speiger.src.collections.objects.lists.ObjectArrayList;
|
||||
import speiger.src.testers.PACKAGE.generators.maps.TEST_MAP_GENERATOR;
|
||||
import speiger.src.testers.PACKAGE.generators.maps.TEST_ORDERED_MAP_GENERATOR;
|
||||
import speiger.src.testers.PACKAGE.generators.maps.TEST_SORTED_MAP_GENERATOR;
|
||||
import speiger.src.testers.objects.utils.ObjectSamples;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public class SIMPLE_MAP_TEST_GENERATOR KEY_VALUE_SPECIAL_GENERIC_TYPE<E extends MAP KEY_VALUE_GENERIC_TYPE>
|
||||
{
|
||||
BiFunction<KEY_TYPE[], VALUE_TYPE[], E> mapper;
|
||||
#if TYPE_BYTE
|
||||
KEY_TYPE[] keys = new KEY_TYPE[]{(byte)0, (byte)1, (byte)2, (byte)3, (byte)4, (byte)-2, (byte)-1, (byte)5, (byte)6};
|
||||
#else if TYPE_SHORT
|
||||
KEY_TYPE[] keys = new KEY_TYPE[]{(short)0, (short)1, (short)2, (short)3, (short)4, (short)-2, (short)-1, (short)5, (short)6};
|
||||
#else if TYPE_CHAR
|
||||
KEY_TYPE[] keys = new KEY_TYPE[]{(char)0, (char)1, (char)2, (char)3, (char)4};
|
||||
#else if TYPE_OBJECT
|
||||
KEY_TYPE[] keys;
|
||||
#else
|
||||
KEY_TYPE[] keys = new KEY_TYPE[]{0, 1, 2, 3, 4, -2, -1, 5, 6};
|
||||
#endif
|
||||
#if VALUE_BOOLEAN
|
||||
VALUE_TYPE[] values = new VALUE_TYPE[]{true, true, true, false, true, false, true, false, true};
|
||||
#else if VALUE_BYTE
|
||||
VALUE_TYPE[] values = new VALUE_TYPE[]{(byte)0, (byte)1, (byte)2, (byte)3, (byte)4, (byte)-2, (byte)-1, (byte)5, (byte)6};
|
||||
#else if VALUE_SHORT
|
||||
VALUE_TYPE[] values = new VALUE_TYPE[]{(short)0, (short)1, (short)2, (short)3, (short)4, (short)-2, (short)-1, (short)5, (short)6};
|
||||
#else if VALUE_CHAR
|
||||
VALUE_TYPE[] values = new VALUE_TYPE[]{(char)0, (char)1, (char)2, (char)3, (char)4};
|
||||
#else if VALUE_OBJECT
|
||||
VALUE_TYPE[] values;
|
||||
#else
|
||||
VALUE_TYPE[] values = new VALUE_TYPE[]{0, 1, 2, 3, 4, -2, -1, 5, 6};
|
||||
#endif
|
||||
|
||||
public SIMPLE_MAP_TEST_GENERATOR(BiFunction<KEY_TYPE[], VALUE_TYPE[], E> mapper) {
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
#if TYPE_OBJECT || TYPE_CHAR
|
||||
public void setKeys(KEY_TYPE... keys) {
|
||||
this.keys = keys;
|
||||
}
|
||||
|
||||
#endif
|
||||
#if VALUE_OBJECT || VALUE_CHAR
|
||||
public void setValues(VALUE_TYPE... values) {
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
#endif
|
||||
public ObjectSamples<MAP.Entry KEY_VALUE_GENERIC_TYPE> getSamples() {
|
||||
return new ObjectSamples<MAP.Entry KEY_VALUE_GENERIC_TYPE>(
|
||||
new ABSTRACT_MAP.BasicEntryKV_BRACES(keys[0], values[0]),
|
||||
new ABSTRACT_MAP.BasicEntryKV_BRACES(keys[1], values[1]),
|
||||
new ABSTRACT_MAP.BasicEntryKV_BRACES(keys[2], values[2]),
|
||||
new ABSTRACT_MAP.BasicEntryKV_BRACES(keys[3], values[3]),
|
||||
new ABSTRACT_MAP.BasicEntryKV_BRACES(keys[4], values[4])
|
||||
);
|
||||
}
|
||||
|
||||
public E create(MAP.Entry KEY_VALUE_GENERIC_TYPE... elements) {
|
||||
#if TYPE_OBJECT
|
||||
KEY_TYPE[] keys = (T[])ObjectArrays.newArray(getSamples().e0().ENTRY_KEY().getClass(), elements.length);
|
||||
#else
|
||||
KEY_TYPE[] keys = NEW_KEY_ARRAY(elements.length);
|
||||
#endif
|
||||
#if VALUE_OBJECT
|
||||
VALUE_TYPE[] values = (V[])ObjectArrays.newArray(getSamples().e0().ENTRY_VALUE().getClass(), elements.length);
|
||||
#else
|
||||
VALUE_TYPE[] values = NEW_VALUE_ARRAY(elements.length);
|
||||
#endif
|
||||
for(int i = 0;i<elements.length;i++) {
|
||||
keys[i] = elements[i].ENTRY_KEY();
|
||||
values[i] = elements[i].ENTRY_VALUE();
|
||||
}
|
||||
return mapper.apply(keys, values);
|
||||
}
|
||||
|
||||
public Iterable<Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>> order(List<Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>> insertionOrder) {
|
||||
return insertionOrder;
|
||||
}
|
||||
|
||||
public ObjectIterable<MAP.Entry KEY_VALUE_GENERIC_TYPE> order(ObjectList<MAP.Entry KEY_VALUE_GENERIC_TYPE> insertionOrder) {
|
||||
return insertionOrder;
|
||||
}
|
||||
|
||||
public static class Maps KEY_VALUE_GENERIC_TYPE extends SIMPLE_MAP_TEST_GENERATOR KEY_VALUE_SPECIAL_GENERIC_TYPE<MAP KEY_VALUE_GENERIC_TYPE> implements TEST_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE
|
||||
{
|
||||
public Maps(BiFunction<KEY_TYPE[], VALUE_TYPE[], MAP KEY_VALUE_GENERIC_TYPE> mapper) {
|
||||
super(mapper);
|
||||
}
|
||||
}
|
||||
|
||||
public static class OrderedMaps KEY_VALUE_GENERIC_TYPE extends SIMPLE_MAP_TEST_GENERATOR KEY_VALUE_SPECIAL_GENERIC_TYPE<ORDERED_MAP KEY_VALUE_GENERIC_TYPE> implements TEST_ORDERED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE
|
||||
{
|
||||
public OrderedMaps(BiFunction<KEY_TYPE[], VALUE_TYPE[], ORDERED_MAP KEY_VALUE_GENERIC_TYPE> mapper) {
|
||||
super(mapper);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ConcurrentMaps KEY_VALUE_GENERIC_TYPE extends SIMPLE_MAP_TEST_GENERATOR KEY_VALUE_SPECIAL_GENERIC_TYPE<CONCURRENT_MAP KEY_VALUE_GENERIC_TYPE> implements TEST_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE
|
||||
{
|
||||
Consumer<ObjectList<MAP.Entry KEY_VALUE_GENERIC_TYPE>> sorter;
|
||||
|
||||
public ConcurrentMaps(BiFunction<KEY_TYPE[], VALUE_TYPE[], CONCURRENT_MAP KEY_VALUE_GENERIC_TYPE> mapper, Consumer<ObjectList<MAP.Entry KEY_VALUE_GENERIC_TYPE>> sorter) {
|
||||
super(mapper);
|
||||
this.sorter = sorter;
|
||||
}
|
||||
|
||||
public Iterable<Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>> order(List<Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>> insertionOrder) {
|
||||
ObjectList<MAP.Entry KEY_VALUE_GENERIC_TYPE> newList = new ObjectArrayList<>();
|
||||
for(Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE> entry : insertionOrder) {
|
||||
newList.add(new ABSTRACT_MAP.BasicEntryKV_BRACES(entry.getKey(), entry.getValue()));
|
||||
}
|
||||
order(newList);
|
||||
insertionOrder.sort(new Comparator<Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>>() {
|
||||
@Override
|
||||
public int compare(Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE> key, Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE> value) {
|
||||
return Integer.signum(indexOf(OBJ_TO_KEY(key.getKey())) - indexOf(OBJ_TO_KEY(value.getKey())));
|
||||
}
|
||||
|
||||
protected int indexOf(KEY_TYPE key) {
|
||||
for(int i = 0,m=newList.size();i<m;i++) {
|
||||
if(KEY_EQUALS(newList.get(i).ENTRY_KEY(), key)) return i;
|
||||
}
|
||||
throw new IllegalArgumentException("MAP.entry sorter was corrupting data");
|
||||
}
|
||||
});
|
||||
return insertionOrder;
|
||||
}
|
||||
|
||||
public ObjectIterable<MAP.Entry KEY_VALUE_GENERIC_TYPE> order(ObjectList<MAP.Entry KEY_VALUE_GENERIC_TYPE> insertionOrder) {
|
||||
sorter.accept(insertionOrder);
|
||||
return insertionOrder;
|
||||
}
|
||||
}
|
||||
|
||||
public static class SortedMaps KEY_VALUE_GENERIC_TYPE extends SIMPLE_MAP_TEST_GENERATOR KEY_VALUE_SPECIAL_GENERIC_TYPE<SORTED_MAP KEY_VALUE_GENERIC_TYPE> implements TEST_SORTED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE
|
||||
{
|
||||
public SortedMaps(BiFunction<KEY_TYPE[], VALUE_TYPE[], SORTED_MAP KEY_VALUE_GENERIC_TYPE> mapper) {
|
||||
super(mapper);
|
||||
#if TYPE_CHAR
|
||||
setKeys(new KEY_TYPE[]{'a', 'b', 'c', 'd', 'e', '_', '`', 'f', 'g'});
|
||||
#endif
|
||||
#if VALUE_CHAR
|
||||
setValues(new VALUE_TYPE[]{'a', 'b', 'c', 'd', 'e', '_', '`', 'f', 'g'});
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
public Iterable<Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>> order(List<Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>> insertionOrder) {
|
||||
#if TYPE_OBJECT
|
||||
insertionOrder.sort(DERIVED_MAP_GENERATORS.entryObjectComparator((Comparator<T>)Comparator.naturalOrder()));
|
||||
#else
|
||||
insertionOrder.sort(DERIVED_MAP_GENERATORS.entryObjectComparator(CLASS_TYPE::compare));
|
||||
#endif
|
||||
return insertionOrder;
|
||||
}
|
||||
|
||||
public ObjectIterable<MAP.Entry KEY_VALUE_GENERIC_TYPE> order(ObjectList<MAP.Entry KEY_VALUE_GENERIC_TYPE> insertionOrder) {
|
||||
#if TYPE_OBJECT
|
||||
insertionOrder.sort(DERIVED_MAP_GENERATORS.entryComparator((Comparator<T>)Comparator.naturalOrder()));
|
||||
#else
|
||||
insertionOrder.sort(DERIVED_MAP_GENERATORS.entryComparator(CLASS_TYPE::compare));
|
||||
#endif
|
||||
return insertionOrder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE belowSamplesLesser() { return new ABSTRACT_MAP.BasicEntryKV_BRACES(keys[5], values[5]); }
|
||||
@Override
|
||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE belowSamplesGreater() { return new ABSTRACT_MAP.BasicEntryKV_BRACES(keys[6], values[6]); }
|
||||
@Override
|
||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE aboveSamplesLesser() { return new ABSTRACT_MAP.BasicEntryKV_BRACES(keys[7], values[7]); }
|
||||
@Override
|
||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE aboveSamplesGreater() { return new ABSTRACT_MAP.BasicEntryKV_BRACES(keys[8], values[8]); }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,92 +1,92 @@
|
|||
package speiger.src.testers.PACKAGE.impl.maps;
|
||||
|
||||
import speiger.src.collections.PACKAGE.maps.abstracts.ABSTRACT_MAP;
|
||||
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
||||
import speiger.src.collections.PACKAGE.maps.impl.misc.ARRAY_MAP;
|
||||
import speiger.src.collections.objects.collections.ObjectIterator;
|
||||
import speiger.src.collections.objects.sets.AbstractObjectSet;
|
||||
import speiger.src.collections.objects.sets.ObjectSet;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public class SIMPLE_TEST_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE
|
||||
{
|
||||
MAP KEY_VALUE_GENERIC_TYPE map;
|
||||
|
||||
public SIMPLE_TEST_MAP(KEY_TYPE[] keys, VALUE_TYPE[] values) {
|
||||
map = new ARRAY_MAPKV_BRACES(keys, values);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE setDefaultReturnValue(VALUE_TYPE v) {
|
||||
map.setDefaultReturnValue(v);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VALUE_TYPE getDefaultReturnValue() { return map.getDefaultReturnValue(); }
|
||||
|
||||
@Override
|
||||
public VALUE_TYPE put(KEY_TYPE key, VALUE_TYPE value) { return map.put(key, value); }
|
||||
@Override
|
||||
public VALUE_TYPE putIfAbsent(KEY_TYPE key, VALUE_TYPE value) { return map.putIfAbsent(key, value); }
|
||||
#if VALUE_PRIMITIVES
|
||||
@Override
|
||||
public VALUE_TYPE addTo(KEY_TYPE key, VALUE_TYPE value) { return map.addTo(key, value); }
|
||||
@Override
|
||||
public VALUE_TYPE subFrom(KEY_TYPE key, VALUE_TYPE value) { return map.subFrom(key, value); }
|
||||
#endif
|
||||
@Override
|
||||
public VALUE_TYPE REMOVE_VALUE(KEY_TYPE key) { return map.REMOVE_VALUE(key); }
|
||||
@Override
|
||||
public VALUE_TYPE REMOVE_VALUEOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) { return map.REMOVE_VALUEOrDefault(key, defaultValue); }
|
||||
#if !TYPE_OBJECT || !VALUE_OBJECT
|
||||
@Override
|
||||
public boolean remove(KEY_TYPE key, VALUE_TYPE value) { return map.remove(key, value); }
|
||||
#endif
|
||||
@Override
|
||||
public CLASS_VALUE_TYPE remove(Object key) { return map.remove(key); }
|
||||
@Override
|
||||
public boolean remove(Object key, Object value) { return map.remove(key, value); }
|
||||
@Override
|
||||
public VALUE_TYPE GET_VALUE(KEY_TYPE key) { return map.GET_VALUE(key); }
|
||||
#if TYPE_OBJECT && !VALUE_OBJECT
|
||||
@Override
|
||||
public VALUE_TYPE getOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) { return map.getOrDefault(key, defaultValue); }
|
||||
#endif
|
||||
@Override
|
||||
public ObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> ENTRY_SET() {
|
||||
return new AbstractObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE>() {
|
||||
@Override
|
||||
public ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iterator() {
|
||||
return new ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE>() {
|
||||
ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = map.ENTRY_SET().iterator();
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return iter.hasNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE next() {
|
||||
MAP.Entry KEY_VALUE_GENERIC_TYPE entry = iter.next();
|
||||
return new ABSTRACT_MAP.BasicEntry KEY_VALUE_GENERIC_TYPE(entry.ENTRY_KEY(), entry.ENTRY_VALUE()) {
|
||||
@Override
|
||||
public VALUE_TYPE setValue(VALUE_TYPE value) {
|
||||
return entry.setValue(value);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
iter.remove();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return map.size();
|
||||
}
|
||||
};
|
||||
}
|
||||
package speiger.src.testers.PACKAGE.impl.maps;
|
||||
|
||||
import speiger.src.collections.PACKAGE.maps.abstracts.ABSTRACT_MAP;
|
||||
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
||||
import speiger.src.collections.PACKAGE.maps.impl.misc.ARRAY_MAP;
|
||||
import speiger.src.collections.objects.collections.ObjectIterator;
|
||||
import speiger.src.collections.objects.sets.AbstractObjectSet;
|
||||
import speiger.src.collections.objects.sets.ObjectSet;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public class SIMPLE_TEST_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE
|
||||
{
|
||||
MAP KEY_VALUE_GENERIC_TYPE map;
|
||||
|
||||
public SIMPLE_TEST_MAP(KEY_TYPE[] keys, VALUE_TYPE[] values) {
|
||||
map = new ARRAY_MAPKV_BRACES(keys, values);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE setDefaultReturnValue(VALUE_TYPE v) {
|
||||
map.setDefaultReturnValue(v);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VALUE_TYPE getDefaultReturnValue() { return map.getDefaultReturnValue(); }
|
||||
|
||||
@Override
|
||||
public VALUE_TYPE put(KEY_TYPE key, VALUE_TYPE value) { return map.put(key, value); }
|
||||
@Override
|
||||
public VALUE_TYPE putIfAbsent(KEY_TYPE key, VALUE_TYPE value) { return map.putIfAbsent(key, value); }
|
||||
#if VALUE_PRIMITIVES
|
||||
@Override
|
||||
public VALUE_TYPE addTo(KEY_TYPE key, VALUE_TYPE value) { return map.addTo(key, value); }
|
||||
@Override
|
||||
public VALUE_TYPE subFrom(KEY_TYPE key, VALUE_TYPE value) { return map.subFrom(key, value); }
|
||||
#endif
|
||||
@Override
|
||||
public VALUE_TYPE REMOVE_VALUE(KEY_TYPE key) { return map.REMOVE_VALUE(key); }
|
||||
@Override
|
||||
public VALUE_TYPE REMOVE_VALUEOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) { return map.REMOVE_VALUEOrDefault(key, defaultValue); }
|
||||
#if !TYPE_OBJECT || !VALUE_OBJECT
|
||||
@Override
|
||||
public boolean remove(KEY_TYPE key, VALUE_TYPE value) { return map.remove(key, value); }
|
||||
#endif
|
||||
@Override
|
||||
public CLASS_VALUE_TYPE remove(Object key) { return map.remove(key); }
|
||||
@Override
|
||||
public boolean remove(Object key, Object value) { return map.remove(key, value); }
|
||||
@Override
|
||||
public VALUE_TYPE GET_VALUE(KEY_TYPE key) { return map.GET_VALUE(key); }
|
||||
#if TYPE_OBJECT && !VALUE_OBJECT
|
||||
@Override
|
||||
public VALUE_TYPE getOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) { return map.getOrDefault(key, defaultValue); }
|
||||
#endif
|
||||
@Override
|
||||
public ObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> ENTRY_SET() {
|
||||
return new AbstractObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE>() {
|
||||
@Override
|
||||
public ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iterator() {
|
||||
return new ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE>() {
|
||||
ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = map.ENTRY_SET().iterator();
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return iter.hasNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE next() {
|
||||
MAP.Entry KEY_VALUE_GENERIC_TYPE entry = iter.next();
|
||||
return new ABSTRACT_MAP.BasicEntry KEY_VALUE_GENERIC_TYPE(entry.ENTRY_KEY(), entry.ENTRY_VALUE()) {
|
||||
@Override
|
||||
public VALUE_TYPE setValue(VALUE_TYPE value) {
|
||||
return entry.setValue(value);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
iter.remove();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return map.size();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,28 +1,28 @@
|
|||
package speiger.src.testers.PACKAGE.tests.base;
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE extends ABSTRACT_CONTAINER_TESTER KKS_GENERIC_TYPE<COLLECTION KEY_CLASS_GENERIC_TYPE>
|
||||
{
|
||||
protected COLLECTION KEY_GENERIC_TYPE collection;
|
||||
|
||||
@Override
|
||||
protected COLLECTION KEY_GENERIC_TYPE actualContents() {
|
||||
return collection;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected COLLECTION KEY_GENERIC_TYPE resetContainer(COLLECTION KEY_GENERIC_TYPE newContents) {
|
||||
collection = super.resetContainer(newContents);
|
||||
return collection;
|
||||
}
|
||||
|
||||
protected void resetCollection() {
|
||||
resetContainer();
|
||||
}
|
||||
|
||||
}
|
||||
package speiger.src.testers.PACKAGE.tests.base;
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE extends ABSTRACT_CONTAINER_TESTER KKS_GENERIC_TYPE<COLLECTION KEY_CLASS_GENERIC_TYPE>
|
||||
{
|
||||
protected COLLECTION KEY_GENERIC_TYPE collection;
|
||||
|
||||
@Override
|
||||
protected COLLECTION KEY_GENERIC_TYPE actualContents() {
|
||||
return collection;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected COLLECTION KEY_GENERIC_TYPE resetContainer(COLLECTION KEY_GENERIC_TYPE newContents) {
|
||||
collection = super.resetContainer(newContents);
|
||||
return collection;
|
||||
}
|
||||
|
||||
protected void resetCollection() {
|
||||
resetContainer();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,188 +1,188 @@
|
|||
package speiger.src.testers.PACKAGE.tests.base;
|
||||
|
||||
import com.google.common.collect.testing.AbstractTester;
|
||||
import com.google.common.collect.testing.OneSizeTestContainerGenerator;
|
||||
import com.google.common.collect.testing.TestContainerGenerator;
|
||||
import com.google.common.collect.testing.features.CollectionSize;
|
||||
import com.google.errorprone.annotations.OverridingMethodsMustInvokeSuper;
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||
import speiger.src.collections.PACKAGE.utils.LISTS;
|
||||
import speiger.src.testers.PACKAGE.generators.TEST_COLLECTION_GENERATOR;
|
||||
import speiger.src.testers.PACKAGE.utils.HELPERS;
|
||||
import speiger.src.testers.PACKAGE.utils.SAMPLE_ELEMENTS;
|
||||
import speiger.src.testers.PACKAGE.utils.MINIMAL_COLLECTION;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public abstract class ABSTRACT_CONTAINER_TESTER KKS_GENERIC_TYPE<E> extends AbstractTester<OneSizeTestContainerGenerator<E, CLASS_TYPE>>
|
||||
{
|
||||
protected SAMPLE_ELEMENTS KEY_GENERIC_TYPE samples;
|
||||
protected E container;
|
||||
protected TEST_COLLECTION_GENERATOR KEY_GENERIC_TYPE primitiveGenerator;
|
||||
protected CollectionSize size;
|
||||
|
||||
@Override
|
||||
@OverridingMethodsMustInvokeSuper
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
setupGenerator();
|
||||
}
|
||||
|
||||
protected void setupGenerator() {
|
||||
TestContainerGenerator<E, CLASS_TYPE> generator = getSubjectGenerator().getInnerGenerator();
|
||||
if (!(generator instanceof TEST_COLLECTION_GENERATOR)) throw new IllegalStateException("Test Generator Must extend TEST_COLLECTION_GENERATOR");
|
||||
primitiveGenerator = (TEST_COLLECTION_GENERATOR KEY_GENERIC_TYPE) generator;
|
||||
samples = primitiveGenerator.getSamples();
|
||||
size = getSubjectGenerator().getCollectionSize();
|
||||
resetContainer();
|
||||
}
|
||||
|
||||
protected abstract COLLECTION KEY_GENERIC_TYPE actualContents();
|
||||
|
||||
protected E resetContainer() {
|
||||
return resetContainer(createTestSubject());
|
||||
}
|
||||
|
||||
protected E resetContainer(E newValue) {
|
||||
container = newValue;
|
||||
return container;
|
||||
}
|
||||
|
||||
protected void expectContents(KEY_TYPE... elements) {
|
||||
expectContents(ARRAY_LIST.wrap(elements));
|
||||
}
|
||||
|
||||
protected void expectContents(COLLECTION KEY_GENERIC_TYPE expected) {
|
||||
HELPERS.assertEqualIgnoringOrder(expected, actualContents());
|
||||
}
|
||||
|
||||
protected void expectUnchanged() {
|
||||
expectContents(getOrderedElements());
|
||||
}
|
||||
|
||||
protected final void expectAdded(KEY_TYPE... elements) {
|
||||
LIST KEY_GENERIC_TYPE expected = HELPERS.copyToList(getSampleElements());
|
||||
expected.addAll(elements);
|
||||
expectContents(expected);
|
||||
}
|
||||
|
||||
protected final void expectAddedIndex(int index, KEY_TYPE... elements) {
|
||||
expectAdded(index, ARRAY_LIST.wrap(elements));
|
||||
}
|
||||
|
||||
protected final void expectAdded(int index, COLLECTION KEY_GENERIC_TYPE elements) {
|
||||
LIST KEY_GENERIC_TYPE expected = HELPERS.copyToList(getSampleElements());
|
||||
expected.addAll(index, elements);
|
||||
expectContents(expected);
|
||||
}
|
||||
|
||||
protected void expectMissing(KEY_TYPE... elements) {
|
||||
for (KEY_TYPE element : elements) {
|
||||
assertFalse("Should not contain " + element, actualContents().contains(element));
|
||||
}
|
||||
}
|
||||
|
||||
protected KEY_TYPE[] createSamplesArray() {
|
||||
return getSampleElements().TO_ARRAY(NEW_KEY_ARRAY(getNumElements()));
|
||||
}
|
||||
|
||||
protected KEY_TYPE[] createOrderedArray() {
|
||||
return getOrderedElements().TO_ARRAY(NEW_KEY_ARRAY(getNumElements()));
|
||||
}
|
||||
|
||||
public static class ArrayWithDuplicate KEY_GENERIC_TYPE {
|
||||
public final KEY_TYPE[] elements;
|
||||
public final KEY_TYPE duplicate;
|
||||
|
||||
private ArrayWithDuplicate(KEY_TYPE[] elements, KEY_TYPE duplicate) {
|
||||
this.elements = elements;
|
||||
this.duplicate = duplicate;
|
||||
}
|
||||
}
|
||||
|
||||
protected ArrayWithDuplicate KEY_GENERIC_TYPE createArrayWithDuplicateElement() {
|
||||
KEY_TYPE[] elements = createSamplesArray();
|
||||
KEY_TYPE duplicate = elements[(elements.length / 2) - 1];
|
||||
elements[(elements.length / 2) + 1] = duplicate;
|
||||
return new ArrayWithDuplicateBRACES(elements, duplicate);
|
||||
}
|
||||
|
||||
protected int getNumElements() {
|
||||
return size.getNumElements();
|
||||
}
|
||||
|
||||
protected COLLECTION KEY_GENERIC_TYPE getSampleElements() {
|
||||
return getSampleElements(getNumElements());
|
||||
}
|
||||
|
||||
protected LIST KEY_GENERIC_TYPE getOrderedElements() {
|
||||
LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES();
|
||||
for (ITERATOR KEY_GENERIC_TYPE iter = primitiveGenerator.order(new ARRAY_LISTBRACES(getSampleElements())).iterator(); iter.hasNext();) {
|
||||
list.add(iter.NEXT());
|
||||
}
|
||||
return LISTS.unmodifiable(list);
|
||||
}
|
||||
|
||||
#if TYPE_OBJECT
|
||||
protected KEY_TYPE[] createDisjointArray() {
|
||||
KEY_TYPE[] array = NEW_KEY_ARRAY(2);
|
||||
array[0] = e3();
|
||||
array[1] = e4();
|
||||
return array;
|
||||
}
|
||||
#else
|
||||
protected KEY_TYPE[] createDisjointArray() {
|
||||
return new KEY_TYPE[]{e3(), e4()};
|
||||
}
|
||||
|
||||
#endif
|
||||
protected KEY_TYPE[] emptyArray() {
|
||||
return NEW_KEY_ARRAY(0);
|
||||
}
|
||||
|
||||
protected MINIMAL_COLLECTION KEY_GENERIC_TYPE createDisjointCollection() {
|
||||
return MINIMAL_COLLECTION.of(e3(), e4());
|
||||
}
|
||||
|
||||
protected MINIMAL_COLLECTION KEY_GENERIC_TYPE emptyCollection() {
|
||||
return MINIMAL_COLLECTION.of();
|
||||
}
|
||||
|
||||
public KEY_TYPE[] createArray(KEY_TYPE...array) {
|
||||
return array;
|
||||
}
|
||||
|
||||
protected final KEY_TYPE e0() {
|
||||
return samples.e0();
|
||||
}
|
||||
|
||||
protected final KEY_TYPE e1() {
|
||||
return samples.e1();
|
||||
}
|
||||
|
||||
protected final KEY_TYPE e2() {
|
||||
return samples.e2();
|
||||
}
|
||||
|
||||
protected final KEY_TYPE e3() {
|
||||
return samples.e3();
|
||||
}
|
||||
|
||||
protected final KEY_TYPE e4() {
|
||||
return samples.e4();
|
||||
}
|
||||
|
||||
protected E createTestSubject() {
|
||||
return (E)primitiveGenerator.create(getSampleElements(size.getNumElements()).TO_ARRAY(NEW_KEY_ARRAY(getNumElements())));
|
||||
}
|
||||
|
||||
protected COLLECTION KEY_GENERIC_TYPE getSampleElements(int howMany) {
|
||||
return new ARRAY_LISTBRACES(samples.asList().subList(0, howMany));
|
||||
}
|
||||
package speiger.src.testers.PACKAGE.tests.base;
|
||||
|
||||
import com.google.common.collect.testing.AbstractTester;
|
||||
import com.google.common.collect.testing.OneSizeTestContainerGenerator;
|
||||
import com.google.common.collect.testing.TestContainerGenerator;
|
||||
import com.google.common.collect.testing.features.CollectionSize;
|
||||
import com.google.errorprone.annotations.OverridingMethodsMustInvokeSuper;
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||
import speiger.src.collections.PACKAGE.utils.LISTS;
|
||||
import speiger.src.testers.PACKAGE.generators.TEST_COLLECTION_GENERATOR;
|
||||
import speiger.src.testers.PACKAGE.utils.HELPERS;
|
||||
import speiger.src.testers.PACKAGE.utils.SAMPLE_ELEMENTS;
|
||||
import speiger.src.testers.PACKAGE.utils.MINIMAL_COLLECTION;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public abstract class ABSTRACT_CONTAINER_TESTER KKS_GENERIC_TYPE<E> extends AbstractTester<OneSizeTestContainerGenerator<E, CLASS_TYPE>>
|
||||
{
|
||||
protected SAMPLE_ELEMENTS KEY_GENERIC_TYPE samples;
|
||||
protected E container;
|
||||
protected TEST_COLLECTION_GENERATOR KEY_GENERIC_TYPE primitiveGenerator;
|
||||
protected CollectionSize size;
|
||||
|
||||
@Override
|
||||
@OverridingMethodsMustInvokeSuper
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
setupGenerator();
|
||||
}
|
||||
|
||||
protected void setupGenerator() {
|
||||
TestContainerGenerator<E, CLASS_TYPE> generator = getSubjectGenerator().getInnerGenerator();
|
||||
if (!(generator instanceof TEST_COLLECTION_GENERATOR)) throw new IllegalStateException("Test Generator Must extend TEST_COLLECTION_GENERATOR");
|
||||
primitiveGenerator = (TEST_COLLECTION_GENERATOR KEY_GENERIC_TYPE) generator;
|
||||
samples = primitiveGenerator.getSamples();
|
||||
size = getSubjectGenerator().getCollectionSize();
|
||||
resetContainer();
|
||||
}
|
||||
|
||||
protected abstract COLLECTION KEY_GENERIC_TYPE actualContents();
|
||||
|
||||
protected E resetContainer() {
|
||||
return resetContainer(createTestSubject());
|
||||
}
|
||||
|
||||
protected E resetContainer(E newValue) {
|
||||
container = newValue;
|
||||
return container;
|
||||
}
|
||||
|
||||
protected void expectContents(KEY_TYPE... elements) {
|
||||
expectContents(ARRAY_LIST.wrap(elements));
|
||||
}
|
||||
|
||||
protected void expectContents(COLLECTION KEY_GENERIC_TYPE expected) {
|
||||
HELPERS.assertEqualIgnoringOrder(expected, actualContents());
|
||||
}
|
||||
|
||||
protected void expectUnchanged() {
|
||||
expectContents(getOrderedElements());
|
||||
}
|
||||
|
||||
protected final void expectAdded(KEY_TYPE... elements) {
|
||||
LIST KEY_GENERIC_TYPE expected = HELPERS.copyToList(getSampleElements());
|
||||
expected.addAll(elements);
|
||||
expectContents(expected);
|
||||
}
|
||||
|
||||
protected final void expectAddedIndex(int index, KEY_TYPE... elements) {
|
||||
expectAdded(index, ARRAY_LIST.wrap(elements));
|
||||
}
|
||||
|
||||
protected final void expectAdded(int index, COLLECTION KEY_GENERIC_TYPE elements) {
|
||||
LIST KEY_GENERIC_TYPE expected = HELPERS.copyToList(getSampleElements());
|
||||
expected.addAll(index, elements);
|
||||
expectContents(expected);
|
||||
}
|
||||
|
||||
protected void expectMissing(KEY_TYPE... elements) {
|
||||
for (KEY_TYPE element : elements) {
|
||||
assertFalse("Should not contain " + element, actualContents().contains(element));
|
||||
}
|
||||
}
|
||||
|
||||
protected KEY_TYPE[] createSamplesArray() {
|
||||
return getSampleElements().TO_ARRAY(NEW_KEY_ARRAY(getNumElements()));
|
||||
}
|
||||
|
||||
protected KEY_TYPE[] createOrderedArray() {
|
||||
return getOrderedElements().TO_ARRAY(NEW_KEY_ARRAY(getNumElements()));
|
||||
}
|
||||
|
||||
public static class ArrayWithDuplicate KEY_GENERIC_TYPE {
|
||||
public final KEY_TYPE[] elements;
|
||||
public final KEY_TYPE duplicate;
|
||||
|
||||
private ArrayWithDuplicate(KEY_TYPE[] elements, KEY_TYPE duplicate) {
|
||||
this.elements = elements;
|
||||
this.duplicate = duplicate;
|
||||
}
|
||||
}
|
||||
|
||||
protected ArrayWithDuplicate KEY_GENERIC_TYPE createArrayWithDuplicateElement() {
|
||||
KEY_TYPE[] elements = createSamplesArray();
|
||||
KEY_TYPE duplicate = elements[(elements.length / 2) - 1];
|
||||
elements[(elements.length / 2) + 1] = duplicate;
|
||||
return new ArrayWithDuplicateBRACES(elements, duplicate);
|
||||
}
|
||||
|
||||
protected int getNumElements() {
|
||||
return size.getNumElements();
|
||||
}
|
||||
|
||||
protected COLLECTION KEY_GENERIC_TYPE getSampleElements() {
|
||||
return getSampleElements(getNumElements());
|
||||
}
|
||||
|
||||
protected LIST KEY_GENERIC_TYPE getOrderedElements() {
|
||||
LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES();
|
||||
for (ITERATOR KEY_GENERIC_TYPE iter = primitiveGenerator.order(new ARRAY_LISTBRACES(getSampleElements())).iterator(); iter.hasNext();) {
|
||||
list.add(iter.NEXT());
|
||||
}
|
||||
return LISTS.unmodifiable(list);
|
||||
}
|
||||
|
||||
#if TYPE_OBJECT
|
||||
protected KEY_TYPE[] createDisjointArray() {
|
||||
KEY_TYPE[] array = NEW_KEY_ARRAY(2);
|
||||
array[0] = e3();
|
||||
array[1] = e4();
|
||||
return array;
|
||||
}
|
||||
#else
|
||||
protected KEY_TYPE[] createDisjointArray() {
|
||||
return new KEY_TYPE[]{e3(), e4()};
|
||||
}
|
||||
|
||||
#endif
|
||||
protected KEY_TYPE[] emptyArray() {
|
||||
return NEW_KEY_ARRAY(0);
|
||||
}
|
||||
|
||||
protected MINIMAL_COLLECTION KEY_GENERIC_TYPE createDisjointCollection() {
|
||||
return MINIMAL_COLLECTION.of(e3(), e4());
|
||||
}
|
||||
|
||||
protected MINIMAL_COLLECTION KEY_GENERIC_TYPE emptyCollection() {
|
||||
return MINIMAL_COLLECTION.of();
|
||||
}
|
||||
|
||||
public KEY_TYPE[] createArray(KEY_TYPE...array) {
|
||||
return array;
|
||||
}
|
||||
|
||||
protected final KEY_TYPE e0() {
|
||||
return samples.e0();
|
||||
}
|
||||
|
||||
protected final KEY_TYPE e1() {
|
||||
return samples.e1();
|
||||
}
|
||||
|
||||
protected final KEY_TYPE e2() {
|
||||
return samples.e2();
|
||||
}
|
||||
|
||||
protected final KEY_TYPE e3() {
|
||||
return samples.e3();
|
||||
}
|
||||
|
||||
protected final KEY_TYPE e4() {
|
||||
return samples.e4();
|
||||
}
|
||||
|
||||
protected E createTestSubject() {
|
||||
return (E)primitiveGenerator.create(getSampleElements(size.getNumElements()).TO_ARRAY(NEW_KEY_ARRAY(getNumElements())));
|
||||
}
|
||||
|
||||
protected COLLECTION KEY_GENERIC_TYPE getSampleElements(int howMany) {
|
||||
return new ARRAY_LISTBRACES(samples.asList().subList(0, howMany));
|
||||
}
|
||||
}
|
|
@ -1,27 +1,27 @@
|
|||
package speiger.src.testers.PACKAGE.tests.base;
|
||||
|
||||
#ignore
|
||||
import static com.google.common.collect.testing.features.CollectionSize.ZERO;
|
||||
#endignore
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
import com.google.common.collect.testing.features.CollectionSize;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public abstract class ABSTRACT_LIST_INDEX_OF_TESTER KEY_GENERIC_TYPE extends ABSTRACT_LIST_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
protected abstract int find(KEY_TYPE o);
|
||||
|
||||
protected abstract String getMethodName();
|
||||
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
public void testFind_yes() {
|
||||
assertEquals(getMethodName() + "(firstElement) should return 0", 0, find(getOrderedElements().GET_KEY(0)));
|
||||
}
|
||||
|
||||
public void testFind_no() {
|
||||
assertEquals(getMethodName() + "(notPresent) should return -1", -1, find(e3()));
|
||||
}
|
||||
}
|
||||
package speiger.src.testers.PACKAGE.tests.base;
|
||||
|
||||
#ignore
|
||||
import static com.google.common.collect.testing.features.CollectionSize.ZERO;
|
||||
#endignore
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
import com.google.common.collect.testing.features.CollectionSize;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public abstract class ABSTRACT_LIST_INDEX_OF_TESTER KEY_GENERIC_TYPE extends ABSTRACT_LIST_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
protected abstract int find(KEY_TYPE o);
|
||||
|
||||
protected abstract String getMethodName();
|
||||
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
public void testFind_yes() {
|
||||
assertEquals(getMethodName() + "(firstElement) should return 0", 0, find(getOrderedElements().GET_KEY(0)));
|
||||
}
|
||||
|
||||
public void testFind_no() {
|
||||
assertEquals(getMethodName() + "(notPresent) should return -1", -1, find(e3()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,39 +1,39 @@
|
|||
package speiger.src.testers.PACKAGE.tests.base;
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
#if TYPE_OBJECT
|
||||
import java.util.Objects;
|
||||
#endif
|
||||
|
||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||
import speiger.src.testers.PACKAGE.utils.HELPERS;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class ABSTRACT_LIST_TESTER KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
protected final LIST KEY_GENERIC_TYPE getList() {
|
||||
return (LIST KEY_GENERIC_TYPE) collection;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void expectContents(COLLECTION KEY_GENERIC_TYPE expectedCollection) {
|
||||
LIST KEY_GENERIC_TYPE expectedList = HELPERS.copyToList(expectedCollection);
|
||||
if (getList().size() != expectedList.size()) {
|
||||
fail("size mismatch: " + reportContext(expectedList));
|
||||
}
|
||||
for (int i = 0; i < expectedList.size(); i++) {
|
||||
KEY_TYPE expected = expectedList.GET_KEY(i);
|
||||
KEY_TYPE actual = getList().GET_KEY(i);
|
||||
if (KEY_EQUALS_NOT(expected, actual)) {
|
||||
fail("mismatch at index " + i + ": " + reportContext(expectedList));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String reportContext(LIST KEY_GENERIC_TYPE expected) {
|
||||
return String.format("expected collection %s; actual collection %s", expected, collection);
|
||||
}
|
||||
package speiger.src.testers.PACKAGE.tests.base;
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
#if TYPE_OBJECT
|
||||
import java.util.Objects;
|
||||
#endif
|
||||
|
||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||
import speiger.src.testers.PACKAGE.utils.HELPERS;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class ABSTRACT_LIST_TESTER KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
protected final LIST KEY_GENERIC_TYPE getList() {
|
||||
return (LIST KEY_GENERIC_TYPE) collection;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void expectContents(COLLECTION KEY_GENERIC_TYPE expectedCollection) {
|
||||
LIST KEY_GENERIC_TYPE expectedList = HELPERS.copyToList(expectedCollection);
|
||||
if (getList().size() != expectedList.size()) {
|
||||
fail("size mismatch: " + reportContext(expectedList));
|
||||
}
|
||||
for (int i = 0; i < expectedList.size(); i++) {
|
||||
KEY_TYPE expected = expectedList.GET_KEY(i);
|
||||
KEY_TYPE actual = getList().GET_KEY(i);
|
||||
if (KEY_EQUALS_NOT(expected, actual)) {
|
||||
fail("mismatch at index " + i + ": " + reportContext(expectedList));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String reportContext(LIST KEY_GENERIC_TYPE expected) {
|
||||
return String.format("expected collection %s; actual collection %s", expected, collection);
|
||||
}
|
||||
}
|
|
@ -1,81 +1,81 @@
|
|||
package speiger.src.testers.PACKAGE.tests.base;
|
||||
|
||||
#if TYPE_OBJECT
|
||||
import java.util.Objects;
|
||||
#endif
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
import com.google.common.collect.testing.TestContainerGenerator;
|
||||
|
||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||
import speiger.src.collections.PACKAGE.queues.PRIORITY_QUEUE;
|
||||
import speiger.src.collections.PACKAGE.utils.LISTS;
|
||||
import speiger.src.testers.PACKAGE.generators.TEST_QUEUE_GENERATOR;
|
||||
import speiger.src.testers.PACKAGE.utils.HELPERS;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class ABSTRACT_QUEUE_TESTER KEY_GENERIC_TYPE extends ABSTRACT_CONTAINER_TESTER KKS_GENERIC_TYPE<PRIORITY_QUEUE KEY_CLASS_GENERIC_TYPE>
|
||||
{
|
||||
protected TEST_QUEUE_GENERATOR KEY_GENERIC_TYPE queueGenerator;
|
||||
protected PRIORITY_QUEUE KEY_GENERIC_TYPE queue;
|
||||
|
||||
@Override
|
||||
protected void setupGenerator() {
|
||||
TestContainerGenerator<PRIORITY_QUEUE KEY_GENERIC_TYPE, CLASS_TYPE> generator = getSubjectGenerator().getInnerGenerator();
|
||||
if (!(generator instanceof TEST_QUEUE_GENERATOR)) throw new IllegalStateException("Test Generator Must extend TestLongCollectionGenerator");
|
||||
queueGenerator = (TEST_QUEUE_GENERATOR KEY_GENERIC_TYPE) generator;
|
||||
samples = queueGenerator.getSamples();
|
||||
size = getSubjectGenerator().getCollectionSize();
|
||||
resetContainer();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected COLLECTION KEY_GENERIC_TYPE actualContents() { return null; }
|
||||
|
||||
@Override
|
||||
protected PRIORITY_QUEUE KEY_GENERIC_TYPE resetContainer(PRIORITY_QUEUE KEY_GENERIC_TYPE newValue) {
|
||||
queue = super.resetContainer(newValue);
|
||||
return queue;
|
||||
}
|
||||
|
||||
protected void resetQueue() {
|
||||
resetContainer();
|
||||
}
|
||||
|
||||
protected LIST KEY_GENERIC_TYPE getOrderedElements() {
|
||||
LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES();
|
||||
for (ITERATOR KEY_GENERIC_TYPE iter = queueGenerator.order(new ARRAY_LISTBRACES(getSampleElements())).iterator(); iter.hasNext();) {
|
||||
list.add(iter.NEXT());
|
||||
}
|
||||
return LISTS.unmodifiable(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PRIORITY_QUEUE KEY_GENERIC_TYPE createTestSubject() {
|
||||
return queueGenerator.create(getSampleElements(size.getNumElements()).TO_ARRAY(NEW_KEY_ARRAY(getNumElements())));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void expectContents(COLLECTION KEY_GENERIC_TYPE expected) {
|
||||
HELPERS.assertContentsAnyOrder(expected, queue.TO_ARRAY());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void expectMissing(KEY_TYPE... elements) {
|
||||
for (KEY_TYPE element : elements) {
|
||||
assertFalse("Should not contain " + element, contains(element));
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean contains(KEY_TYPE element) {
|
||||
for(int i = 0,m=queue.size();i<m;i++) {
|
||||
if(KEY_EQUALS(queue.peek(i), element)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
package speiger.src.testers.PACKAGE.tests.base;
|
||||
|
||||
#if TYPE_OBJECT
|
||||
import java.util.Objects;
|
||||
#endif
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
import com.google.common.collect.testing.TestContainerGenerator;
|
||||
|
||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||
import speiger.src.collections.PACKAGE.queues.PRIORITY_QUEUE;
|
||||
import speiger.src.collections.PACKAGE.utils.LISTS;
|
||||
import speiger.src.testers.PACKAGE.generators.TEST_QUEUE_GENERATOR;
|
||||
import speiger.src.testers.PACKAGE.utils.HELPERS;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class ABSTRACT_QUEUE_TESTER KEY_GENERIC_TYPE extends ABSTRACT_CONTAINER_TESTER KKS_GENERIC_TYPE<PRIORITY_QUEUE KEY_CLASS_GENERIC_TYPE>
|
||||
{
|
||||
protected TEST_QUEUE_GENERATOR KEY_GENERIC_TYPE queueGenerator;
|
||||
protected PRIORITY_QUEUE KEY_GENERIC_TYPE queue;
|
||||
|
||||
@Override
|
||||
protected void setupGenerator() {
|
||||
TestContainerGenerator<PRIORITY_QUEUE KEY_GENERIC_TYPE, CLASS_TYPE> generator = getSubjectGenerator().getInnerGenerator();
|
||||
if (!(generator instanceof TEST_QUEUE_GENERATOR)) throw new IllegalStateException("Test Generator Must extend TestLongCollectionGenerator");
|
||||
queueGenerator = (TEST_QUEUE_GENERATOR KEY_GENERIC_TYPE) generator;
|
||||
samples = queueGenerator.getSamples();
|
||||
size = getSubjectGenerator().getCollectionSize();
|
||||
resetContainer();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected COLLECTION KEY_GENERIC_TYPE actualContents() { return null; }
|
||||
|
||||
@Override
|
||||
protected PRIORITY_QUEUE KEY_GENERIC_TYPE resetContainer(PRIORITY_QUEUE KEY_GENERIC_TYPE newValue) {
|
||||
queue = super.resetContainer(newValue);
|
||||
return queue;
|
||||
}
|
||||
|
||||
protected void resetQueue() {
|
||||
resetContainer();
|
||||
}
|
||||
|
||||
protected LIST KEY_GENERIC_TYPE getOrderedElements() {
|
||||
LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES();
|
||||
for (ITERATOR KEY_GENERIC_TYPE iter = queueGenerator.order(new ARRAY_LISTBRACES(getSampleElements())).iterator(); iter.hasNext();) {
|
||||
list.add(iter.NEXT());
|
||||
}
|
||||
return LISTS.unmodifiable(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PRIORITY_QUEUE KEY_GENERIC_TYPE createTestSubject() {
|
||||
return queueGenerator.create(getSampleElements(size.getNumElements()).TO_ARRAY(NEW_KEY_ARRAY(getNumElements())));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void expectContents(COLLECTION KEY_GENERIC_TYPE expected) {
|
||||
HELPERS.assertContentsAnyOrder(expected, queue.TO_ARRAY());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void expectMissing(KEY_TYPE... elements) {
|
||||
for (KEY_TYPE element : elements) {
|
||||
assertFalse("Should not contain " + element, contains(element));
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean contains(KEY_TYPE element) {
|
||||
for(int i = 0,m=queue.size();i<m;i++) {
|
||||
if(KEY_EQUALS(queue.peek(i), element)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
package speiger.src.testers.PACKAGE.tests.base;
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
import speiger.src.collections.PACKAGE.sets.SET;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class ABSTRACT_SET_TESTER KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
protected final SET KEY_GENERIC_TYPE getSet() {
|
||||
return (SET KEY_GENERIC_TYPE)collection;
|
||||
}
|
||||
}
|
||||
package speiger.src.testers.PACKAGE.tests.base;
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
import speiger.src.collections.PACKAGE.sets.SET;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class ABSTRACT_SET_TESTER KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
protected final SET KEY_GENERIC_TYPE getSet() {
|
||||
return (SET KEY_GENERIC_TYPE)collection;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,243 +1,243 @@
|
|||
package speiger.src.testers.PACKAGE.tests.base.maps;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
#if VALUE_OBJECT
|
||||
import java.util.Objects;
|
||||
#endif
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
import com.google.common.collect.testing.TestContainerGenerator;
|
||||
|
||||
import speiger.src.collections.PACKAGE.maps.abstracts.ABSTRACT_MAP;
|
||||
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
||||
import speiger.src.collections.objects.collections.ObjectCollection;
|
||||
import speiger.src.collections.objects.collections.ObjectIterator;
|
||||
import speiger.src.collections.objects.lists.ObjectArrayList;
|
||||
import speiger.src.collections.objects.lists.ObjectList;
|
||||
import speiger.src.collections.objects.lists.ObjectListIterator;
|
||||
import speiger.src.collections.objects.utils.ObjectLists;
|
||||
import speiger.src.testers.PACKAGE.generators.maps.TEST_MAP_GENERATOR;
|
||||
#if !TYPE_OBJECT
|
||||
import speiger.src.testers.PACKAGE.utils.HELPERS;
|
||||
#endif
|
||||
import speiger.src.testers.objects.tests.base.AbstractObjectContainerTester;
|
||||
import speiger.src.testers.objects.utils.ObjectHelpers;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class ABSTRACT_MAP_TESTER KEY_VALUE_GENERIC_TYPE extends AbstractObjectContainerTester<MAP.Entry KEY_VALUE_GENERIC_TYPE, MAP KEY_VALUE_GENERIC_TYPE>
|
||||
{
|
||||
protected TEST_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE primitiveMapGenerator;
|
||||
|
||||
protected MAP KEY_VALUE_GENERIC_TYPE getMap() {
|
||||
return container;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupGenerator() {
|
||||
TestContainerGenerator<? extends Map<CLASS_TYPE, CLASS_VALUE_TYPE>, ? extends Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>> generator = getSubjectGenerator().getInnerGenerator();
|
||||
if (!(generator instanceof TEST_MAP_GENERATOR)) throw new IllegalStateException("Test Generator Must extend TestLong2ByteMapGenerator");
|
||||
primitiveMapGenerator = (TEST_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE) generator;
|
||||
samples = primitiveMapGenerator.getSamples();
|
||||
size = getSubjectGenerator().getCollectionSize();
|
||||
resetContainer();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MAP KEY_VALUE_GENERIC_TYPE createTestSubject() {
|
||||
return primitiveMapGenerator.create(getSampleElements(size.getNumElements()).toArray(new MAP.Entry[getNumElements()]));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ObjectList<MAP.Entry KEY_VALUE_GENERIC_TYPE> getOrderedElements() {
|
||||
ObjectList<MAP.Entry KEY_VALUE_GENERIC_TYPE> list = new ObjectArrayList<>();
|
||||
for (ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = primitiveMapGenerator.order(new ObjectArrayList<MAP.Entry KEY_VALUE_GENERIC_TYPE>(getSampleElements())).iterator(); iter.hasNext();) {
|
||||
list.add(iter.next());
|
||||
}
|
||||
return ObjectLists.unmodifiable(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ObjectCollection<MAP.Entry KEY_VALUE_GENERIC_TYPE> actualContents() {
|
||||
return getMap().ENTRY_SET();
|
||||
}
|
||||
|
||||
protected final void resetMap() {
|
||||
resetContainer();
|
||||
}
|
||||
|
||||
protected void resetMap(MAP.Entry KEY_VALUE_GENERIC_TYPE[] entries) {
|
||||
resetContainer(primitiveMapGenerator.create(entries));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MAP KEY_VALUE_GENERIC_TYPE resetContainer(MAP KEY_VALUE_GENERIC_TYPE newValue) {
|
||||
newValue.setDefaultReturnValue(INVALID_VALUE);
|
||||
return super.resetContainer(newValue);
|
||||
}
|
||||
|
||||
protected void expectMissingKeys(KEY_TYPE... elements) {
|
||||
for (KEY_TYPE element : elements) {
|
||||
assertFalse("Should not contain key " + element, getMap().containsKey(element));
|
||||
}
|
||||
}
|
||||
|
||||
protected void expectMissingValues(VALUE_TYPE... elements) {
|
||||
for (VALUE_TYPE element : elements) {
|
||||
assertFalse("Should not contain value " + element, getMap().containsValue(element));
|
||||
}
|
||||
}
|
||||
|
||||
protected int getNumEntries() {
|
||||
return getNumElements();
|
||||
}
|
||||
|
||||
protected ObjectCollection<MAP.Entry KEY_VALUE_GENERIC_TYPE> getSampleEntries(int howMany) {
|
||||
return getSampleElements(howMany);
|
||||
}
|
||||
|
||||
protected ObjectCollection<MAP.Entry KEY_VALUE_GENERIC_TYPE> getSampleEntries() {
|
||||
return getSampleElements();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void expectMissing(MAP.Entry KEY_VALUE_GENERIC_TYPE... entries) {
|
||||
for (MAP.Entry KEY_VALUE_GENERIC_TYPE entry : entries) {
|
||||
assertFalse("Should not contain entry " + entry, actualContents().contains(entry));
|
||||
#if !VALUE_BOOLEAN
|
||||
assertFalse("Should not contain key " + entry.ENTRY_KEY() + " mapped to value " + entry.ENTRY_VALUE(), valueEquals(getMap().get(entry.ENTRY_KEY()), entry.ENTRY_VALUE()));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void expectContents(ObjectCollection<MAP.Entry KEY_VALUE_GENERIC_TYPE> expected) {
|
||||
super.expectContents(expected);
|
||||
for (MAP.Entry KEY_VALUE_GENERIC_TYPE entry : expected) {
|
||||
assertEquals("Wrong value for key " + entry.ENTRY_KEY(), entry.ENTRY_VALUE(), getMap().GET_VALUE(entry.ENTRY_KEY()));
|
||||
}
|
||||
}
|
||||
|
||||
protected final void expectReplacement(MAP.Entry KEY_VALUE_GENERIC_TYPE newEntry) {
|
||||
ObjectList<MAP.Entry KEY_VALUE_GENERIC_TYPE> expected = ObjectHelpers.copyToList(getSampleElements());
|
||||
replaceValue(expected, newEntry);
|
||||
expectContents(expected);
|
||||
}
|
||||
|
||||
private void replaceValue(ObjectList<MAP.Entry KEY_VALUE_GENERIC_TYPE> expected, MAP.Entry KEY_VALUE_GENERIC_TYPE newEntry) {
|
||||
for (ObjectListIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> i = expected.listIterator(); i.hasNext();) {
|
||||
if (HELPERS.equals(i.next().ENTRY_KEY(), newEntry.ENTRY_KEY())) {
|
||||
i.set(newEntry);
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException(String.format(Locale.ROOT, "key %s not found in entries %s", newEntry.ENTRY_KEY(), expected));
|
||||
}
|
||||
|
||||
#if !VALUE_BOOLEAN
|
||||
private static GENERIC_VALUE_BRACES boolean valueEquals(VALUE_TYPE a, VALUE_TYPE b) {
|
||||
return VALUE_EQUALS(a, b);
|
||||
}
|
||||
|
||||
#endif
|
||||
protected MAP.Entry KEY_VALUE_GENERIC_TYPE entry(KEY_TYPE key, VALUE_TYPE value) {
|
||||
return new ABSTRACT_MAP.BasicEntryKV_BRACES(key, value);
|
||||
}
|
||||
|
||||
protected KEY_TYPE[] emptyKeyArray() {
|
||||
return NEW_KEY_ARRAY(0);
|
||||
}
|
||||
|
||||
protected KEY_TYPE[] createDisjointedKeyArray() {
|
||||
KEY_TYPE[] array = NEW_KEY_ARRAY(2);
|
||||
array[0] = k3();
|
||||
array[1] = k4();
|
||||
return array;
|
||||
}
|
||||
|
||||
protected CLASS_TYPE[] emptyKeyObjectArray() {
|
||||
return NEW_CLASS_ARRAY(0);
|
||||
}
|
||||
|
||||
protected CLASS_TYPE[] createDisjointedKeyObjectArray() {
|
||||
CLASS_TYPE[] array = NEW_CLASS_ARRAY(2);
|
||||
array[0] = k3();
|
||||
array[1] = k4();
|
||||
return array;
|
||||
}
|
||||
|
||||
protected VALUE_TYPE[] emptyValueArray() {
|
||||
return NEW_VALUE_ARRAY(0);
|
||||
}
|
||||
|
||||
protected VALUE_TYPE[] createDisjointedValueArray() {
|
||||
VALUE_TYPE[] array = NEW_VALUE_ARRAY(2);
|
||||
array[0] = v3();
|
||||
array[1] = v4();
|
||||
return array;
|
||||
}
|
||||
|
||||
protected CLASS_VALUE_TYPE[] emptyValueObjectArray() {
|
||||
return NEW_CLASS_VALUE_ARRAY(0);
|
||||
}
|
||||
|
||||
protected CLASS_VALUE_TYPE[] createDisjointedValueObjectArray() {
|
||||
CLASS_VALUE_TYPE[] array = NEW_CLASS_VALUE_ARRAY(2);
|
||||
array[0] = v3();
|
||||
array[1] = v4();
|
||||
return array;
|
||||
}
|
||||
|
||||
protected VALUE_TYPE get(KEY_TYPE key) {
|
||||
return getMap().GET_VALUE(key);
|
||||
}
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
@SuppressWarnings("deprecation")
|
||||
protected CLASS_VALUE_TYPE get(CLASS_TYPE key) {
|
||||
return getMap().get(key);
|
||||
}
|
||||
|
||||
#endif
|
||||
protected final KEY_TYPE k0() {
|
||||
return e0().ENTRY_KEY();
|
||||
}
|
||||
|
||||
protected final VALUE_TYPE v0() {
|
||||
return e0().ENTRY_VALUE();
|
||||
}
|
||||
|
||||
protected final KEY_TYPE k1() {
|
||||
return e1().ENTRY_KEY();
|
||||
}
|
||||
|
||||
protected final VALUE_TYPE v1() {
|
||||
return e1().ENTRY_VALUE();
|
||||
}
|
||||
|
||||
protected final KEY_TYPE k2() {
|
||||
return e2().ENTRY_KEY();
|
||||
}
|
||||
|
||||
protected final VALUE_TYPE v2() {
|
||||
return e2().ENTRY_VALUE();
|
||||
}
|
||||
|
||||
protected final KEY_TYPE k3() {
|
||||
return e3().ENTRY_KEY();
|
||||
}
|
||||
|
||||
protected final VALUE_TYPE v3() {
|
||||
return e3().ENTRY_VALUE();
|
||||
}
|
||||
|
||||
protected final KEY_TYPE k4() {
|
||||
return e4().ENTRY_KEY();
|
||||
}
|
||||
|
||||
protected final VALUE_TYPE v4() {
|
||||
return e4().ENTRY_VALUE();
|
||||
}
|
||||
}
|
||||
package speiger.src.testers.PACKAGE.tests.base.maps;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
#if VALUE_OBJECT
|
||||
import java.util.Objects;
|
||||
#endif
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
import com.google.common.collect.testing.TestContainerGenerator;
|
||||
|
||||
import speiger.src.collections.PACKAGE.maps.abstracts.ABSTRACT_MAP;
|
||||
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
||||
import speiger.src.collections.objects.collections.ObjectCollection;
|
||||
import speiger.src.collections.objects.collections.ObjectIterator;
|
||||
import speiger.src.collections.objects.lists.ObjectArrayList;
|
||||
import speiger.src.collections.objects.lists.ObjectList;
|
||||
import speiger.src.collections.objects.lists.ObjectListIterator;
|
||||
import speiger.src.collections.objects.utils.ObjectLists;
|
||||
import speiger.src.testers.PACKAGE.generators.maps.TEST_MAP_GENERATOR;
|
||||
#if !TYPE_OBJECT
|
||||
import speiger.src.testers.PACKAGE.utils.HELPERS;
|
||||
#endif
|
||||
import speiger.src.testers.objects.tests.base.AbstractObjectContainerTester;
|
||||
import speiger.src.testers.objects.utils.ObjectHelpers;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class ABSTRACT_MAP_TESTER KEY_VALUE_GENERIC_TYPE extends AbstractObjectContainerTester<MAP.Entry KEY_VALUE_GENERIC_TYPE, MAP KEY_VALUE_GENERIC_TYPE>
|
||||
{
|
||||
protected TEST_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE primitiveMapGenerator;
|
||||
|
||||
protected MAP KEY_VALUE_GENERIC_TYPE getMap() {
|
||||
return container;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupGenerator() {
|
||||
TestContainerGenerator<? extends Map<CLASS_TYPE, CLASS_VALUE_TYPE>, ? extends Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>> generator = getSubjectGenerator().getInnerGenerator();
|
||||
if (!(generator instanceof TEST_MAP_GENERATOR)) throw new IllegalStateException("Test Generator Must extend TestLong2ByteMapGenerator");
|
||||
primitiveMapGenerator = (TEST_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE) generator;
|
||||
samples = primitiveMapGenerator.getSamples();
|
||||
size = getSubjectGenerator().getCollectionSize();
|
||||
resetContainer();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MAP KEY_VALUE_GENERIC_TYPE createTestSubject() {
|
||||
return primitiveMapGenerator.create(getSampleElements(size.getNumElements()).toArray(new MAP.Entry[getNumElements()]));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ObjectList<MAP.Entry KEY_VALUE_GENERIC_TYPE> getOrderedElements() {
|
||||
ObjectList<MAP.Entry KEY_VALUE_GENERIC_TYPE> list = new ObjectArrayList<>();
|
||||
for (ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = primitiveMapGenerator.order(new ObjectArrayList<MAP.Entry KEY_VALUE_GENERIC_TYPE>(getSampleElements())).iterator(); iter.hasNext();) {
|
||||
list.add(iter.next());
|
||||
}
|
||||
return ObjectLists.unmodifiable(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ObjectCollection<MAP.Entry KEY_VALUE_GENERIC_TYPE> actualContents() {
|
||||
return getMap().ENTRY_SET();
|
||||
}
|
||||
|
||||
protected final void resetMap() {
|
||||
resetContainer();
|
||||
}
|
||||
|
||||
protected void resetMap(MAP.Entry KEY_VALUE_GENERIC_TYPE[] entries) {
|
||||
resetContainer(primitiveMapGenerator.create(entries));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MAP KEY_VALUE_GENERIC_TYPE resetContainer(MAP KEY_VALUE_GENERIC_TYPE newValue) {
|
||||
newValue.setDefaultReturnValue(INVALID_VALUE);
|
||||
return super.resetContainer(newValue);
|
||||
}
|
||||
|
||||
protected void expectMissingKeys(KEY_TYPE... elements) {
|
||||
for (KEY_TYPE element : elements) {
|
||||
assertFalse("Should not contain key " + element, getMap().containsKey(element));
|
||||
}
|
||||
}
|
||||
|
||||
protected void expectMissingValues(VALUE_TYPE... elements) {
|
||||
for (VALUE_TYPE element : elements) {
|
||||
assertFalse("Should not contain value " + element, getMap().containsValue(element));
|
||||
}
|
||||
}
|
||||
|
||||
protected int getNumEntries() {
|
||||
return getNumElements();
|
||||
}
|
||||
|
||||
protected ObjectCollection<MAP.Entry KEY_VALUE_GENERIC_TYPE> getSampleEntries(int howMany) {
|
||||
return getSampleElements(howMany);
|
||||
}
|
||||
|
||||
protected ObjectCollection<MAP.Entry KEY_VALUE_GENERIC_TYPE> getSampleEntries() {
|
||||
return getSampleElements();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void expectMissing(MAP.Entry KEY_VALUE_GENERIC_TYPE... entries) {
|
||||
for (MAP.Entry KEY_VALUE_GENERIC_TYPE entry : entries) {
|
||||
assertFalse("Should not contain entry " + entry, actualContents().contains(entry));
|
||||
#if !VALUE_BOOLEAN
|
||||
assertFalse("Should not contain key " + entry.ENTRY_KEY() + " mapped to value " + entry.ENTRY_VALUE(), valueEquals(getMap().get(entry.ENTRY_KEY()), entry.ENTRY_VALUE()));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void expectContents(ObjectCollection<MAP.Entry KEY_VALUE_GENERIC_TYPE> expected) {
|
||||
super.expectContents(expected);
|
||||
for (MAP.Entry KEY_VALUE_GENERIC_TYPE entry : expected) {
|
||||
assertEquals("Wrong value for key " + entry.ENTRY_KEY(), entry.ENTRY_VALUE(), getMap().GET_VALUE(entry.ENTRY_KEY()));
|
||||
}
|
||||
}
|
||||
|
||||
protected final void expectReplacement(MAP.Entry KEY_VALUE_GENERIC_TYPE newEntry) {
|
||||
ObjectList<MAP.Entry KEY_VALUE_GENERIC_TYPE> expected = ObjectHelpers.copyToList(getSampleElements());
|
||||
replaceValue(expected, newEntry);
|
||||
expectContents(expected);
|
||||
}
|
||||
|
||||
private void replaceValue(ObjectList<MAP.Entry KEY_VALUE_GENERIC_TYPE> expected, MAP.Entry KEY_VALUE_GENERIC_TYPE newEntry) {
|
||||
for (ObjectListIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> i = expected.listIterator(); i.hasNext();) {
|
||||
if (HELPERS.equals(i.next().ENTRY_KEY(), newEntry.ENTRY_KEY())) {
|
||||
i.set(newEntry);
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException(String.format(Locale.ROOT, "key %s not found in entries %s", newEntry.ENTRY_KEY(), expected));
|
||||
}
|
||||
|
||||
#if !VALUE_BOOLEAN
|
||||
private static GENERIC_VALUE_BRACES boolean valueEquals(VALUE_TYPE a, VALUE_TYPE b) {
|
||||
return VALUE_EQUALS(a, b);
|
||||
}
|
||||
|
||||
#endif
|
||||
protected MAP.Entry KEY_VALUE_GENERIC_TYPE entry(KEY_TYPE key, VALUE_TYPE value) {
|
||||
return new ABSTRACT_MAP.BasicEntryKV_BRACES(key, value);
|
||||
}
|
||||
|
||||
protected KEY_TYPE[] emptyKeyArray() {
|
||||
return NEW_KEY_ARRAY(0);
|
||||
}
|
||||
|
||||
protected KEY_TYPE[] createDisjointedKeyArray() {
|
||||
KEY_TYPE[] array = NEW_KEY_ARRAY(2);
|
||||
array[0] = k3();
|
||||
array[1] = k4();
|
||||
return array;
|
||||
}
|
||||
|
||||
protected CLASS_TYPE[] emptyKeyObjectArray() {
|
||||
return NEW_CLASS_ARRAY(0);
|
||||
}
|
||||
|
||||
protected CLASS_TYPE[] createDisjointedKeyObjectArray() {
|
||||
CLASS_TYPE[] array = NEW_CLASS_ARRAY(2);
|
||||
array[0] = k3();
|
||||
array[1] = k4();
|
||||
return array;
|
||||
}
|
||||
|
||||
protected VALUE_TYPE[] emptyValueArray() {
|
||||
return NEW_VALUE_ARRAY(0);
|
||||
}
|
||||
|
||||
protected VALUE_TYPE[] createDisjointedValueArray() {
|
||||
VALUE_TYPE[] array = NEW_VALUE_ARRAY(2);
|
||||
array[0] = v3();
|
||||
array[1] = v4();
|
||||
return array;
|
||||
}
|
||||
|
||||
protected CLASS_VALUE_TYPE[] emptyValueObjectArray() {
|
||||
return NEW_CLASS_VALUE_ARRAY(0);
|
||||
}
|
||||
|
||||
protected CLASS_VALUE_TYPE[] createDisjointedValueObjectArray() {
|
||||
CLASS_VALUE_TYPE[] array = NEW_CLASS_VALUE_ARRAY(2);
|
||||
array[0] = v3();
|
||||
array[1] = v4();
|
||||
return array;
|
||||
}
|
||||
|
||||
protected VALUE_TYPE get(KEY_TYPE key) {
|
||||
return getMap().GET_VALUE(key);
|
||||
}
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
@SuppressWarnings("deprecation")
|
||||
protected CLASS_VALUE_TYPE get(CLASS_TYPE key) {
|
||||
return getMap().get(key);
|
||||
}
|
||||
|
||||
#endif
|
||||
protected final KEY_TYPE k0() {
|
||||
return e0().ENTRY_KEY();
|
||||
}
|
||||
|
||||
protected final VALUE_TYPE v0() {
|
||||
return e0().ENTRY_VALUE();
|
||||
}
|
||||
|
||||
protected final KEY_TYPE k1() {
|
||||
return e1().ENTRY_KEY();
|
||||
}
|
||||
|
||||
protected final VALUE_TYPE v1() {
|
||||
return e1().ENTRY_VALUE();
|
||||
}
|
||||
|
||||
protected final KEY_TYPE k2() {
|
||||
return e2().ENTRY_KEY();
|
||||
}
|
||||
|
||||
protected final VALUE_TYPE v2() {
|
||||
return e2().ENTRY_VALUE();
|
||||
}
|
||||
|
||||
protected final KEY_TYPE k3() {
|
||||
return e3().ENTRY_KEY();
|
||||
}
|
||||
|
||||
protected final VALUE_TYPE v3() {
|
||||
return e3().ENTRY_VALUE();
|
||||
}
|
||||
|
||||
protected final KEY_TYPE k4() {
|
||||
return e4().ENTRY_KEY();
|
||||
}
|
||||
|
||||
protected final VALUE_TYPE v4() {
|
||||
return e4().ENTRY_VALUE();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,151 +1,151 @@
|
|||
package speiger.src.testers.PACKAGE.tests.collection;
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
#ignore
|
||||
import static com.google.common.collect.testing.features.CollectionFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION;
|
||||
import static com.google.common.collect.testing.features.CollectionFeature.SUPPORTS_ADD;
|
||||
import static com.google.common.collect.testing.features.CollectionSize.ZERO;
|
||||
#endignore
|
||||
|
||||
import java.util.ConcurrentModificationException;
|
||||
|
||||
import com.google.common.collect.testing.features.CollectionFeature;
|
||||
import com.google.common.collect.testing.features.CollectionSize;
|
||||
|
||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPECollectionAddAllArrayTester KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
#ignore
|
||||
@CollectionFeature.Require(SUPPORTS_ADD)
|
||||
public void testAddAllArray_supportedNothing() {
|
||||
assertFalse("addAll(nothing[]) should return false", collection.addAll(emptyArray()));
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(absent = SUPPORTS_ADD)
|
||||
public void testAddAllArray_unsupportedNothing() {
|
||||
try {
|
||||
assertFalse("addAll(nothing[]) should return false or throw", collection.addAll(emptyArray()));
|
||||
} catch (UnsupportedOperationException tolerated) {
|
||||
}
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(SUPPORTS_ADD)
|
||||
public void testAddAllArray_supportedNonePresent() {
|
||||
assertTrue("addAll(nonePresent[]) should return true", collection.addAll(createDisjointArray()));
|
||||
expectAdded(e3(), e4());
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(absent = SUPPORTS_ADD)
|
||||
public void testAddAllArray_unsupportedNonePresent() {
|
||||
try {
|
||||
collection.addAll(createDisjointArray());
|
||||
fail("addAll(nonePresent[]) should throw");
|
||||
} catch (UnsupportedOperationException expected) {
|
||||
}
|
||||
expectUnchanged();
|
||||
expectMissing(e3(), e4());
|
||||
}
|
||||
#endignore
|
||||
|
||||
#if !TYPE_BOOLEAN
|
||||
#ignore
|
||||
@CollectionFeature.Require(SUPPORTS_ADD)
|
||||
#endignore
|
||||
public void testAddAllArray_supportedToLargeOffset() {
|
||||
try {
|
||||
collection.addAll(createDisjointArray(), 5, 2);
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
}
|
||||
expectUnchanged();
|
||||
expectMissing(e3(), e4());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(SUPPORTS_ADD)
|
||||
#endignore
|
||||
public void testAddAllArray_supportedToLargeArray() {
|
||||
try {
|
||||
collection.addAll(createDisjointArray(), 3);
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
}
|
||||
expectUnchanged();
|
||||
expectMissing(e3(), e4());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(SUPPORTS_ADD)
|
||||
#endignore
|
||||
public void testAddAllArray_supportedToSmallOffset() {
|
||||
try {
|
||||
collection.addAll(createDisjointArray(), -1, 2);
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
}
|
||||
expectUnchanged();
|
||||
expectMissing(e3(), e4());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(SUPPORTS_ADD)
|
||||
#endignore
|
||||
public void testAddAllArray_supportedAddSubArray() {
|
||||
try {
|
||||
collection.addAll(createDisjointArray(), 1);
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
}
|
||||
expectAdded(e3());
|
||||
expectMissing(e4());
|
||||
}
|
||||
#endif
|
||||
#ignore
|
||||
@CollectionFeature.Require(SUPPORTS_ADD)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
public void testAddAllArray_supportedSomePresent() {
|
||||
assertTrue("addAll(somePresent[]) should return true", collection.addAll(e3(), e0()));
|
||||
assertTrue("should contain " + e3(), collection.contains(e3()));
|
||||
assertTrue("should contain " + e0(), collection.contains(e0()));
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(absent = SUPPORTS_ADD)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
public void testAddAllArray_unsupportedSomePresent() {
|
||||
try {
|
||||
collection.addAll(e3(), e0());
|
||||
fail("addAll(somePresent[]) should throw");
|
||||
} catch (UnsupportedOperationException expected) {
|
||||
}
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
@CollectionFeature.Require({ SUPPORTS_ADD, FAILS_FAST_ON_CONCURRENT_MODIFICATION })
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
public void testAddAllArrayConcurrentWithIteration() {
|
||||
#endignore
|
||||
try {
|
||||
ITERATOR KEY_GENERIC_TYPE iterator = collection.iterator();
|
||||
assertTrue(collection.addAll(e3(), e0()));
|
||||
iterator.NEXT();
|
||||
fail("Expected ConcurrentModificationException");
|
||||
} catch (ConcurrentModificationException expected) {
|
||||
// success
|
||||
}
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(absent = SUPPORTS_ADD)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
public void testAddAllArray_unsupportedAllPresent() {
|
||||
try {
|
||||
assertFalse("addAll(allPresent[]) should return false or throw", collection.addAll(e0()));
|
||||
} catch (UnsupportedOperationException tolerated) {
|
||||
}
|
||||
expectUnchanged();
|
||||
}
|
||||
#endignore
|
||||
package speiger.src.testers.PACKAGE.tests.collection;
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
#ignore
|
||||
import static com.google.common.collect.testing.features.CollectionFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION;
|
||||
import static com.google.common.collect.testing.features.CollectionFeature.SUPPORTS_ADD;
|
||||
import static com.google.common.collect.testing.features.CollectionSize.ZERO;
|
||||
#endignore
|
||||
|
||||
import java.util.ConcurrentModificationException;
|
||||
|
||||
import com.google.common.collect.testing.features.CollectionFeature;
|
||||
import com.google.common.collect.testing.features.CollectionSize;
|
||||
|
||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPECollectionAddAllArrayTester KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
#ignore
|
||||
@CollectionFeature.Require(SUPPORTS_ADD)
|
||||
public void testAddAllArray_supportedNothing() {
|
||||
assertFalse("addAll(nothing[]) should return false", collection.addAll(emptyArray()));
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(absent = SUPPORTS_ADD)
|
||||
public void testAddAllArray_unsupportedNothing() {
|
||||
try {
|
||||
assertFalse("addAll(nothing[]) should return false or throw", collection.addAll(emptyArray()));
|
||||
} catch (UnsupportedOperationException tolerated) {
|
||||
}
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(SUPPORTS_ADD)
|
||||
public void testAddAllArray_supportedNonePresent() {
|
||||
assertTrue("addAll(nonePresent[]) should return true", collection.addAll(createDisjointArray()));
|
||||
expectAdded(e3(), e4());
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(absent = SUPPORTS_ADD)
|
||||
public void testAddAllArray_unsupportedNonePresent() {
|
||||
try {
|
||||
collection.addAll(createDisjointArray());
|
||||
fail("addAll(nonePresent[]) should throw");
|
||||
} catch (UnsupportedOperationException expected) {
|
||||
}
|
||||
expectUnchanged();
|
||||
expectMissing(e3(), e4());
|
||||
}
|
||||
#endignore
|
||||
|
||||
#if !TYPE_BOOLEAN
|
||||
#ignore
|
||||
@CollectionFeature.Require(SUPPORTS_ADD)
|
||||
#endignore
|
||||
public void testAddAllArray_supportedToLargeOffset() {
|
||||
try {
|
||||
collection.addAll(createDisjointArray(), 5, 2);
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
}
|
||||
expectUnchanged();
|
||||
expectMissing(e3(), e4());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(SUPPORTS_ADD)
|
||||
#endignore
|
||||
public void testAddAllArray_supportedToLargeArray() {
|
||||
try {
|
||||
collection.addAll(createDisjointArray(), 3);
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
}
|
||||
expectUnchanged();
|
||||
expectMissing(e3(), e4());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(SUPPORTS_ADD)
|
||||
#endignore
|
||||
public void testAddAllArray_supportedToSmallOffset() {
|
||||
try {
|
||||
collection.addAll(createDisjointArray(), -1, 2);
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
}
|
||||
expectUnchanged();
|
||||
expectMissing(e3(), e4());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(SUPPORTS_ADD)
|
||||
#endignore
|
||||
public void testAddAllArray_supportedAddSubArray() {
|
||||
try {
|
||||
collection.addAll(createDisjointArray(), 1);
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
}
|
||||
expectAdded(e3());
|
||||
expectMissing(e4());
|
||||
}
|
||||
#endif
|
||||
#ignore
|
||||
@CollectionFeature.Require(SUPPORTS_ADD)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
public void testAddAllArray_supportedSomePresent() {
|
||||
assertTrue("addAll(somePresent[]) should return true", collection.addAll(e3(), e0()));
|
||||
assertTrue("should contain " + e3(), collection.contains(e3()));
|
||||
assertTrue("should contain " + e0(), collection.contains(e0()));
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(absent = SUPPORTS_ADD)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
public void testAddAllArray_unsupportedSomePresent() {
|
||||
try {
|
||||
collection.addAll(e3(), e0());
|
||||
fail("addAll(somePresent[]) should throw");
|
||||
} catch (UnsupportedOperationException expected) {
|
||||
}
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
@CollectionFeature.Require({ SUPPORTS_ADD, FAILS_FAST_ON_CONCURRENT_MODIFICATION })
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
public void testAddAllArrayConcurrentWithIteration() {
|
||||
#endignore
|
||||
try {
|
||||
ITERATOR KEY_GENERIC_TYPE iterator = collection.iterator();
|
||||
assertTrue(collection.addAll(e3(), e0()));
|
||||
iterator.NEXT();
|
||||
fail("Expected ConcurrentModificationException");
|
||||
} catch (ConcurrentModificationException expected) {
|
||||
// success
|
||||
}
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(absent = SUPPORTS_ADD)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
public void testAddAllArray_unsupportedAllPresent() {
|
||||
try {
|
||||
assertFalse("addAll(allPresent[]) should return false or throw", collection.addAll(e0()));
|
||||
} catch (UnsupportedOperationException tolerated) {
|
||||
}
|
||||
expectUnchanged();
|
||||
}
|
||||
#endignore
|
||||
}
|
|
@ -1,102 +1,102 @@
|
|||
package speiger.src.testers.PACKAGE.tests.collection;
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
#ignore
|
||||
import static com.google.common.collect.testing.features.CollectionFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION;
|
||||
import static com.google.common.collect.testing.features.CollectionFeature.SUPPORTS_ADD;
|
||||
import static com.google.common.collect.testing.features.CollectionSize.ZERO;
|
||||
#endignore
|
||||
|
||||
import java.util.ConcurrentModificationException;
|
||||
|
||||
import com.google.common.collect.testing.features.CollectionFeature;
|
||||
import com.google.common.collect.testing.features.CollectionSize;
|
||||
|
||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
||||
import speiger.src.testers.PACKAGE.utils.MINIMAL_COLLECTION;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPECollectionAddAllTester KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
#ignore
|
||||
@CollectionFeature.Require(SUPPORTS_ADD)
|
||||
public void testAddAll_supportedNothing() {
|
||||
assertFalse("addAll(nothing) should return false", collection.addAll(emptyCollection()));
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(absent = SUPPORTS_ADD)
|
||||
public void testAddAll_unsupportedNothing() {
|
||||
try {
|
||||
assertFalse("addAll(nothing) should return false or throw", collection.addAll(emptyCollection()));
|
||||
} catch (UnsupportedOperationException tolerated) {
|
||||
}
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(SUPPORTS_ADD)
|
||||
public void testAddAll_supportedNonePresent() {
|
||||
assertTrue("addAll(nonePresent) should return true", collection.addAll(createDisjointCollection()));
|
||||
expectAdded(e3(), e4());
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(absent = SUPPORTS_ADD)
|
||||
public void testAddAll_unsupportedNonePresent() {
|
||||
try {
|
||||
collection.addAll(createDisjointCollection());
|
||||
fail("addAll(nonePresent) should throw");
|
||||
} catch (UnsupportedOperationException expected) {
|
||||
}
|
||||
expectUnchanged();
|
||||
expectMissing(e3(), e4());
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(SUPPORTS_ADD)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
public void testAddAll_supportedSomePresent() {
|
||||
#endignore
|
||||
assertTrue("addAll(somePresent) should return true", collection.addAll(MINIMAL_COLLECTION.of(e3(), e0())));
|
||||
assertTrue("should contain " + e3(), collection.contains(e3()));
|
||||
assertTrue("should contain " + e0(), collection.contains(e0()));
|
||||
}
|
||||
#ignore
|
||||
@CollectionFeature.Require(absent = SUPPORTS_ADD)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
public void testAddAll_unsupportedSomePresent() {
|
||||
#endignore
|
||||
try {
|
||||
collection.addAll(MINIMAL_COLLECTION.of(e3(), e0()));
|
||||
fail("addAll(somePresent) should throw");
|
||||
} catch (UnsupportedOperationException expected) {
|
||||
}
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require({ SUPPORTS_ADD, FAILS_FAST_ON_CONCURRENT_MODIFICATION })
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
public void testAddAllConcurrentWithIteration() {
|
||||
#endignore
|
||||
try {
|
||||
ITERATOR KEY_GENERIC_TYPE iterator = collection.iterator();
|
||||
assertTrue(collection.addAll(MINIMAL_COLLECTION.of(e3(), e0())));
|
||||
iterator.NEXT();
|
||||
fail("Expected ConcurrentModificationException");
|
||||
} catch (ConcurrentModificationException expected) {
|
||||
// success
|
||||
}
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(absent = SUPPORTS_ADD)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
public void testAddAll_unsupportedAllPresent() {
|
||||
try {
|
||||
assertFalse("addAll(allPresent) should return false or throw", collection.addAll(MINIMAL_COLLECTION.of(e0())));
|
||||
} catch (UnsupportedOperationException tolerated) {
|
||||
}
|
||||
expectUnchanged();
|
||||
}
|
||||
}
|
||||
package speiger.src.testers.PACKAGE.tests.collection;
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
#ignore
|
||||
import static com.google.common.collect.testing.features.CollectionFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION;
|
||||
import static com.google.common.collect.testing.features.CollectionFeature.SUPPORTS_ADD;
|
||||
import static com.google.common.collect.testing.features.CollectionSize.ZERO;
|
||||
#endignore
|
||||
|
||||
import java.util.ConcurrentModificationException;
|
||||
|
||||
import com.google.common.collect.testing.features.CollectionFeature;
|
||||
import com.google.common.collect.testing.features.CollectionSize;
|
||||
|
||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
||||
import speiger.src.testers.PACKAGE.utils.MINIMAL_COLLECTION;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPECollectionAddAllTester KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
#ignore
|
||||
@CollectionFeature.Require(SUPPORTS_ADD)
|
||||
public void testAddAll_supportedNothing() {
|
||||
assertFalse("addAll(nothing) should return false", collection.addAll(emptyCollection()));
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(absent = SUPPORTS_ADD)
|
||||
public void testAddAll_unsupportedNothing() {
|
||||
try {
|
||||
assertFalse("addAll(nothing) should return false or throw", collection.addAll(emptyCollection()));
|
||||
} catch (UnsupportedOperationException tolerated) {
|
||||
}
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(SUPPORTS_ADD)
|
||||
public void testAddAll_supportedNonePresent() {
|
||||
assertTrue("addAll(nonePresent) should return true", collection.addAll(createDisjointCollection()));
|
||||
expectAdded(e3(), e4());
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(absent = SUPPORTS_ADD)
|
||||
public void testAddAll_unsupportedNonePresent() {
|
||||
try {
|
||||
collection.addAll(createDisjointCollection());
|
||||
fail("addAll(nonePresent) should throw");
|
||||
} catch (UnsupportedOperationException expected) {
|
||||
}
|
||||
expectUnchanged();
|
||||
expectMissing(e3(), e4());
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(SUPPORTS_ADD)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
public void testAddAll_supportedSomePresent() {
|
||||
#endignore
|
||||
assertTrue("addAll(somePresent) should return true", collection.addAll(MINIMAL_COLLECTION.of(e3(), e0())));
|
||||
assertTrue("should contain " + e3(), collection.contains(e3()));
|
||||
assertTrue("should contain " + e0(), collection.contains(e0()));
|
||||
}
|
||||
#ignore
|
||||
@CollectionFeature.Require(absent = SUPPORTS_ADD)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
public void testAddAll_unsupportedSomePresent() {
|
||||
#endignore
|
||||
try {
|
||||
collection.addAll(MINIMAL_COLLECTION.of(e3(), e0()));
|
||||
fail("addAll(somePresent) should throw");
|
||||
} catch (UnsupportedOperationException expected) {
|
||||
}
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require({ SUPPORTS_ADD, FAILS_FAST_ON_CONCURRENT_MODIFICATION })
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
public void testAddAllConcurrentWithIteration() {
|
||||
#endignore
|
||||
try {
|
||||
ITERATOR KEY_GENERIC_TYPE iterator = collection.iterator();
|
||||
assertTrue(collection.addAll(MINIMAL_COLLECTION.of(e3(), e0())));
|
||||
iterator.NEXT();
|
||||
fail("Expected ConcurrentModificationException");
|
||||
} catch (ConcurrentModificationException expected) {
|
||||
// success
|
||||
}
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(absent = SUPPORTS_ADD)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
public void testAddAll_unsupportedAllPresent() {
|
||||
try {
|
||||
assertFalse("addAll(allPresent) should return false or throw", collection.addAll(MINIMAL_COLLECTION.of(e0())));
|
||||
} catch (UnsupportedOperationException tolerated) {
|
||||
}
|
||||
expectUnchanged();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,64 +1,64 @@
|
|||
package speiger.src.testers.PACKAGE.tests.collection;
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
#ignore
|
||||
import static com.google.common.collect.testing.features.CollectionFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION;
|
||||
import static com.google.common.collect.testing.features.CollectionFeature.SUPPORTS_ADD;
|
||||
import static com.google.common.collect.testing.features.CollectionSize.ZERO;
|
||||
#endignore
|
||||
|
||||
import java.util.ConcurrentModificationException;
|
||||
|
||||
import com.google.common.collect.testing.features.CollectionFeature;
|
||||
import com.google.common.collect.testing.features.CollectionSize;
|
||||
|
||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPECollectionAddTester KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
#ignore
|
||||
@CollectionFeature.Require(SUPPORTS_ADD)
|
||||
public void testAdd_supportedNotPresent() {
|
||||
assertTrue("add(notPresent) should return true", collection.add(e3()));
|
||||
expectAdded(e3());
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(absent = SUPPORTS_ADD)
|
||||
public void testAdd_unsupportedNotPresent() {
|
||||
try {
|
||||
collection.add(e3());
|
||||
fail("add(notPresent) should throw");
|
||||
} catch (UnsupportedOperationException expected) {
|
||||
}
|
||||
expectUnchanged();
|
||||
expectMissing(e3());
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(absent = SUPPORTS_ADD)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
public void testAdd_unsupportedPresent() {
|
||||
try {
|
||||
assertFalse("add(present) should return false or throw", collection.add(e0()));
|
||||
} catch (UnsupportedOperationException tolerated) {
|
||||
}
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
@CollectionFeature.Require({ SUPPORTS_ADD, FAILS_FAST_ON_CONCURRENT_MODIFICATION })
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
public void testAddConcurrentWithIteration() {
|
||||
#endignore
|
||||
try {
|
||||
ITERATOR KEY_GENERIC_TYPE iterator = collection.iterator();
|
||||
assertTrue(collection.add(e3()));
|
||||
iterator.NEXT();
|
||||
fail("Expected ConcurrentModificationException");
|
||||
} catch (ConcurrentModificationException expected) {
|
||||
// success
|
||||
}
|
||||
}
|
||||
}
|
||||
package speiger.src.testers.PACKAGE.tests.collection;
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
#ignore
|
||||
import static com.google.common.collect.testing.features.CollectionFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION;
|
||||
import static com.google.common.collect.testing.features.CollectionFeature.SUPPORTS_ADD;
|
||||
import static com.google.common.collect.testing.features.CollectionSize.ZERO;
|
||||
#endignore
|
||||
|
||||
import java.util.ConcurrentModificationException;
|
||||
|
||||
import com.google.common.collect.testing.features.CollectionFeature;
|
||||
import com.google.common.collect.testing.features.CollectionSize;
|
||||
|
||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPECollectionAddTester KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
#ignore
|
||||
@CollectionFeature.Require(SUPPORTS_ADD)
|
||||
public void testAdd_supportedNotPresent() {
|
||||
assertTrue("add(notPresent) should return true", collection.add(e3()));
|
||||
expectAdded(e3());
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(absent = SUPPORTS_ADD)
|
||||
public void testAdd_unsupportedNotPresent() {
|
||||
try {
|
||||
collection.add(e3());
|
||||
fail("add(notPresent) should throw");
|
||||
} catch (UnsupportedOperationException expected) {
|
||||
}
|
||||
expectUnchanged();
|
||||
expectMissing(e3());
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(absent = SUPPORTS_ADD)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
public void testAdd_unsupportedPresent() {
|
||||
try {
|
||||
assertFalse("add(present) should return false or throw", collection.add(e0()));
|
||||
} catch (UnsupportedOperationException tolerated) {
|
||||
}
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
@CollectionFeature.Require({ SUPPORTS_ADD, FAILS_FAST_ON_CONCURRENT_MODIFICATION })
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
public void testAddConcurrentWithIteration() {
|
||||
#endignore
|
||||
try {
|
||||
ITERATOR KEY_GENERIC_TYPE iterator = collection.iterator();
|
||||
assertTrue(collection.add(e3()));
|
||||
iterator.NEXT();
|
||||
fail("Expected ConcurrentModificationException");
|
||||
} catch (ConcurrentModificationException expected) {
|
||||
// success
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,68 +1,68 @@
|
|||
package speiger.src.testers.PACKAGE.tests.collection;
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
#ignore
|
||||
import static com.google.common.collect.testing.features.CollectionFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION;
|
||||
import static com.google.common.collect.testing.features.CollectionFeature.SUPPORTS_REMOVE;
|
||||
import static com.google.common.collect.testing.features.CollectionSize.SEVERAL;
|
||||
import static com.google.common.collect.testing.features.CollectionSize.ZERO;
|
||||
#endignore
|
||||
|
||||
import java.util.ConcurrentModificationException;
|
||||
|
||||
import com.google.common.collect.testing.features.CollectionFeature;
|
||||
import com.google.common.collect.testing.features.CollectionSize;
|
||||
|
||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPECollectionClearTester KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
#ignore
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
public void testClear() {
|
||||
collection.clear();
|
||||
assertTrue("After clear(), a collection should be empty.", collection.isEmpty());
|
||||
assertEquals(0, collection.size());
|
||||
assertFalse(collection.iterator().hasNext());
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(absent = SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
public void testClear_unsupported() {
|
||||
try {
|
||||
collection.clear();
|
||||
fail("clear() should throw UnsupportedOperation if a collection does "
|
||||
+ "not support it and is not empty.");
|
||||
} catch (UnsupportedOperationException expected) {
|
||||
}
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(absent = SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(ZERO)
|
||||
public void testClear_unsupportedByEmptyCollection() {
|
||||
try {
|
||||
collection.clear();
|
||||
} catch (UnsupportedOperationException tolerated) {
|
||||
}
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
@CollectionFeature.Require({ SUPPORTS_REMOVE, FAILS_FAST_ON_CONCURRENT_MODIFICATION })
|
||||
@CollectionSize.Require(SEVERAL)
|
||||
public void testClearConcurrentWithIteration() {
|
||||
#endignore
|
||||
try {
|
||||
ITERATOR KEY_GENERIC_TYPE iterator = collection.iterator();
|
||||
collection.clear();
|
||||
iterator.NEXT();
|
||||
fail("Expected ConcurrentModificationException");
|
||||
} catch (ConcurrentModificationException expected) {
|
||||
// success
|
||||
}
|
||||
}
|
||||
}
|
||||
package speiger.src.testers.PACKAGE.tests.collection;
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
#ignore
|
||||
import static com.google.common.collect.testing.features.CollectionFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION;
|
||||
import static com.google.common.collect.testing.features.CollectionFeature.SUPPORTS_REMOVE;
|
||||
import static com.google.common.collect.testing.features.CollectionSize.SEVERAL;
|
||||
import static com.google.common.collect.testing.features.CollectionSize.ZERO;
|
||||
#endignore
|
||||
|
||||
import java.util.ConcurrentModificationException;
|
||||
|
||||
import com.google.common.collect.testing.features.CollectionFeature;
|
||||
import com.google.common.collect.testing.features.CollectionSize;
|
||||
|
||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPECollectionClearTester KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
#ignore
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
public void testClear() {
|
||||
collection.clear();
|
||||
assertTrue("After clear(), a collection should be empty.", collection.isEmpty());
|
||||
assertEquals(0, collection.size());
|
||||
assertFalse(collection.iterator().hasNext());
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(absent = SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
public void testClear_unsupported() {
|
||||
try {
|
||||
collection.clear();
|
||||
fail("clear() should throw UnsupportedOperation if a collection does "
|
||||
+ "not support it and is not empty.");
|
||||
} catch (UnsupportedOperationException expected) {
|
||||
}
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(absent = SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(ZERO)
|
||||
public void testClear_unsupportedByEmptyCollection() {
|
||||
try {
|
||||
collection.clear();
|
||||
} catch (UnsupportedOperationException tolerated) {
|
||||
}
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
@CollectionFeature.Require({ SUPPORTS_REMOVE, FAILS_FAST_ON_CONCURRENT_MODIFICATION })
|
||||
@CollectionSize.Require(SEVERAL)
|
||||
public void testClearConcurrentWithIteration() {
|
||||
#endignore
|
||||
try {
|
||||
ITERATOR KEY_GENERIC_TYPE iterator = collection.iterator();
|
||||
collection.clear();
|
||||
iterator.NEXT();
|
||||
fail("Expected ConcurrentModificationException");
|
||||
} catch (ConcurrentModificationException expected) {
|
||||
// success
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,165 +1,165 @@
|
|||
package speiger.src.testers.PACKAGE.tests.collection;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.IntFunction;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.Ignore;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||
#if !TYPE_OBJECT
|
||||
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
||||
#endif
|
||||
import speiger.src.collections.utils.ITrimmable;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public abstract class FILE_KEY_TYPECollectionConstructorTester KEY_GENERIC_TYPE extends TestCase
|
||||
{
|
||||
protected Supplier<COLLECTION KEY_GENERIC_TYPE> simpleConstructor;
|
||||
protected IntFunction<COLLECTION KEY_GENERIC_TYPE> sizeConstructor;
|
||||
protected Function<KEY_TYPE[], COLLECTION KEY_GENERIC_TYPE> pArrayConstructor;
|
||||
#if !TYPE_OBJECT
|
||||
protected Function<CLASS_TYPE[], COLLECTION KEY_GENERIC_TYPE> arrayConstructor;
|
||||
#endif
|
||||
protected Function<Collection<? extends CLASS_TYPE>, COLLECTION KEY_GENERIC_TYPE> collectionConstructor;
|
||||
protected Function<COLLECTION KEY_GENERIC_TYPE, COLLECTION KEY_GENERIC_TYPE> pCollectionConstructor;
|
||||
protected KEY_TYPE[] keys = createKeyElements();
|
||||
|
||||
protected void setSimpleConstructor(Supplier<COLLECTION KEY_GENERIC_TYPE> simpleConstructor) {
|
||||
this.simpleConstructor = simpleConstructor;
|
||||
}
|
||||
|
||||
protected void setSizeConstructor(IntFunction<COLLECTION KEY_GENERIC_TYPE> sizeConstructor) {
|
||||
this.sizeConstructor = sizeConstructor;
|
||||
}
|
||||
|
||||
protected void setPArrayConstructor(Function<KEY_TYPE[], COLLECTION KEY_GENERIC_TYPE> pArrayConstructor) {
|
||||
this.pArrayConstructor = pArrayConstructor;
|
||||
}
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
protected void setArrayConstructor(Function<CLASS_TYPE[], COLLECTION KEY_GENERIC_TYPE> arrayConstructor) {
|
||||
this.arrayConstructor = arrayConstructor;
|
||||
}
|
||||
|
||||
#endif
|
||||
protected void setCollectionConstructor(Function<Collection<? extends CLASS_TYPE>, COLLECTION KEY_GENERIC_TYPE> collectionConstructor) {
|
||||
this.collectionConstructor = collectionConstructor;
|
||||
}
|
||||
|
||||
protected void setPCollectionConstructor(Function<COLLECTION KEY_GENERIC_TYPE, COLLECTION KEY_GENERIC_TYPE> pCollectionConstructor) {
|
||||
this.pCollectionConstructor = pCollectionConstructor;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPrimitiveArrayConstructor() {
|
||||
if(pArrayConstructor == null) return;
|
||||
Assert.assertTrue(pArrayConstructor.apply(keys) != null);
|
||||
}
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
@Test
|
||||
public void testArrayConstructor() {
|
||||
if(arrayConstructor == null) return;
|
||||
#if TYPE_OBJECT
|
||||
Assert.assertTrue(arrayConstructor.apply(keys) != null);
|
||||
#else
|
||||
Assert.assertTrue(arrayConstructor.apply(ARRAYS.wrap(keys)) != null);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
@Test
|
||||
public void testPrimitiveMapsConstructor() {
|
||||
if(pCollectionConstructor == null) return;
|
||||
Assert.assertTrue(pCollectionConstructor.apply(new ARRAY_LISTBRACES(keys)) != null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMapsConstructor() {
|
||||
if(collectionConstructor == null) return;
|
||||
Assert.assertTrue(collectionConstructor.apply(new ArrayList<>(new ARRAY_LISTBRACES(keys))) != null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimpleConstructor() {
|
||||
if(simpleConstructor == null) return;
|
||||
Assert.assertTrue(simpleConstructor.get() != null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSizeConstructor_empty() {
|
||||
if(sizeConstructor == null) return;
|
||||
Assert.assertTrue(sizeConstructor.apply(0) != null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSizeConstructor_smallSize() {
|
||||
if(sizeConstructor == null) return;
|
||||
Assert.assertTrue(sizeConstructor.apply(32) != null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSizeConstructor_largeSize() {
|
||||
if(sizeConstructor == null) return;
|
||||
Assert.assertTrue(sizeConstructor.apply(25212) != null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRehash() {
|
||||
if(sizeConstructor == null) return;
|
||||
try
|
||||
{
|
||||
COLLECTION KEY_GENERIC_TYPE set = sizeConstructor.apply(0);
|
||||
if(set instanceof ITrimmable) {
|
||||
ITrimmable trim = (ITrimmable)set;
|
||||
set.addAll(keys);
|
||||
set.clear();
|
||||
Assert.assertTrue(trim.trim());
|
||||
Assert.assertFalse(trim.trim());
|
||||
set.addAll(keys);
|
||||
trim.clearAndTrim();
|
||||
set.addAll(keys);
|
||||
trim.clearAndTrim(Short.MAX_VALUE);
|
||||
}
|
||||
}
|
||||
catch(UnsupportedOperationException e) {
|
||||
//Ignore thats fine
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSizeConstructor_InvalidSize() {
|
||||
if(sizeConstructor == null) return;
|
||||
try {
|
||||
sizeConstructor.apply(-1);
|
||||
Assert.fail("When Inputted Size is negative this should crash");
|
||||
}
|
||||
catch(IllegalStateException e) {
|
||||
}
|
||||
}
|
||||
|
||||
#if TYPE_OBJECT
|
||||
protected abstract KEY_TYPE[] createKeyElements();
|
||||
|
||||
#else
|
||||
protected KEY_TYPE[] createKeyElements() {
|
||||
KEY_TYPE[] keys = NEW_KEY_ARRAY(100);
|
||||
for(int i = 0;i<100;i++) {
|
||||
#if TYPE_BOOLEAN
|
||||
keys[i] = i % 2 != 0;
|
||||
#else
|
||||
keys[i] = (KEY_TYPE)i;
|
||||
#endif
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
#endif
|
||||
package speiger.src.testers.PACKAGE.tests.collection;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.IntFunction;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.Ignore;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||
#if !TYPE_OBJECT
|
||||
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
||||
#endif
|
||||
import speiger.src.collections.utils.ITrimmable;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public abstract class FILE_KEY_TYPECollectionConstructorTester KEY_GENERIC_TYPE extends TestCase
|
||||
{
|
||||
protected Supplier<COLLECTION KEY_GENERIC_TYPE> simpleConstructor;
|
||||
protected IntFunction<COLLECTION KEY_GENERIC_TYPE> sizeConstructor;
|
||||
protected Function<KEY_TYPE[], COLLECTION KEY_GENERIC_TYPE> pArrayConstructor;
|
||||
#if !TYPE_OBJECT
|
||||
protected Function<CLASS_TYPE[], COLLECTION KEY_GENERIC_TYPE> arrayConstructor;
|
||||
#endif
|
||||
protected Function<Collection<? extends CLASS_TYPE>, COLLECTION KEY_GENERIC_TYPE> collectionConstructor;
|
||||
protected Function<COLLECTION KEY_GENERIC_TYPE, COLLECTION KEY_GENERIC_TYPE> pCollectionConstructor;
|
||||
protected KEY_TYPE[] keys = createKeyElements();
|
||||
|
||||
protected void setSimpleConstructor(Supplier<COLLECTION KEY_GENERIC_TYPE> simpleConstructor) {
|
||||
this.simpleConstructor = simpleConstructor;
|
||||
}
|
||||
|
||||
protected void setSizeConstructor(IntFunction<COLLECTION KEY_GENERIC_TYPE> sizeConstructor) {
|
||||
this.sizeConstructor = sizeConstructor;
|
||||
}
|
||||
|
||||
protected void setPArrayConstructor(Function<KEY_TYPE[], COLLECTION KEY_GENERIC_TYPE> pArrayConstructor) {
|
||||
this.pArrayConstructor = pArrayConstructor;
|
||||
}
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
protected void setArrayConstructor(Function<CLASS_TYPE[], COLLECTION KEY_GENERIC_TYPE> arrayConstructor) {
|
||||
this.arrayConstructor = arrayConstructor;
|
||||
}
|
||||
|
||||
#endif
|
||||
protected void setCollectionConstructor(Function<Collection<? extends CLASS_TYPE>, COLLECTION KEY_GENERIC_TYPE> collectionConstructor) {
|
||||
this.collectionConstructor = collectionConstructor;
|
||||
}
|
||||
|
||||
protected void setPCollectionConstructor(Function<COLLECTION KEY_GENERIC_TYPE, COLLECTION KEY_GENERIC_TYPE> pCollectionConstructor) {
|
||||
this.pCollectionConstructor = pCollectionConstructor;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPrimitiveArrayConstructor() {
|
||||
if(pArrayConstructor == null) return;
|
||||
Assert.assertTrue(pArrayConstructor.apply(keys) != null);
|
||||
}
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
@Test
|
||||
public void testArrayConstructor() {
|
||||
if(arrayConstructor == null) return;
|
||||
#if TYPE_OBJECT
|
||||
Assert.assertTrue(arrayConstructor.apply(keys) != null);
|
||||
#else
|
||||
Assert.assertTrue(arrayConstructor.apply(ARRAYS.wrap(keys)) != null);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
@Test
|
||||
public void testPrimitiveMapsConstructor() {
|
||||
if(pCollectionConstructor == null) return;
|
||||
Assert.assertTrue(pCollectionConstructor.apply(new ARRAY_LISTBRACES(keys)) != null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMapsConstructor() {
|
||||
if(collectionConstructor == null) return;
|
||||
Assert.assertTrue(collectionConstructor.apply(new ArrayList<>(new ARRAY_LISTBRACES(keys))) != null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimpleConstructor() {
|
||||
if(simpleConstructor == null) return;
|
||||
Assert.assertTrue(simpleConstructor.get() != null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSizeConstructor_empty() {
|
||||
if(sizeConstructor == null) return;
|
||||
Assert.assertTrue(sizeConstructor.apply(0) != null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSizeConstructor_smallSize() {
|
||||
if(sizeConstructor == null) return;
|
||||
Assert.assertTrue(sizeConstructor.apply(32) != null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSizeConstructor_largeSize() {
|
||||
if(sizeConstructor == null) return;
|
||||
Assert.assertTrue(sizeConstructor.apply(25212) != null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRehash() {
|
||||
if(sizeConstructor == null) return;
|
||||
try
|
||||
{
|
||||
COLLECTION KEY_GENERIC_TYPE set = sizeConstructor.apply(0);
|
||||
if(set instanceof ITrimmable) {
|
||||
ITrimmable trim = (ITrimmable)set;
|
||||
set.addAll(keys);
|
||||
set.clear();
|
||||
Assert.assertTrue(trim.trim());
|
||||
Assert.assertFalse(trim.trim());
|
||||
set.addAll(keys);
|
||||
trim.clearAndTrim();
|
||||
set.addAll(keys);
|
||||
trim.clearAndTrim(Short.MAX_VALUE);
|
||||
}
|
||||
}
|
||||
catch(UnsupportedOperationException e) {
|
||||
//Ignore thats fine
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSizeConstructor_InvalidSize() {
|
||||
if(sizeConstructor == null) return;
|
||||
try {
|
||||
sizeConstructor.apply(-1);
|
||||
Assert.fail("When Inputted Size is negative this should crash");
|
||||
}
|
||||
catch(IllegalStateException e) {
|
||||
}
|
||||
}
|
||||
|
||||
#if TYPE_OBJECT
|
||||
protected abstract KEY_TYPE[] createKeyElements();
|
||||
|
||||
#else
|
||||
protected KEY_TYPE[] createKeyElements() {
|
||||
KEY_TYPE[] keys = NEW_KEY_ARRAY(100);
|
||||
for(int i = 0;i<100;i++) {
|
||||
#if TYPE_BOOLEAN
|
||||
keys[i] = i % 2 != 0;
|
||||
#else
|
||||
keys[i] = (KEY_TYPE)i;
|
||||
#endif
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
#endif
|
||||
}
|
|
@ -1,45 +1,45 @@
|
|||
package speiger.src.testers.PACKAGE.tests.collection;
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
#ignore
|
||||
import static com.google.common.collect.testing.features.CollectionSize.ZERO;
|
||||
#endignore
|
||||
|
||||
import com.google.common.collect.testing.features.CollectionSize;
|
||||
|
||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
||||
import speiger.src.testers.PACKAGE.utils.MINIMAL_COLLECTION;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPECollectionContainsAllTester KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
public void testContainsAll_empty() {
|
||||
assertTrue("containsAll(empty) should return true", collection.containsAll(MINIMAL_COLLECTION.of()));
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
public void testContainsAll_subset() {
|
||||
#endignore
|
||||
assertTrue("containsAll(subset) should return true", collection.containsAll(MINIMAL_COLLECTION.of(e0())));
|
||||
}
|
||||
|
||||
public void testContainsAll_sameElements() {
|
||||
assertTrue("containsAll(sameElements) should return true", collection.containsAll(MINIMAL_COLLECTION.of(createSamplesArray())));
|
||||
}
|
||||
|
||||
public void testContainsAll_self() {
|
||||
assertTrue("containsAll(this) should return true", collection.containsAll(collection));
|
||||
}
|
||||
|
||||
public void testContainsAll_partialOverlap() {
|
||||
assertFalse("containsAll(partialOverlap) should return false", collection.containsAll(MINIMAL_COLLECTION.of(e0(), e3())));
|
||||
}
|
||||
|
||||
public void testContainsAll_disjoint() {
|
||||
assertFalse("containsAll(disjoint) should return false", collection.containsAll(MINIMAL_COLLECTION.of(e3())));
|
||||
}
|
||||
|
||||
}
|
||||
package speiger.src.testers.PACKAGE.tests.collection;
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
#ignore
|
||||
import static com.google.common.collect.testing.features.CollectionSize.ZERO;
|
||||
#endignore
|
||||
|
||||
import com.google.common.collect.testing.features.CollectionSize;
|
||||
|
||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
||||
import speiger.src.testers.PACKAGE.utils.MINIMAL_COLLECTION;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPECollectionContainsAllTester KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
public void testContainsAll_empty() {
|
||||
assertTrue("containsAll(empty) should return true", collection.containsAll(MINIMAL_COLLECTION.of()));
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
public void testContainsAll_subset() {
|
||||
#endignore
|
||||
assertTrue("containsAll(subset) should return true", collection.containsAll(MINIMAL_COLLECTION.of(e0())));
|
||||
}
|
||||
|
||||
public void testContainsAll_sameElements() {
|
||||
assertTrue("containsAll(sameElements) should return true", collection.containsAll(MINIMAL_COLLECTION.of(createSamplesArray())));
|
||||
}
|
||||
|
||||
public void testContainsAll_self() {
|
||||
assertTrue("containsAll(this) should return true", collection.containsAll(collection));
|
||||
}
|
||||
|
||||
public void testContainsAll_partialOverlap() {
|
||||
assertFalse("containsAll(partialOverlap) should return false", collection.containsAll(MINIMAL_COLLECTION.of(e0(), e3())));
|
||||
}
|
||||
|
||||
public void testContainsAll_disjoint() {
|
||||
assertFalse("containsAll(disjoint) should return false", collection.containsAll(MINIMAL_COLLECTION.of(e3())));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,42 +1,42 @@
|
|||
package speiger.src.testers.PACKAGE.tests.collection;
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
#ignore
|
||||
import static com.google.common.collect.testing.features.CollectionSize.ONE;
|
||||
import static com.google.common.collect.testing.features.CollectionSize.ZERO;
|
||||
#endignore
|
||||
|
||||
import com.google.common.collect.testing.features.CollectionSize;
|
||||
|
||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
||||
import speiger.src.testers.PACKAGE.utils.MINIMAL_COLLECTION;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPECollectionContainsAnyTester KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
public void testContainsAny_empty() {
|
||||
assertFalse("containsAny(empty) should return false", collection.containsAny(MINIMAL_COLLECTION.of()));
|
||||
}
|
||||
#ignore
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
public void testContainsAny_subset() {
|
||||
#endignore
|
||||
assertTrue("containsAny(subset) should return true", collection.containsAny(MINIMAL_COLLECTION.of(e0())));
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionSize.Require(ONE)
|
||||
public void testContainsAny_subSetElement() {
|
||||
#endignore
|
||||
assertFalse("containsAny(empty) should return false", collection.containsAny(MINIMAL_COLLECTION.of()));
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionSize.Require(ONE)
|
||||
public void testContainsAny_subSetElements() {
|
||||
#endignore
|
||||
assertTrue("containsAny(subset) should return true", collection.containsAny(getSampleElements(5)));
|
||||
}
|
||||
}
|
||||
package speiger.src.testers.PACKAGE.tests.collection;
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
#ignore
|
||||
import static com.google.common.collect.testing.features.CollectionSize.ONE;
|
||||
import static com.google.common.collect.testing.features.CollectionSize.ZERO;
|
||||
#endignore
|
||||
|
||||
import com.google.common.collect.testing.features.CollectionSize;
|
||||
|
||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
||||
import speiger.src.testers.PACKAGE.utils.MINIMAL_COLLECTION;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPECollectionContainsAnyTester KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
public void testContainsAny_empty() {
|
||||
assertFalse("containsAny(empty) should return false", collection.containsAny(MINIMAL_COLLECTION.of()));
|
||||
}
|
||||
#ignore
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
public void testContainsAny_subset() {
|
||||
#endignore
|
||||
assertTrue("containsAny(subset) should return true", collection.containsAny(MINIMAL_COLLECTION.of(e0())));
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionSize.Require(ONE)
|
||||
public void testContainsAny_subSetElement() {
|
||||
#endignore
|
||||
assertFalse("containsAny(empty) should return false", collection.containsAny(MINIMAL_COLLECTION.of()));
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionSize.Require(ONE)
|
||||
public void testContainsAny_subSetElements() {
|
||||
#endignore
|
||||
assertTrue("containsAny(subset) should return true", collection.containsAny(getSampleElements(5)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,27 +1,27 @@
|
|||
package speiger.src.testers.PACKAGE.tests.collection;
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
#ignore
|
||||
import static com.google.common.collect.testing.features.CollectionSize.ZERO;
|
||||
#endignore
|
||||
|
||||
import com.google.common.collect.testing.features.CollectionSize;
|
||||
|
||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPECollectionContainsTester KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
#ignore
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
public void testContains_yes() {
|
||||
assertTrue("contains(present) should return true", collection.contains(e0()));
|
||||
}
|
||||
|
||||
public void testContains_no() {
|
||||
assertFalse("contains(notPresent) should return false", collection.contains(e3()));
|
||||
}
|
||||
#endignore
|
||||
}
|
||||
package speiger.src.testers.PACKAGE.tests.collection;
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
#ignore
|
||||
import static com.google.common.collect.testing.features.CollectionSize.ZERO;
|
||||
#endignore
|
||||
|
||||
import com.google.common.collect.testing.features.CollectionSize;
|
||||
|
||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPECollectionContainsTester KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
#ignore
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
public void testContains_yes() {
|
||||
assertTrue("contains(present) should return true", collection.contains(e0()));
|
||||
}
|
||||
|
||||
public void testContains_no() {
|
||||
assertFalse("contains(notPresent) should return false", collection.contains(e3()));
|
||||
}
|
||||
#endignore
|
||||
}
|
||||
|
|
|
@ -1,38 +1,38 @@
|
|||
package speiger.src.testers.PACKAGE.tests.collection;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
|
||||
import speiger.src.testers.utils.SpecialFeature;
|
||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||
import speiger.src.collections.PACKAGE.utils.COLLECTIONS;
|
||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPECollectionCopyTester KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
#ignore
|
||||
@SpecialFeature.Require(SpecialFeature.COPYING)
|
||||
#endignore
|
||||
public void testEquals() {
|
||||
COLLECTION KEY_GENERIC_TYPE copy = collection.copy();
|
||||
if(!(collection instanceof COLLECTIONS.EmptyCollection)) {
|
||||
Assert.assertFalse("Copied Collection shouldn't match", copy == collection);
|
||||
}
|
||||
Assert.assertTrue("Copied Collection contents should match", copy.equals(collection));
|
||||
}
|
||||
|
||||
#ignore
|
||||
@SpecialFeature.Require(absent = SpecialFeature.COPYING)
|
||||
#endignore
|
||||
public void testEqualsFail() {
|
||||
try {
|
||||
assertNull(collection.copy());
|
||||
fail("If Copying isn't supported it should throw a UnsupportedOperationException");
|
||||
}
|
||||
catch(UnsupportedOperationException e) {
|
||||
//Success
|
||||
}
|
||||
}
|
||||
}
|
||||
package speiger.src.testers.PACKAGE.tests.collection;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
|
||||
import speiger.src.testers.utils.SpecialFeature;
|
||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||
import speiger.src.collections.PACKAGE.utils.COLLECTIONS;
|
||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPECollectionCopyTester KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
#ignore
|
||||
@SpecialFeature.Require(SpecialFeature.COPYING)
|
||||
#endignore
|
||||
public void testEquals() {
|
||||
COLLECTION KEY_GENERIC_TYPE copy = collection.copy();
|
||||
if(!(collection instanceof COLLECTIONS.EmptyCollection)) {
|
||||
Assert.assertFalse("Copied Collection shouldn't match", copy == collection);
|
||||
}
|
||||
Assert.assertTrue("Copied Collection contents should match", copy.equals(collection));
|
||||
}
|
||||
|
||||
#ignore
|
||||
@SpecialFeature.Require(absent = SpecialFeature.COPYING)
|
||||
#endignore
|
||||
public void testEqualsFail() {
|
||||
try {
|
||||
assertNull(collection.copy());
|
||||
fail("If Copying isn't supported it should throw a UnsupportedOperationException");
|
||||
}
|
||||
catch(UnsupportedOperationException e) {
|
||||
//Success
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,24 +1,24 @@
|
|||
package speiger.src.testers.PACKAGE.tests.collection;
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPECollectionEqualsTester KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
public void testEquals_self() {
|
||||
assertTrue("An Object should be equal to itself.", collection.equals(collection));
|
||||
}
|
||||
|
||||
public void testEquals_null() {
|
||||
// noinspection ObjectEqualsNull
|
||||
assertFalse("An object should not be equal to null.", collection.equals(null));
|
||||
}
|
||||
|
||||
public void testEquals_notACollection() {
|
||||
// noinspection EqualsBetweenInconvertibleTypes
|
||||
assertFalse("A Collection should never equal an object that is not a Collection.", collection.equals("huh?"));
|
||||
}
|
||||
}
|
||||
package speiger.src.testers.PACKAGE.tests.collection;
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPECollectionEqualsTester KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
public void testEquals_self() {
|
||||
assertTrue("An Object should be equal to itself.", collection.equals(collection));
|
||||
}
|
||||
|
||||
public void testEquals_null() {
|
||||
// noinspection ObjectEqualsNull
|
||||
assertFalse("An object should not be equal to null.", collection.equals(null));
|
||||
}
|
||||
|
||||
public void testEquals_notACollection() {
|
||||
// noinspection EqualsBetweenInconvertibleTypes
|
||||
assertFalse("A Collection should never equal an object that is not a Collection.", collection.equals("huh?"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,55 +1,55 @@
|
|||
package speiger.src.testers.PACKAGE.tests.collection;
|
||||
|
||||
#ignore
|
||||
import static com.google.common.collect.testing.features.CollectionFeature.KNOWN_ORDER;
|
||||
#endignore
|
||||
|
||||
import com.google.common.collect.testing.features.CollectionFeature;
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
||||
import speiger.src.testers.PACKAGE.utils.HELPERS;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPECollectionForEachTester KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
#ignore
|
||||
@CollectionFeature.Require(absent = KNOWN_ORDER)
|
||||
public void testForEachUnknownOrder() {
|
||||
#endignore
|
||||
LIST KEY_GENERIC_TYPE elements = new ARRAY_LISTBRACES();
|
||||
collection.forEach(elements::add);
|
||||
HELPERS.assertContentsAnyOrder(elements, createSamplesArray());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(absent = KNOWN_ORDER)
|
||||
public void testForEachExtraUnknownOrder() {
|
||||
#endignore
|
||||
LIST KEY_GENERIC_TYPE elements = new ARRAY_LISTBRACES();
|
||||
collection.forEach(elements, LIST::add);
|
||||
HELPERS.assertContentsAnyOrder(elements, createSamplesArray());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(KNOWN_ORDER)
|
||||
public void testForEachKnownOrder() {
|
||||
#endignore
|
||||
LIST KEY_GENERIC_TYPE elements = new ARRAY_LISTBRACES();
|
||||
collection.forEach(elements::add);
|
||||
assertEquals("Different ordered iteration", HELPERS.copyToList(getOrderedElements()), elements);
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(KNOWN_ORDER)
|
||||
public void testForEachExtraKnownOrder() {
|
||||
#endignore
|
||||
LIST KEY_GENERIC_TYPE elements = new ARRAY_LISTBRACES();
|
||||
collection.forEach(elements, LIST::add);
|
||||
assertEquals("Different ordered iteration", HELPERS.copyToList(getOrderedElements()), elements);
|
||||
}
|
||||
}
|
||||
package speiger.src.testers.PACKAGE.tests.collection;
|
||||
|
||||
#ignore
|
||||
import static com.google.common.collect.testing.features.CollectionFeature.KNOWN_ORDER;
|
||||
#endignore
|
||||
|
||||
import com.google.common.collect.testing.features.CollectionFeature;
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
||||
import speiger.src.testers.PACKAGE.utils.HELPERS;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPECollectionForEachTester KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
#ignore
|
||||
@CollectionFeature.Require(absent = KNOWN_ORDER)
|
||||
public void testForEachUnknownOrder() {
|
||||
#endignore
|
||||
LIST KEY_GENERIC_TYPE elements = new ARRAY_LISTBRACES();
|
||||
collection.forEach(elements::add);
|
||||
HELPERS.assertContentsAnyOrder(elements, createSamplesArray());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(absent = KNOWN_ORDER)
|
||||
public void testForEachExtraUnknownOrder() {
|
||||
#endignore
|
||||
LIST KEY_GENERIC_TYPE elements = new ARRAY_LISTBRACES();
|
||||
collection.forEach(elements, LIST::add);
|
||||
HELPERS.assertContentsAnyOrder(elements, createSamplesArray());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(KNOWN_ORDER)
|
||||
public void testForEachKnownOrder() {
|
||||
#endignore
|
||||
LIST KEY_GENERIC_TYPE elements = new ARRAY_LISTBRACES();
|
||||
collection.forEach(elements::add);
|
||||
assertEquals("Different ordered iteration", HELPERS.copyToList(getOrderedElements()), elements);
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(KNOWN_ORDER)
|
||||
public void testForEachExtraKnownOrder() {
|
||||
#endignore
|
||||
LIST KEY_GENERIC_TYPE elements = new ARRAY_LISTBRACES();
|
||||
collection.forEach(elements, LIST::add);
|
||||
assertEquals("Different ordered iteration", HELPERS.copyToList(getOrderedElements()), elements);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,161 +1,161 @@
|
|||
package speiger.src.testers.PACKAGE.tests.collection;
|
||||
|
||||
#ignore
|
||||
import static com.google.common.collect.testing.IteratorFeature.MODIFIABLE;
|
||||
import static com.google.common.collect.testing.IteratorFeature.UNMODIFIABLE;
|
||||
import static com.google.common.collect.testing.features.CollectionFeature.KNOWN_ORDER;
|
||||
import static com.google.common.collect.testing.features.CollectionFeature.SUPPORTS_ITERATOR_REMOVE;
|
||||
import static com.google.common.collect.testing.features.CollectionSize.ZERO;
|
||||
#endignore
|
||||
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Set;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Collections;
|
||||
|
||||
import com.google.common.collect.testing.IteratorFeature;
|
||||
import com.google.common.collect.testing.features.CollectionFeature;
|
||||
import com.google.common.collect.testing.features.CollectionSize;
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
import speiger.src.collections.PACKAGE.collections.ITERABLE;
|
||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
||||
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||
import speiger.src.collections.PACKAGE.lists.LIST_ITERATOR;
|
||||
import speiger.src.collections.PACKAGE.utils.LISTS;
|
||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
||||
import speiger.src.testers.PACKAGE.utils.HELPERS;
|
||||
import speiger.src.testers.PACKAGE.utils.ITERATOR_TESTER;
|
||||
import speiger.src.testers.PACKAGE.utils.LIST_ITERATOR_TESTER;
|
||||
import speiger.src.testers.PACKAGE.utils.BIDIRECTIONAL_ITERATOR_TESTER;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPECollectionIteratorTester KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
public void testIterator() {
|
||||
LIST KEY_GENERIC_TYPE elements = new ARRAY_LISTBRACES();
|
||||
for (ITERATOR KEY_GENERIC_TYPE iter = collection.iterator();iter.hasNext();) { // uses iterator()
|
||||
elements.add(iter.NEXT());
|
||||
}
|
||||
HELPERS.assertContentsAnyOrder(elements, createSamplesArray());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(KNOWN_ORDER)
|
||||
public void testIterationOrdering() {
|
||||
#endignore
|
||||
LIST KEY_GENERIC_TYPE elements = new ARRAY_LISTBRACES();
|
||||
for (ITERATOR KEY_GENERIC_TYPE iter = collection.iterator();iter.hasNext();) { // uses iterator()
|
||||
elements.add(iter.NEXT());
|
||||
}
|
||||
LIST KEY_GENERIC_TYPE expected = HELPERS.copyToList(getOrderedElements());
|
||||
assertEquals("Different ordered iteration", expected, elements);
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(SUPPORTS_ITERATOR_REMOVE)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
public void testIterator_removeAffectsBackingCollection() {
|
||||
#endignore
|
||||
int originalSize = collection.size();
|
||||
ITERATOR KEY_GENERIC_TYPE iterator = collection.iterator();
|
||||
KEY_TYPE element = iterator.NEXT();
|
||||
assertTrue(collection.contains(element)); // sanity check
|
||||
iterator.remove();
|
||||
assertFalse(collection.contains(element));
|
||||
assertEquals(originalSize - 1, collection.size());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require({ KNOWN_ORDER, SUPPORTS_ITERATOR_REMOVE })
|
||||
public void testIterator_knownOrderRemoveSupported() {
|
||||
#endignore
|
||||
runIteratorTest(MODIFIABLE, ITERATOR_TESTER.KnownOrder.KNOWN_ORDER, getOrderedElements());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(value = KNOWN_ORDER, absent = SUPPORTS_ITERATOR_REMOVE)
|
||||
public void testIterator_knownOrderRemoveUnsupported() {
|
||||
#endignore
|
||||
runIteratorTest(UNMODIFIABLE, ITERATOR_TESTER.KnownOrder.KNOWN_ORDER, getOrderedElements());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(absent = KNOWN_ORDER, value = SUPPORTS_ITERATOR_REMOVE)
|
||||
public void testIterator_unknownOrderRemoveSupported() {
|
||||
#endignore
|
||||
runIteratorTest(MODIFIABLE, ITERATOR_TESTER.KnownOrder.UNKNOWN_ORDER, getSampleElements());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(absent = { KNOWN_ORDER, SUPPORTS_ITERATOR_REMOVE })
|
||||
public void testIterator_unknownOrderRemoveUnsupported() {
|
||||
#endignore
|
||||
runIteratorTest(UNMODIFIABLE, ITERATOR_TESTER.KnownOrder.UNKNOWN_ORDER, getSampleElements());
|
||||
}
|
||||
|
||||
private void runIteratorTest(Set<IteratorFeature> features, ITERATOR_TESTER.KnownOrder knownOrder, ITERABLE KEY_GENERIC_TYPE elements) {
|
||||
if(knownOrder == ITERATOR_TESTER.KnownOrder.KNOWN_ORDER && !(collection instanceof LIST) && collection.iterator() instanceof LIST_ITERATOR) {
|
||||
Set<IteratorFeature> listFeature = features.isEmpty() ? features : EnumSet.copyOf(features);
|
||||
#ignore
|
||||
listFeature.retainAll(EnumSet.of(IteratorFeature.SUPPORTS_REMOVE));
|
||||
#endignore
|
||||
new LIST_ITERATOR_TESTER KEY_GENERIC_TYPE(2, LISTS.singleton(INVALID_VALUE), Collections.unmodifiableSet(listFeature), elements, 0) {
|
||||
@Override
|
||||
protected LIST_ITERATOR KEY_GENERIC_TYPE newTargetIterator() {
|
||||
resetCollection();
|
||||
return (LIST_ITERATOR KEY_GENERIC_TYPE)collection.iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void verify(LIST KEY_GENERIC_TYPE elements) {
|
||||
expectContents(elements);
|
||||
}
|
||||
}.test();
|
||||
}
|
||||
if(collection.iterator() instanceof BI_ITERATOR) {
|
||||
new BIDIRECTIONAL_ITERATOR_TESTER KEY_GENERIC_TYPE(4, features, elements, knownOrder) {
|
||||
@Override
|
||||
protected BI_ITERATOR KEY_GENERIC_TYPE newTargetIterator() {
|
||||
resetCollection();
|
||||
return (BI_ITERATOR KEY_GENERIC_TYPE)collection.iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void verify(LIST KEY_GENERIC_TYPE elements) {
|
||||
expectContents(elements);
|
||||
}
|
||||
}.test();
|
||||
return;
|
||||
}
|
||||
new ITERATOR_TESTER KEY_GENERIC_TYPE(5, features, elements, knownOrder) {
|
||||
@Override
|
||||
protected ITERATOR KEY_GENERIC_TYPE newTargetIterator() {
|
||||
resetCollection();
|
||||
return collection.iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void verify(LIST KEY_GENERIC_TYPE elements) {
|
||||
expectContents(elements);
|
||||
}
|
||||
}.test();
|
||||
}
|
||||
|
||||
public void testIteratorNoSuchElementException() {
|
||||
ITERATOR KEY_GENERIC_TYPE iterator = collection.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
iterator.NEXT();
|
||||
}
|
||||
|
||||
try {
|
||||
iterator.NEXT();
|
||||
fail("iterator.next() should throw NoSuchElementException");
|
||||
} catch (NoSuchElementException expected) {
|
||||
}
|
||||
}
|
||||
}
|
||||
package speiger.src.testers.PACKAGE.tests.collection;
|
||||
|
||||
#ignore
|
||||
import static com.google.common.collect.testing.IteratorFeature.MODIFIABLE;
|
||||
import static com.google.common.collect.testing.IteratorFeature.UNMODIFIABLE;
|
||||
import static com.google.common.collect.testing.features.CollectionFeature.KNOWN_ORDER;
|
||||
import static com.google.common.collect.testing.features.CollectionFeature.SUPPORTS_ITERATOR_REMOVE;
|
||||
import static com.google.common.collect.testing.features.CollectionSize.ZERO;
|
||||
#endignore
|
||||
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Set;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Collections;
|
||||
|
||||
import com.google.common.collect.testing.IteratorFeature;
|
||||
import com.google.common.collect.testing.features.CollectionFeature;
|
||||
import com.google.common.collect.testing.features.CollectionSize;
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
import speiger.src.collections.PACKAGE.collections.ITERABLE;
|
||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
||||
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||
import speiger.src.collections.PACKAGE.lists.LIST_ITERATOR;
|
||||
import speiger.src.collections.PACKAGE.utils.LISTS;
|
||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
||||
import speiger.src.testers.PACKAGE.utils.HELPERS;
|
||||
import speiger.src.testers.PACKAGE.utils.ITERATOR_TESTER;
|
||||
import speiger.src.testers.PACKAGE.utils.LIST_ITERATOR_TESTER;
|
||||
import speiger.src.testers.PACKAGE.utils.BIDIRECTIONAL_ITERATOR_TESTER;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPECollectionIteratorTester KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
public void testIterator() {
|
||||
LIST KEY_GENERIC_TYPE elements = new ARRAY_LISTBRACES();
|
||||
for (ITERATOR KEY_GENERIC_TYPE iter = collection.iterator();iter.hasNext();) { // uses iterator()
|
||||
elements.add(iter.NEXT());
|
||||
}
|
||||
HELPERS.assertContentsAnyOrder(elements, createSamplesArray());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(KNOWN_ORDER)
|
||||
public void testIterationOrdering() {
|
||||
#endignore
|
||||
LIST KEY_GENERIC_TYPE elements = new ARRAY_LISTBRACES();
|
||||
for (ITERATOR KEY_GENERIC_TYPE iter = collection.iterator();iter.hasNext();) { // uses iterator()
|
||||
elements.add(iter.NEXT());
|
||||
}
|
||||
LIST KEY_GENERIC_TYPE expected = HELPERS.copyToList(getOrderedElements());
|
||||
assertEquals("Different ordered iteration", expected, elements);
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(SUPPORTS_ITERATOR_REMOVE)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
public void testIterator_removeAffectsBackingCollection() {
|
||||
#endignore
|
||||
int originalSize = collection.size();
|
||||
ITERATOR KEY_GENERIC_TYPE iterator = collection.iterator();
|
||||
KEY_TYPE element = iterator.NEXT();
|
||||
assertTrue(collection.contains(element)); // sanity check
|
||||
iterator.remove();
|
||||
assertFalse(collection.contains(element));
|
||||
assertEquals(originalSize - 1, collection.size());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require({ KNOWN_ORDER, SUPPORTS_ITERATOR_REMOVE })
|
||||
public void testIterator_knownOrderRemoveSupported() {
|
||||
#endignore
|
||||
runIteratorTest(MODIFIABLE, ITERATOR_TESTER.KnownOrder.KNOWN_ORDER, getOrderedElements());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(value = KNOWN_ORDER, absent = SUPPORTS_ITERATOR_REMOVE)
|
||||
public void testIterator_knownOrderRemoveUnsupported() {
|
||||
#endignore
|
||||
runIteratorTest(UNMODIFIABLE, ITERATOR_TESTER.KnownOrder.KNOWN_ORDER, getOrderedElements());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(absent = KNOWN_ORDER, value = SUPPORTS_ITERATOR_REMOVE)
|
||||
public void testIterator_unknownOrderRemoveSupported() {
|
||||
#endignore
|
||||
runIteratorTest(MODIFIABLE, ITERATOR_TESTER.KnownOrder.UNKNOWN_ORDER, getSampleElements());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(absent = { KNOWN_ORDER, SUPPORTS_ITERATOR_REMOVE })
|
||||
public void testIterator_unknownOrderRemoveUnsupported() {
|
||||
#endignore
|
||||
runIteratorTest(UNMODIFIABLE, ITERATOR_TESTER.KnownOrder.UNKNOWN_ORDER, getSampleElements());
|
||||
}
|
||||
|
||||
private void runIteratorTest(Set<IteratorFeature> features, ITERATOR_TESTER.KnownOrder knownOrder, ITERABLE KEY_GENERIC_TYPE elements) {
|
||||
if(knownOrder == ITERATOR_TESTER.KnownOrder.KNOWN_ORDER && !(collection instanceof LIST) && collection.iterator() instanceof LIST_ITERATOR) {
|
||||
Set<IteratorFeature> listFeature = features.isEmpty() ? features : EnumSet.copyOf(features);
|
||||
#ignore
|
||||
listFeature.retainAll(EnumSet.of(IteratorFeature.SUPPORTS_REMOVE));
|
||||
#endignore
|
||||
new LIST_ITERATOR_TESTER KEY_GENERIC_TYPE(2, LISTS.singleton(INVALID_VALUE), Collections.unmodifiableSet(listFeature), elements, 0) {
|
||||
@Override
|
||||
protected LIST_ITERATOR KEY_GENERIC_TYPE newTargetIterator() {
|
||||
resetCollection();
|
||||
return (LIST_ITERATOR KEY_GENERIC_TYPE)collection.iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void verify(LIST KEY_GENERIC_TYPE elements) {
|
||||
expectContents(elements);
|
||||
}
|
||||
}.test();
|
||||
}
|
||||
if(collection.iterator() instanceof BI_ITERATOR) {
|
||||
new BIDIRECTIONAL_ITERATOR_TESTER KEY_GENERIC_TYPE(4, features, elements, knownOrder) {
|
||||
@Override
|
||||
protected BI_ITERATOR KEY_GENERIC_TYPE newTargetIterator() {
|
||||
resetCollection();
|
||||
return (BI_ITERATOR KEY_GENERIC_TYPE)collection.iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void verify(LIST KEY_GENERIC_TYPE elements) {
|
||||
expectContents(elements);
|
||||
}
|
||||
}.test();
|
||||
return;
|
||||
}
|
||||
new ITERATOR_TESTER KEY_GENERIC_TYPE(5, features, elements, knownOrder) {
|
||||
@Override
|
||||
protected ITERATOR KEY_GENERIC_TYPE newTargetIterator() {
|
||||
resetCollection();
|
||||
return collection.iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void verify(LIST KEY_GENERIC_TYPE elements) {
|
||||
expectContents(elements);
|
||||
}
|
||||
}.test();
|
||||
}
|
||||
|
||||
public void testIteratorNoSuchElementException() {
|
||||
ITERATOR KEY_GENERIC_TYPE iterator = collection.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
iterator.NEXT();
|
||||
}
|
||||
|
||||
try {
|
||||
iterator.NEXT();
|
||||
fail("iterator.next() should throw NoSuchElementException");
|
||||
} catch (NoSuchElementException expected) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,153 +1,153 @@
|
|||
package speiger.src.testers.PACKAGE.tests.collection;
|
||||
|
||||
#ignore
|
||||
import static com.google.common.collect.testing.features.CollectionFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION;
|
||||
import static com.google.common.collect.testing.features.CollectionFeature.SUPPORTS_REMOVE;
|
||||
import static com.google.common.collect.testing.features.CollectionSize.SEVERAL;
|
||||
import static com.google.common.collect.testing.features.CollectionSize.ZERO;
|
||||
#endignore
|
||||
|
||||
import java.util.ConcurrentModificationException;
|
||||
|
||||
import com.google.common.collect.testing.features.CollectionFeature;
|
||||
import com.google.common.collect.testing.features.CollectionSize;
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
||||
import speiger.src.testers.PACKAGE.utils.HELPERS;
|
||||
import speiger.src.testers.PACKAGE.utils.MINIMAL_COLLECTION;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPECollectionRemoveAllTester KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
#ignore
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
#endignore
|
||||
public void testRemoveAll_emptyCollection() {
|
||||
assertFalse("removeAll(emptyCollection) should return false", collection.removeAll(MINIMAL_COLLECTION.of()));
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
#endignore
|
||||
public void testRemoveAll_nonePresent() {
|
||||
assertFalse("removeAll(disjointCollection) should return false", collection.removeAll(MINIMAL_COLLECTION.of(e3())));
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
#endignore
|
||||
public void testRemoveAll_nonePresentFetchRemoved() {
|
||||
LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES();
|
||||
assertFalse("removeAll(disjointCollection) should return false", collection.removeAll(MINIMAL_COLLECTION.of(e3()), list::add));
|
||||
expectUnchanged();
|
||||
assertTrue(list.isEmpty());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
#endignore
|
||||
public void testRemoveAll_emptyCollectionFetching() {
|
||||
LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES();
|
||||
assertFalse("removeAll(emptyCollection) should return false", collection.removeAll(MINIMAL_COLLECTION.of(), list::add));
|
||||
expectUnchanged();
|
||||
assertTrue(list.isEmpty());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testRemoveAll_allPresent() {
|
||||
assertTrue("removeAll(intersectingCollection) should return true", collection.removeAll(MINIMAL_COLLECTION.of(e0())));
|
||||
expectMissing(e0());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testRemoveAll_somePresent() {
|
||||
assertTrue("removeAll(intersectingCollection) should return true", collection.removeAll(MINIMAL_COLLECTION.of(e0(), e3())));
|
||||
expectMissing(e0());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require({ SUPPORTS_REMOVE, FAILS_FAST_ON_CONCURRENT_MODIFICATION })
|
||||
@CollectionSize.Require(SEVERAL)
|
||||
#endignore
|
||||
public void testRemoveAllSomePresentConcurrentWithIteration() {
|
||||
try {
|
||||
ITERATOR KEY_GENERIC_TYPE iterator = collection.iterator();
|
||||
assertTrue(collection.removeAll(MINIMAL_COLLECTION.of(e0(), e3())));
|
||||
iterator.NEXT();
|
||||
fail("Expected ConcurrentModificationException");
|
||||
} catch (ConcurrentModificationException expected) {
|
||||
// success
|
||||
}
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testRemoveAll_somePresentLargeCollectionToRemove() {
|
||||
assertTrue("removeAll(largeIntersectingCollection) should return true", collection.removeAll(MINIMAL_COLLECTION.of(e0(), e0(), e0(), e3(), e3(), e3())));
|
||||
expectMissing(e0());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testRemoveAll_someFetchRemovedElements() {
|
||||
LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES();
|
||||
assertTrue("removeAll(largeIntersectingCollection, RemovedElements) should return true", collection.removeAll(MINIMAL_COLLECTION.of(e0(), e0(), e0(), e3(), e3(), e3()), list::add));
|
||||
expectMissing(e0());
|
||||
HELPERS.assertContentsAnyOrder(list, e0());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(absent = SUPPORTS_REMOVE)
|
||||
#endignore
|
||||
public void testRemoveAll_unsupportedEmptyCollection() {
|
||||
try {
|
||||
assertFalse("removeAll(emptyCollection) should return false or throw UnsupportedOperationException", collection.removeAll(MINIMAL_COLLECTION.of()));
|
||||
} catch (UnsupportedOperationException tolerated) {
|
||||
}
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(absent = SUPPORTS_REMOVE)
|
||||
#endignore
|
||||
public void testRemoveAll_unsupportedNonePresent() {
|
||||
try {
|
||||
assertFalse("removeAll(disjointCollection) should return false or throw UnsupportedOperationException", collection.removeAll(MINIMAL_COLLECTION.of(e3())));
|
||||
} catch (UnsupportedOperationException tolerated) {
|
||||
}
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(absent = SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testRemoveAll_unsupportedPresent() {
|
||||
try {
|
||||
collection.removeAll(MINIMAL_COLLECTION.of(e0()));
|
||||
fail("removeAll(intersectingCollection) should throw UnsupportedOperationException");
|
||||
} catch (UnsupportedOperationException expected) {
|
||||
}
|
||||
expectUnchanged();
|
||||
assertTrue(collection.contains(e0()));
|
||||
}
|
||||
}
|
||||
package speiger.src.testers.PACKAGE.tests.collection;
|
||||
|
||||
#ignore
|
||||
import static com.google.common.collect.testing.features.CollectionFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION;
|
||||
import static com.google.common.collect.testing.features.CollectionFeature.SUPPORTS_REMOVE;
|
||||
import static com.google.common.collect.testing.features.CollectionSize.SEVERAL;
|
||||
import static com.google.common.collect.testing.features.CollectionSize.ZERO;
|
||||
#endignore
|
||||
|
||||
import java.util.ConcurrentModificationException;
|
||||
|
||||
import com.google.common.collect.testing.features.CollectionFeature;
|
||||
import com.google.common.collect.testing.features.CollectionSize;
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
||||
import speiger.src.testers.PACKAGE.utils.HELPERS;
|
||||
import speiger.src.testers.PACKAGE.utils.MINIMAL_COLLECTION;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPECollectionRemoveAllTester KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
#ignore
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
#endignore
|
||||
public void testRemoveAll_emptyCollection() {
|
||||
assertFalse("removeAll(emptyCollection) should return false", collection.removeAll(MINIMAL_COLLECTION.of()));
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
#endignore
|
||||
public void testRemoveAll_nonePresent() {
|
||||
assertFalse("removeAll(disjointCollection) should return false", collection.removeAll(MINIMAL_COLLECTION.of(e3())));
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
#endignore
|
||||
public void testRemoveAll_nonePresentFetchRemoved() {
|
||||
LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES();
|
||||
assertFalse("removeAll(disjointCollection) should return false", collection.removeAll(MINIMAL_COLLECTION.of(e3()), list::add));
|
||||
expectUnchanged();
|
||||
assertTrue(list.isEmpty());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
#endignore
|
||||
public void testRemoveAll_emptyCollectionFetching() {
|
||||
LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES();
|
||||
assertFalse("removeAll(emptyCollection) should return false", collection.removeAll(MINIMAL_COLLECTION.of(), list::add));
|
||||
expectUnchanged();
|
||||
assertTrue(list.isEmpty());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testRemoveAll_allPresent() {
|
||||
assertTrue("removeAll(intersectingCollection) should return true", collection.removeAll(MINIMAL_COLLECTION.of(e0())));
|
||||
expectMissing(e0());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testRemoveAll_somePresent() {
|
||||
assertTrue("removeAll(intersectingCollection) should return true", collection.removeAll(MINIMAL_COLLECTION.of(e0(), e3())));
|
||||
expectMissing(e0());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require({ SUPPORTS_REMOVE, FAILS_FAST_ON_CONCURRENT_MODIFICATION })
|
||||
@CollectionSize.Require(SEVERAL)
|
||||
#endignore
|
||||
public void testRemoveAllSomePresentConcurrentWithIteration() {
|
||||
try {
|
||||
ITERATOR KEY_GENERIC_TYPE iterator = collection.iterator();
|
||||
assertTrue(collection.removeAll(MINIMAL_COLLECTION.of(e0(), e3())));
|
||||
iterator.NEXT();
|
||||
fail("Expected ConcurrentModificationException");
|
||||
} catch (ConcurrentModificationException expected) {
|
||||
// success
|
||||
}
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testRemoveAll_somePresentLargeCollectionToRemove() {
|
||||
assertTrue("removeAll(largeIntersectingCollection) should return true", collection.removeAll(MINIMAL_COLLECTION.of(e0(), e0(), e0(), e3(), e3(), e3())));
|
||||
expectMissing(e0());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testRemoveAll_someFetchRemovedElements() {
|
||||
LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES();
|
||||
assertTrue("removeAll(largeIntersectingCollection, RemovedElements) should return true", collection.removeAll(MINIMAL_COLLECTION.of(e0(), e0(), e0(), e3(), e3(), e3()), list::add));
|
||||
expectMissing(e0());
|
||||
HELPERS.assertContentsAnyOrder(list, e0());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(absent = SUPPORTS_REMOVE)
|
||||
#endignore
|
||||
public void testRemoveAll_unsupportedEmptyCollection() {
|
||||
try {
|
||||
assertFalse("removeAll(emptyCollection) should return false or throw UnsupportedOperationException", collection.removeAll(MINIMAL_COLLECTION.of()));
|
||||
} catch (UnsupportedOperationException tolerated) {
|
||||
}
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(absent = SUPPORTS_REMOVE)
|
||||
#endignore
|
||||
public void testRemoveAll_unsupportedNonePresent() {
|
||||
try {
|
||||
assertFalse("removeAll(disjointCollection) should return false or throw UnsupportedOperationException", collection.removeAll(MINIMAL_COLLECTION.of(e3())));
|
||||
} catch (UnsupportedOperationException tolerated) {
|
||||
}
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(absent = SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testRemoveAll_unsupportedPresent() {
|
||||
try {
|
||||
collection.removeAll(MINIMAL_COLLECTION.of(e0()));
|
||||
fail("removeAll(intersectingCollection) should throw UnsupportedOperationException");
|
||||
} catch (UnsupportedOperationException expected) {
|
||||
}
|
||||
expectUnchanged();
|
||||
assertTrue(collection.contains(e0()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,119 +1,119 @@
|
|||
package speiger.src.testers.PACKAGE.tests.collection;
|
||||
|
||||
#ignore
|
||||
import static com.google.common.collect.testing.features.CollectionFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION;
|
||||
import static com.google.common.collect.testing.features.CollectionFeature.SUPPORTS_REMOVE;
|
||||
import static com.google.common.collect.testing.features.CollectionSize.SEVERAL;
|
||||
import static com.google.common.collect.testing.features.CollectionSize.ZERO;
|
||||
#endignore
|
||||
|
||||
import java.util.ConcurrentModificationException;
|
||||
#if TYPE_OBJECT
|
||||
import java.util.Objects;
|
||||
#endif
|
||||
|
||||
import com.google.common.collect.testing.features.CollectionFeature;
|
||||
import com.google.common.collect.testing.features.CollectionSize;
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPECollectionRemoveIfTester KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
#ignore
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
#endignore
|
||||
public void testRemoveIf_alwaysFalse() {
|
||||
#if TYPE_OBJECT
|
||||
assertFalse("remoIf(x -> false) should return false", collection.removeIf(x -> false));
|
||||
#else
|
||||
assertFalse("remoIf(x -> false) should return false", collection.remIf(x -> false));
|
||||
#endif
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testRemoveIf_sometimesTrue() {
|
||||
assertTrue("remIf(isEqual(present)) should return true",
|
||||
#if TYPE_OBJECT
|
||||
collection.removeIf(T -> Objects.equals(T, e0())));
|
||||
#else
|
||||
collection.remIf(T -> T == e0()));
|
||||
#endif
|
||||
expectMissing(samples.e0());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testRemoveIf_allPresent() {
|
||||
#if TYPE_OBJECT
|
||||
assertTrue("remIf(x -> true) should return true", collection.removeIf(x -> true));
|
||||
#else
|
||||
assertTrue("remIf(x -> true) should return true", collection.remIf(x -> true));
|
||||
#endif
|
||||
expectContents();
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require({ SUPPORTS_REMOVE, FAILS_FAST_ON_CONCURRENT_MODIFICATION })
|
||||
@CollectionSize.Require(SEVERAL)
|
||||
#endignore
|
||||
public void testRemoveIfSomeMatchesConcurrentWithIteration() {
|
||||
try {
|
||||
ITERATOR KEY_GENERIC_TYPE iterator = collection.iterator();
|
||||
#if TYPE_OBJECT
|
||||
assertTrue(collection.removeIf(T -> Objects.equals(T, e0())));
|
||||
#else
|
||||
assertTrue(collection.remIf(T -> T == e0()));
|
||||
#endif
|
||||
iterator.NEXT();
|
||||
fail("Expected ConcurrentModificationException");
|
||||
} catch (ConcurrentModificationException expected) {
|
||||
// success
|
||||
}
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(absent = SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(ZERO)
|
||||
#endignore
|
||||
public void testRemoveIf_unsupportedEmptyCollection() {
|
||||
try {
|
||||
assertFalse("remIf(Predicate) should return false or throw UnsupportedOperationException",
|
||||
#if TYPE_OBJECT
|
||||
collection.removeIf(x -> {throw new AssertionError("predicate should never be called");}));
|
||||
#else
|
||||
collection.remIf(x -> {throw new AssertionError("predicate should never be called");}));
|
||||
#endif
|
||||
} catch (UnsupportedOperationException tolerated) {
|
||||
}
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(absent = SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testRemoveIf_alwaysTrueUnsupported() {
|
||||
try {
|
||||
#if TYPE_OBJECT
|
||||
collection.removeIf(x -> true);
|
||||
#else
|
||||
collection.remIf(x -> true);
|
||||
fail("remIf(x -> true) should throw " + "UnsupportedOperationException");
|
||||
#endif
|
||||
} catch (UnsupportedOperationException expected) {
|
||||
}
|
||||
expectUnchanged();
|
||||
assertTrue(collection.contains(samples.e0()));
|
||||
}
|
||||
package speiger.src.testers.PACKAGE.tests.collection;
|
||||
|
||||
#ignore
|
||||
import static com.google.common.collect.testing.features.CollectionFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION;
|
||||
import static com.google.common.collect.testing.features.CollectionFeature.SUPPORTS_REMOVE;
|
||||
import static com.google.common.collect.testing.features.CollectionSize.SEVERAL;
|
||||
import static com.google.common.collect.testing.features.CollectionSize.ZERO;
|
||||
#endignore
|
||||
|
||||
import java.util.ConcurrentModificationException;
|
||||
#if TYPE_OBJECT
|
||||
import java.util.Objects;
|
||||
#endif
|
||||
|
||||
import com.google.common.collect.testing.features.CollectionFeature;
|
||||
import com.google.common.collect.testing.features.CollectionSize;
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPECollectionRemoveIfTester KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
#ignore
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
#endignore
|
||||
public void testRemoveIf_alwaysFalse() {
|
||||
#if TYPE_OBJECT
|
||||
assertFalse("remoIf(x -> false) should return false", collection.removeIf(x -> false));
|
||||
#else
|
||||
assertFalse("remoIf(x -> false) should return false", collection.remIf(x -> false));
|
||||
#endif
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testRemoveIf_sometimesTrue() {
|
||||
assertTrue("remIf(isEqual(present)) should return true",
|
||||
#if TYPE_OBJECT
|
||||
collection.removeIf(T -> Objects.equals(T, e0())));
|
||||
#else
|
||||
collection.remIf(T -> T == e0()));
|
||||
#endif
|
||||
expectMissing(samples.e0());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testRemoveIf_allPresent() {
|
||||
#if TYPE_OBJECT
|
||||
assertTrue("remIf(x -> true) should return true", collection.removeIf(x -> true));
|
||||
#else
|
||||
assertTrue("remIf(x -> true) should return true", collection.remIf(x -> true));
|
||||
#endif
|
||||
expectContents();
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require({ SUPPORTS_REMOVE, FAILS_FAST_ON_CONCURRENT_MODIFICATION })
|
||||
@CollectionSize.Require(SEVERAL)
|
||||
#endignore
|
||||
public void testRemoveIfSomeMatchesConcurrentWithIteration() {
|
||||
try {
|
||||
ITERATOR KEY_GENERIC_TYPE iterator = collection.iterator();
|
||||
#if TYPE_OBJECT
|
||||
assertTrue(collection.removeIf(T -> Objects.equals(T, e0())));
|
||||
#else
|
||||
assertTrue(collection.remIf(T -> T == e0()));
|
||||
#endif
|
||||
iterator.NEXT();
|
||||
fail("Expected ConcurrentModificationException");
|
||||
} catch (ConcurrentModificationException expected) {
|
||||
// success
|
||||
}
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(absent = SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(ZERO)
|
||||
#endignore
|
||||
public void testRemoveIf_unsupportedEmptyCollection() {
|
||||
try {
|
||||
assertFalse("remIf(Predicate) should return false or throw UnsupportedOperationException",
|
||||
#if TYPE_OBJECT
|
||||
collection.removeIf(x -> {throw new AssertionError("predicate should never be called");}));
|
||||
#else
|
||||
collection.remIf(x -> {throw new AssertionError("predicate should never be called");}));
|
||||
#endif
|
||||
} catch (UnsupportedOperationException tolerated) {
|
||||
}
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(absent = SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testRemoveIf_alwaysTrueUnsupported() {
|
||||
try {
|
||||
#if TYPE_OBJECT
|
||||
collection.removeIf(x -> true);
|
||||
#else
|
||||
collection.remIf(x -> true);
|
||||
fail("remIf(x -> true) should throw " + "UnsupportedOperationException");
|
||||
#endif
|
||||
} catch (UnsupportedOperationException expected) {
|
||||
}
|
||||
expectUnchanged();
|
||||
assertTrue(collection.contains(samples.e0()));
|
||||
}
|
||||
}
|
|
@ -1,337 +1,337 @@
|
|||
package speiger.src.testers.PACKAGE.tests.collection;
|
||||
|
||||
#ignore
|
||||
import static com.google.common.collect.testing.features.CollectionFeature.SUPPORTS_REMOVE;
|
||||
import static com.google.common.collect.testing.features.CollectionSize.ONE;
|
||||
import static com.google.common.collect.testing.features.CollectionSize.ZERO;
|
||||
#endignore
|
||||
|
||||
import com.google.common.collect.testing.features.CollectionFeature;
|
||||
import com.google.common.collect.testing.features.CollectionSize;
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
||||
import speiger.src.testers.PACKAGE.utils.HELPERS;
|
||||
import speiger.src.testers.PACKAGE.utils.MINIMAL_COLLECTION;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPECollectionRetainAllTester KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
|
||||
private class Target {
|
||||
private final COLLECTION KEY_GENERIC_TYPE toRetain;
|
||||
private final COLLECTION KEY_GENERIC_TYPE inverse = ARRAY_LIST.wrap(createSamplesArray());
|
||||
private final String description;
|
||||
|
||||
private Target(COLLECTION KEY_GENERIC_TYPE toRetain, String description) {
|
||||
this.toRetain = toRetain;
|
||||
inverse.removeAll(toRetain);
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return description;
|
||||
}
|
||||
}
|
||||
|
||||
private Target empty;
|
||||
private Target disjoint;
|
||||
private Target superset;
|
||||
private Target nonEmptyProperSubset;
|
||||
private Target sameElements;
|
||||
private Target partialOverlap;
|
||||
private Target containsDuplicates;
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
empty = new Target(emptyCollection(), "empty");
|
||||
disjoint = new Target(ARRAY_LIST.wrap(e3(), e4()), "disjoint");
|
||||
superset = new Target(MINIMAL_COLLECTION.of(e0(), e1(), e2(), e3(), e4()), "superset");
|
||||
nonEmptyProperSubset = new Target(MINIMAL_COLLECTION.of(e1()), "subset");
|
||||
sameElements = new Target(ARRAY_LIST.wrap(createSamplesArray()), "sameElements");
|
||||
containsDuplicates = new Target(MINIMAL_COLLECTION.of(e0(), e0(), e3(), e3()), "containsDuplicates");
|
||||
partialOverlap = new Target(MINIMAL_COLLECTION.of(e2(), e3()), "partialOverlap");
|
||||
}
|
||||
|
||||
// retainAll(empty)
|
||||
#ignore
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(ZERO)
|
||||
public void testRetainAll_emptyPreviouslyEmpty() {
|
||||
expectReturnsFalse(empty);
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(ZERO)
|
||||
public void testRetainAllExtra_emptyPreviouslyEmpty() {
|
||||
expectReturnsFalseExtra(empty);
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(absent = SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(ZERO)
|
||||
public void testRetainAll_emptyPreviouslyEmptyUnsupported() {
|
||||
expectReturnsFalseOrThrows(empty);
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
public void testRetainAll_emptyPreviouslyNonEmpty() {
|
||||
expectReturnsTrue(empty);
|
||||
expectContents();
|
||||
expectMissing(e0(), e1(), e2());
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
public void testRetainAllExtra_emptyPreviouslyNonEmpty() {
|
||||
expectReturnsTrueExtra(empty);
|
||||
expectContents();
|
||||
expectMissing(e0(), e1(), e2());
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(absent = SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
public void testRetainAll_emptyPreviouslyNonEmptyUnsupported() {
|
||||
expectThrows(empty);
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
// retainAll(disjoint)
|
||||
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(ZERO)
|
||||
public void testRetainAll_disjointPreviouslyEmpty() {
|
||||
expectReturnsFalse(disjoint);
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(ZERO)
|
||||
public void testRetainAllExtra_disjointPreviouslyEmpty() {
|
||||
expectReturnsFalseExtra(disjoint);
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(absent = SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(ZERO)
|
||||
public void testRetainAll_disjointPreviouslyEmptyUnsupported() {
|
||||
expectReturnsFalseOrThrows(disjoint);
|
||||
expectUnchanged();
|
||||
}
|
||||
#endignore
|
||||
#if !TYPE_BOOLEAN
|
||||
#ignore
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testRetainAll_disjointPreviouslyNonEmpty() {
|
||||
expectReturnsTrue(disjoint);
|
||||
expectContents();
|
||||
expectMissing(e0(), e1(), e2());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testRetainAllExtra_disjointPreviouslyNonEmpty() {
|
||||
expectReturnsTrueExtra(disjoint);
|
||||
expectContents();
|
||||
expectMissing(e0(), e1(), e2());
|
||||
}
|
||||
|
||||
#endif
|
||||
#ignore
|
||||
@CollectionFeature.Require(absent = SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
public void testRetainAll_disjointPreviouslyNonEmptyUnsupported() {
|
||||
expectThrows(disjoint);
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
// retainAll(superset)
|
||||
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
public void testRetainAll_superset() {
|
||||
expectReturnsFalse(superset);
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
public void testRetainAllExtra_superset() {
|
||||
expectReturnsFalseExtra(superset);
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(absent = SUPPORTS_REMOVE)
|
||||
public void testRetainAll_supersetUnsupported() {
|
||||
expectReturnsFalseOrThrows(superset);
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
// retainAll(subset)
|
||||
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(absent = { ZERO, ONE })
|
||||
public void testRetainAll_subset() {
|
||||
expectReturnsTrue(nonEmptyProperSubset);
|
||||
expectContents(nonEmptyProperSubset.toRetain);
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(absent = { ZERO, ONE })
|
||||
public void testRetainAllExtra_subset() {
|
||||
expectReturnsTrueExtra(nonEmptyProperSubset);
|
||||
expectContents(nonEmptyProperSubset.toRetain);
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(absent = SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(absent = { ZERO, ONE })
|
||||
public void testRetainAll_subsetUnsupported() {
|
||||
expectThrows(nonEmptyProperSubset);
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
// retainAll(sameElements)
|
||||
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
public void testRetainAll_sameElements() {
|
||||
expectReturnsFalse(sameElements);
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
public void testRetainAllExtra_sameElements() {
|
||||
expectReturnsFalseExtra(sameElements);
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(absent = SUPPORTS_REMOVE)
|
||||
public void testRetainAll_sameElementsUnsupported() {
|
||||
expectReturnsFalseOrThrows(sameElements);
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
// retainAll(partialOverlap)
|
||||
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(absent = { ZERO, ONE })
|
||||
public void testRetainAll_partialOverlap() {
|
||||
expectReturnsTrue(partialOverlap);
|
||||
expectContents(e2());
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(absent = { ZERO, ONE })
|
||||
public void testRetainAllExtra_partialOverlap() {
|
||||
expectReturnsTrueExtra(partialOverlap);
|
||||
expectContents(e2());
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(absent = SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(absent = { ZERO, ONE })
|
||||
public void testRetainAll_partialOverlapUnsupported() {
|
||||
expectThrows(partialOverlap);
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
// retainAll(containsDuplicates)
|
||||
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(ONE)
|
||||
public void testRetainAll_containsDuplicatesSizeOne() {
|
||||
expectReturnsFalse(containsDuplicates);
|
||||
expectContents(e0());
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(ONE)
|
||||
public void testRetainAllExtra_containsDuplicatesSizeOne() {
|
||||
expectReturnsFalseExtra(containsDuplicates);
|
||||
expectContents(e0());
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(absent = { ZERO, ONE })
|
||||
public void testRetainAll_containsDuplicatesSizeSeveral() {
|
||||
expectReturnsTrue(containsDuplicates);
|
||||
expectContents(e0());
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(absent = { ZERO, ONE })
|
||||
public void testRetainAllExtra_containsDuplicatesSizeSeveral() {
|
||||
expectReturnsTrueExtra(containsDuplicates);
|
||||
expectContents(e0());
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(ZERO)
|
||||
public void testRetainAll_nullCollectionReferenceEmptySubject() {
|
||||
try {
|
||||
collection.retainAll(null);
|
||||
// Returning successfully is not ideal, but tolerated.
|
||||
} catch (NullPointerException tolerated) {
|
||||
}
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
public void testRetainAll_nullCollectionReferenceNonEmptySubject() {
|
||||
try {
|
||||
collection.retainAll(null);
|
||||
fail("retainAll(null) should throw NullPointerException");
|
||||
} catch (NullPointerException expected) {
|
||||
}
|
||||
}
|
||||
|
||||
#endignore
|
||||
private void expectReturnsTrue(Target target) {
|
||||
String message = String.format("retainAll(%s) should return true", target);
|
||||
assertTrue(message, collection.retainAll(target.toRetain));
|
||||
}
|
||||
|
||||
private void expectReturnsTrueExtra(Target target) {
|
||||
String message = String.format("retainAll(%s, Removed) should return true", target);
|
||||
LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES();
|
||||
assertTrue(message, collection.retainAll(target.toRetain, list::add));
|
||||
HELPERS.assertEqualIgnoringOrder(target.inverse, list);
|
||||
}
|
||||
|
||||
private void expectReturnsFalse(Target target) {
|
||||
String message = String.format("retainAll(%s) should return false", target);
|
||||
assertFalse(message, collection.retainAll(target.toRetain));
|
||||
}
|
||||
|
||||
private void expectReturnsFalseExtra(Target target) {
|
||||
String message = String.format("retainAll(%s, Removed) should return false", target);
|
||||
assertFalse(message, collection.retainAll(target.toRetain, T -> {}));
|
||||
}
|
||||
|
||||
private void expectThrows(Target target) {
|
||||
try {
|
||||
collection.retainAll(target.toRetain);
|
||||
fail(String.format("retainAll(%s) should throw", target));
|
||||
} catch (UnsupportedOperationException expected) {
|
||||
}
|
||||
}
|
||||
|
||||
private void expectReturnsFalseOrThrows(Target target) {
|
||||
String message = String.format("retainAll(%s) should return false or throw", target);
|
||||
try {
|
||||
assertFalse(message, collection.retainAll(target.toRetain));
|
||||
} catch (UnsupportedOperationException tolerated) {
|
||||
}
|
||||
}
|
||||
}
|
||||
package speiger.src.testers.PACKAGE.tests.collection;
|
||||
|
||||
#ignore
|
||||
import static com.google.common.collect.testing.features.CollectionFeature.SUPPORTS_REMOVE;
|
||||
import static com.google.common.collect.testing.features.CollectionSize.ONE;
|
||||
import static com.google.common.collect.testing.features.CollectionSize.ZERO;
|
||||
#endignore
|
||||
|
||||
import com.google.common.collect.testing.features.CollectionFeature;
|
||||
import com.google.common.collect.testing.features.CollectionSize;
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
||||
import speiger.src.testers.PACKAGE.utils.HELPERS;
|
||||
import speiger.src.testers.PACKAGE.utils.MINIMAL_COLLECTION;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPECollectionRetainAllTester KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
|
||||
private class Target {
|
||||
private final COLLECTION KEY_GENERIC_TYPE toRetain;
|
||||
private final COLLECTION KEY_GENERIC_TYPE inverse = ARRAY_LIST.wrap(createSamplesArray());
|
||||
private final String description;
|
||||
|
||||
private Target(COLLECTION KEY_GENERIC_TYPE toRetain, String description) {
|
||||
this.toRetain = toRetain;
|
||||
inverse.removeAll(toRetain);
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return description;
|
||||
}
|
||||
}
|
||||
|
||||
private Target empty;
|
||||
private Target disjoint;
|
||||
private Target superset;
|
||||
private Target nonEmptyProperSubset;
|
||||
private Target sameElements;
|
||||
private Target partialOverlap;
|
||||
private Target containsDuplicates;
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
empty = new Target(emptyCollection(), "empty");
|
||||
disjoint = new Target(ARRAY_LIST.wrap(e3(), e4()), "disjoint");
|
||||
superset = new Target(MINIMAL_COLLECTION.of(e0(), e1(), e2(), e3(), e4()), "superset");
|
||||
nonEmptyProperSubset = new Target(MINIMAL_COLLECTION.of(e1()), "subset");
|
||||
sameElements = new Target(ARRAY_LIST.wrap(createSamplesArray()), "sameElements");
|
||||
containsDuplicates = new Target(MINIMAL_COLLECTION.of(e0(), e0(), e3(), e3()), "containsDuplicates");
|
||||
partialOverlap = new Target(MINIMAL_COLLECTION.of(e2(), e3()), "partialOverlap");
|
||||
}
|
||||
|
||||
// retainAll(empty)
|
||||
#ignore
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(ZERO)
|
||||
public void testRetainAll_emptyPreviouslyEmpty() {
|
||||
expectReturnsFalse(empty);
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(ZERO)
|
||||
public void testRetainAllExtra_emptyPreviouslyEmpty() {
|
||||
expectReturnsFalseExtra(empty);
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(absent = SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(ZERO)
|
||||
public void testRetainAll_emptyPreviouslyEmptyUnsupported() {
|
||||
expectReturnsFalseOrThrows(empty);
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
public void testRetainAll_emptyPreviouslyNonEmpty() {
|
||||
expectReturnsTrue(empty);
|
||||
expectContents();
|
||||
expectMissing(e0(), e1(), e2());
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
public void testRetainAllExtra_emptyPreviouslyNonEmpty() {
|
||||
expectReturnsTrueExtra(empty);
|
||||
expectContents();
|
||||
expectMissing(e0(), e1(), e2());
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(absent = SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
public void testRetainAll_emptyPreviouslyNonEmptyUnsupported() {
|
||||
expectThrows(empty);
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
// retainAll(disjoint)
|
||||
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(ZERO)
|
||||
public void testRetainAll_disjointPreviouslyEmpty() {
|
||||
expectReturnsFalse(disjoint);
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(ZERO)
|
||||
public void testRetainAllExtra_disjointPreviouslyEmpty() {
|
||||
expectReturnsFalseExtra(disjoint);
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(absent = SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(ZERO)
|
||||
public void testRetainAll_disjointPreviouslyEmptyUnsupported() {
|
||||
expectReturnsFalseOrThrows(disjoint);
|
||||
expectUnchanged();
|
||||
}
|
||||
#endignore
|
||||
#if !TYPE_BOOLEAN
|
||||
#ignore
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testRetainAll_disjointPreviouslyNonEmpty() {
|
||||
expectReturnsTrue(disjoint);
|
||||
expectContents();
|
||||
expectMissing(e0(), e1(), e2());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testRetainAllExtra_disjointPreviouslyNonEmpty() {
|
||||
expectReturnsTrueExtra(disjoint);
|
||||
expectContents();
|
||||
expectMissing(e0(), e1(), e2());
|
||||
}
|
||||
|
||||
#endif
|
||||
#ignore
|
||||
@CollectionFeature.Require(absent = SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
public void testRetainAll_disjointPreviouslyNonEmptyUnsupported() {
|
||||
expectThrows(disjoint);
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
// retainAll(superset)
|
||||
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
public void testRetainAll_superset() {
|
||||
expectReturnsFalse(superset);
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
public void testRetainAllExtra_superset() {
|
||||
expectReturnsFalseExtra(superset);
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(absent = SUPPORTS_REMOVE)
|
||||
public void testRetainAll_supersetUnsupported() {
|
||||
expectReturnsFalseOrThrows(superset);
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
// retainAll(subset)
|
||||
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(absent = { ZERO, ONE })
|
||||
public void testRetainAll_subset() {
|
||||
expectReturnsTrue(nonEmptyProperSubset);
|
||||
expectContents(nonEmptyProperSubset.toRetain);
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(absent = { ZERO, ONE })
|
||||
public void testRetainAllExtra_subset() {
|
||||
expectReturnsTrueExtra(nonEmptyProperSubset);
|
||||
expectContents(nonEmptyProperSubset.toRetain);
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(absent = SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(absent = { ZERO, ONE })
|
||||
public void testRetainAll_subsetUnsupported() {
|
||||
expectThrows(nonEmptyProperSubset);
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
// retainAll(sameElements)
|
||||
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
public void testRetainAll_sameElements() {
|
||||
expectReturnsFalse(sameElements);
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
public void testRetainAllExtra_sameElements() {
|
||||
expectReturnsFalseExtra(sameElements);
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(absent = SUPPORTS_REMOVE)
|
||||
public void testRetainAll_sameElementsUnsupported() {
|
||||
expectReturnsFalseOrThrows(sameElements);
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
// retainAll(partialOverlap)
|
||||
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(absent = { ZERO, ONE })
|
||||
public void testRetainAll_partialOverlap() {
|
||||
expectReturnsTrue(partialOverlap);
|
||||
expectContents(e2());
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(absent = { ZERO, ONE })
|
||||
public void testRetainAllExtra_partialOverlap() {
|
||||
expectReturnsTrueExtra(partialOverlap);
|
||||
expectContents(e2());
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(absent = SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(absent = { ZERO, ONE })
|
||||
public void testRetainAll_partialOverlapUnsupported() {
|
||||
expectThrows(partialOverlap);
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
// retainAll(containsDuplicates)
|
||||
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(ONE)
|
||||
public void testRetainAll_containsDuplicatesSizeOne() {
|
||||
expectReturnsFalse(containsDuplicates);
|
||||
expectContents(e0());
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(ONE)
|
||||
public void testRetainAllExtra_containsDuplicatesSizeOne() {
|
||||
expectReturnsFalseExtra(containsDuplicates);
|
||||
expectContents(e0());
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(absent = { ZERO, ONE })
|
||||
public void testRetainAll_containsDuplicatesSizeSeveral() {
|
||||
expectReturnsTrue(containsDuplicates);
|
||||
expectContents(e0());
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(absent = { ZERO, ONE })
|
||||
public void testRetainAllExtra_containsDuplicatesSizeSeveral() {
|
||||
expectReturnsTrueExtra(containsDuplicates);
|
||||
expectContents(e0());
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(ZERO)
|
||||
public void testRetainAll_nullCollectionReferenceEmptySubject() {
|
||||
try {
|
||||
collection.retainAll(null);
|
||||
// Returning successfully is not ideal, but tolerated.
|
||||
} catch (NullPointerException tolerated) {
|
||||
}
|
||||
}
|
||||
|
||||
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
public void testRetainAll_nullCollectionReferenceNonEmptySubject() {
|
||||
try {
|
||||
collection.retainAll(null);
|
||||
fail("retainAll(null) should throw NullPointerException");
|
||||
} catch (NullPointerException expected) {
|
||||
}
|
||||
}
|
||||
|
||||
#endignore
|
||||
private void expectReturnsTrue(Target target) {
|
||||
String message = String.format("retainAll(%s) should return true", target);
|
||||
assertTrue(message, collection.retainAll(target.toRetain));
|
||||
}
|
||||
|
||||
private void expectReturnsTrueExtra(Target target) {
|
||||
String message = String.format("retainAll(%s, Removed) should return true", target);
|
||||
LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES();
|
||||
assertTrue(message, collection.retainAll(target.toRetain, list::add));
|
||||
HELPERS.assertEqualIgnoringOrder(target.inverse, list);
|
||||
}
|
||||
|
||||
private void expectReturnsFalse(Target target) {
|
||||
String message = String.format("retainAll(%s) should return false", target);
|
||||
assertFalse(message, collection.retainAll(target.toRetain));
|
||||
}
|
||||
|
||||
private void expectReturnsFalseExtra(Target target) {
|
||||
String message = String.format("retainAll(%s, Removed) should return false", target);
|
||||
assertFalse(message, collection.retainAll(target.toRetain, T -> {}));
|
||||
}
|
||||
|
||||
private void expectThrows(Target target) {
|
||||
try {
|
||||
collection.retainAll(target.toRetain);
|
||||
fail(String.format("retainAll(%s) should throw", target));
|
||||
} catch (UnsupportedOperationException expected) {
|
||||
}
|
||||
}
|
||||
|
||||
private void expectReturnsFalseOrThrows(Target target) {
|
||||
String message = String.format("retainAll(%s) should return false or throw", target);
|
||||
try {
|
||||
assertFalse(message, collection.retainAll(target.toRetain));
|
||||
} catch (UnsupportedOperationException tolerated) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,59 +1,59 @@
|
|||
package speiger.src.testers.PACKAGE.tests.collection;
|
||||
|
||||
#ignore
|
||||
import static com.google.common.collect.testing.features.CollectionFeature.KNOWN_ORDER;
|
||||
#endignore
|
||||
|
||||
import com.google.common.collect.testing.features.CollectionFeature;
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
||||
#if !JDK_TYPE
|
||||
import speiger.src.collections.utils.SanityChecks;
|
||||
#endif
|
||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
||||
import speiger.src.testers.PACKAGE.utils.HELPERS;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPECollectionStreamTester KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
#ignore
|
||||
@CollectionFeature.Require(absent = KNOWN_ORDER)
|
||||
public void testStreamToArrayUnknownOrder() {
|
||||
#endignore
|
||||
synchronized (collection) {
|
||||
HELPERS.assertContentsAnyOrder(getSampleElements(), unwrap(collection.primitiveStream().toArray()));
|
||||
}
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(KNOWN_ORDER)
|
||||
public void testStreamToArrayKnownOrder() {
|
||||
#endignore
|
||||
synchronized (collection) {
|
||||
assertEquals(getOrderedElements(), ARRAY_LIST.wrap(unwrap(collection.primitiveStream().toArray())));
|
||||
}
|
||||
}
|
||||
|
||||
public void testStreamCount() {
|
||||
synchronized (collection) {
|
||||
assertEquals(getNumElements(), collection.primitiveStream().count());
|
||||
}
|
||||
}
|
||||
|
||||
#if JDK_TYPE
|
||||
public KEY_TYPE[] unwrap(KEY_TYPE[] input) {
|
||||
return input;
|
||||
}
|
||||
#else
|
||||
public KEY_TYPE[] unwrap(KEY_JAVA_TYPE[] input) {
|
||||
KEY_TYPE[] other = NEW_KEY_ARRAY(input.length);
|
||||
for(int i = 0,m=input.length;i<m;i++) {
|
||||
other[i] = SanityChecks.SANITY_CAST(input[i]);
|
||||
}
|
||||
return other;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
package speiger.src.testers.PACKAGE.tests.collection;
|
||||
|
||||
#ignore
|
||||
import static com.google.common.collect.testing.features.CollectionFeature.KNOWN_ORDER;
|
||||
#endignore
|
||||
|
||||
import com.google.common.collect.testing.features.CollectionFeature;
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
||||
#if !JDK_TYPE
|
||||
import speiger.src.collections.utils.SanityChecks;
|
||||
#endif
|
||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
||||
import speiger.src.testers.PACKAGE.utils.HELPERS;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPECollectionStreamTester KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
#ignore
|
||||
@CollectionFeature.Require(absent = KNOWN_ORDER)
|
||||
public void testStreamToArrayUnknownOrder() {
|
||||
#endignore
|
||||
synchronized (collection) {
|
||||
HELPERS.assertContentsAnyOrder(getSampleElements(), unwrap(collection.primitiveStream().toArray()));
|
||||
}
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(KNOWN_ORDER)
|
||||
public void testStreamToArrayKnownOrder() {
|
||||
#endignore
|
||||
synchronized (collection) {
|
||||
assertEquals(getOrderedElements(), ARRAY_LIST.wrap(unwrap(collection.primitiveStream().toArray())));
|
||||
}
|
||||
}
|
||||
|
||||
public void testStreamCount() {
|
||||
synchronized (collection) {
|
||||
assertEquals(getNumElements(), collection.primitiveStream().count());
|
||||
}
|
||||
}
|
||||
|
||||
#if JDK_TYPE
|
||||
public KEY_TYPE[] unwrap(KEY_TYPE[] input) {
|
||||
return input;
|
||||
}
|
||||
#else
|
||||
public KEY_TYPE[] unwrap(KEY_JAVA_TYPE[] input) {
|
||||
KEY_TYPE[] other = NEW_KEY_ARRAY(input.length);
|
||||
for(int i = 0,m=input.length;i<m;i++) {
|
||||
other[i] = SanityChecks.SANITY_CAST(input[i]);
|
||||
}
|
||||
return other;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -1,116 +1,116 @@
|
|||
package speiger.src.testers.PACKAGE.tests.collection;
|
||||
|
||||
#ignore
|
||||
import static com.google.common.collect.testing.features.CollectionFeature.KNOWN_ORDER;
|
||||
#endignore
|
||||
|
||||
import com.google.common.collect.testing.features.CollectionFeature;
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
||||
import speiger.src.testers.PACKAGE.utils.HELPERS;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPECollectionToArrayTester KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
public void testToArray_noArgs() {
|
||||
KEY_OBJECT_TYPE[] array = collection.TO_ARRAY();
|
||||
expectArrayContentsAnyOrder(createSamplesArray(), array);
|
||||
}
|
||||
|
||||
public void testToArray_emptyArray() {
|
||||
KEY_TYPE[] empty = emptyArray();
|
||||
KEY_TYPE[] array = collection.TO_ARRAY(empty);
|
||||
assertEquals("toLongArray(emptyT[]).length:", getNumElements(), array.length);
|
||||
expectArrayContentsAnyOrder(createSamplesArray(), array);
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(KNOWN_ORDER)
|
||||
public void testToArray_emptyArray_ordered() {
|
||||
#endignore
|
||||
KEY_TYPE[] empty = emptyArray();
|
||||
KEY_TYPE[] array = collection.TO_ARRAY(empty);
|
||||
assertEquals("toLongArray(emptyT[]).length:", getNumElements(), array.length);
|
||||
expectArrayContentsInOrder(getOrderedElements(), array);
|
||||
}
|
||||
|
||||
public void testToArray_emptyArrayOfObject() {
|
||||
KEY_TYPE[] in = emptyArray();
|
||||
KEY_TYPE[] array = collection.TO_ARRAY(in);
|
||||
assertEquals("toLongArray(emptyObject[]).length", getNumElements(), array.length);
|
||||
expectArrayContentsAnyOrder(createSamplesArray(), array);
|
||||
}
|
||||
|
||||
public void testToArray_rightSizedArray() {
|
||||
KEY_TYPE[] array = NEW_KEY_ARRAY(getNumElements());
|
||||
assertSame("toLongArray(sameSizeE[]) should return the given array", array, collection.TO_ARRAY(array));
|
||||
expectArrayContentsAnyOrder(createSamplesArray(), array);
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(KNOWN_ORDER)
|
||||
public void testToArray_rightSizedArray_ordered() {
|
||||
#endignore
|
||||
KEY_TYPE[] array = NEW_KEY_ARRAY(getNumElements());
|
||||
assertSame("toLongArray(sameSizeE[]) should return the given array", array, collection.TO_ARRAY(array));
|
||||
expectArrayContentsInOrder(getOrderedElements(), array);
|
||||
}
|
||||
|
||||
public void testToArray_rightSizedArrayOfObject() {
|
||||
KEY_TYPE[] array = NEW_KEY_ARRAY(getNumElements());
|
||||
assertSame("toLongArray(sameSizeObject[]) should return the given array", array, collection.TO_ARRAY(array));
|
||||
expectArrayContentsAnyOrder(createSamplesArray(), array);
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(KNOWN_ORDER)
|
||||
public void testToArray_rightSizedArrayOfObject_ordered() {
|
||||
#endignore
|
||||
KEY_TYPE[] array = NEW_KEY_ARRAY(getNumElements());
|
||||
assertSame("toLongArray(sameSizeObject[]) should return the given array", array, collection.TO_ARRAY(array));
|
||||
expectArrayContentsInOrder(getOrderedElements(), array);
|
||||
}
|
||||
|
||||
public void testToArray_oversizedArray() {
|
||||
KEY_TYPE[] array = NEW_KEY_ARRAY(getNumElements() + 2);
|
||||
array[getNumElements()] = e3();
|
||||
array[getNumElements() + 1] = e3();
|
||||
assertSame("toLongArray(overSizedE[]) should return the given array", array, collection.TO_ARRAY(array));
|
||||
|
||||
LIST KEY_GENERIC_TYPE subArray = ARRAY_LIST.wrap(array).subList(0, getNumElements());
|
||||
KEY_TYPE[] expectedSubArray = createSamplesArray();
|
||||
for (int i = 0; i < getNumElements(); i++) {
|
||||
assertTrue("toLongArray(overSizedE[]) should contain element " + expectedSubArray[i], subArray.contains(expectedSubArray[i]));
|
||||
}
|
||||
assertEquals("The array element immediately following the end of the collection should be nulled", EMPTY_KEY_VALUE, array[getNumElements()]);
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(KNOWN_ORDER)
|
||||
public void testToArray_oversizedArray_ordered() {
|
||||
#endignore
|
||||
KEY_TYPE[] array = NEW_KEY_ARRAY(getNumElements() + 2);
|
||||
array[getNumElements()] = e3();
|
||||
array[getNumElements() + 1] = e3();
|
||||
assertSame("toLongArray(overSizedE[]) should return the given array", array, collection.TO_ARRAY(array));
|
||||
|
||||
LIST KEY_GENERIC_TYPE expected = getOrderedElements();
|
||||
for (int i = 0; i < getNumElements(); i++) {
|
||||
assertEquals(expected.GET_KEY(i), array[i]);
|
||||
}
|
||||
assertEquals("The array element immediately following the end of the collection should be nulled", EMPTY_KEY_VALUE, array[getNumElements()]);
|
||||
}
|
||||
|
||||
private void expectArrayContentsAnyOrder(KEY_OBJECT_TYPE[] expected, KEY_OBJECT_TYPE[] actual) {
|
||||
HELPERS.assertEqualIgnoringOrder(ARRAY_LIST.wrap(expected), ARRAY_LIST.wrap(actual));
|
||||
}
|
||||
|
||||
private void expectArrayContentsInOrder(LIST KEY_GENERIC_TYPE expected, KEY_TYPE[] actual) {
|
||||
assertEquals("TO_ARRAY() ordered contents: ", expected, ARRAY_LIST.wrap(actual));
|
||||
}
|
||||
}
|
||||
package speiger.src.testers.PACKAGE.tests.collection;
|
||||
|
||||
#ignore
|
||||
import static com.google.common.collect.testing.features.CollectionFeature.KNOWN_ORDER;
|
||||
#endignore
|
||||
|
||||
import com.google.common.collect.testing.features.CollectionFeature;
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
||||
import speiger.src.testers.PACKAGE.utils.HELPERS;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPECollectionToArrayTester KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
public void testToArray_noArgs() {
|
||||
KEY_OBJECT_TYPE[] array = collection.TO_ARRAY();
|
||||
expectArrayContentsAnyOrder(createSamplesArray(), array);
|
||||
}
|
||||
|
||||
public void testToArray_emptyArray() {
|
||||
KEY_TYPE[] empty = emptyArray();
|
||||
KEY_TYPE[] array = collection.TO_ARRAY(empty);
|
||||
assertEquals("toLongArray(emptyT[]).length:", getNumElements(), array.length);
|
||||
expectArrayContentsAnyOrder(createSamplesArray(), array);
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(KNOWN_ORDER)
|
||||
public void testToArray_emptyArray_ordered() {
|
||||
#endignore
|
||||
KEY_TYPE[] empty = emptyArray();
|
||||
KEY_TYPE[] array = collection.TO_ARRAY(empty);
|
||||
assertEquals("toLongArray(emptyT[]).length:", getNumElements(), array.length);
|
||||
expectArrayContentsInOrder(getOrderedElements(), array);
|
||||
}
|
||||
|
||||
public void testToArray_emptyArrayOfObject() {
|
||||
KEY_TYPE[] in = emptyArray();
|
||||
KEY_TYPE[] array = collection.TO_ARRAY(in);
|
||||
assertEquals("toLongArray(emptyObject[]).length", getNumElements(), array.length);
|
||||
expectArrayContentsAnyOrder(createSamplesArray(), array);
|
||||
}
|
||||
|
||||
public void testToArray_rightSizedArray() {
|
||||
KEY_TYPE[] array = NEW_KEY_ARRAY(getNumElements());
|
||||
assertSame("toLongArray(sameSizeE[]) should return the given array", array, collection.TO_ARRAY(array));
|
||||
expectArrayContentsAnyOrder(createSamplesArray(), array);
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(KNOWN_ORDER)
|
||||
public void testToArray_rightSizedArray_ordered() {
|
||||
#endignore
|
||||
KEY_TYPE[] array = NEW_KEY_ARRAY(getNumElements());
|
||||
assertSame("toLongArray(sameSizeE[]) should return the given array", array, collection.TO_ARRAY(array));
|
||||
expectArrayContentsInOrder(getOrderedElements(), array);
|
||||
}
|
||||
|
||||
public void testToArray_rightSizedArrayOfObject() {
|
||||
KEY_TYPE[] array = NEW_KEY_ARRAY(getNumElements());
|
||||
assertSame("toLongArray(sameSizeObject[]) should return the given array", array, collection.TO_ARRAY(array));
|
||||
expectArrayContentsAnyOrder(createSamplesArray(), array);
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(KNOWN_ORDER)
|
||||
public void testToArray_rightSizedArrayOfObject_ordered() {
|
||||
#endignore
|
||||
KEY_TYPE[] array = NEW_KEY_ARRAY(getNumElements());
|
||||
assertSame("toLongArray(sameSizeObject[]) should return the given array", array, collection.TO_ARRAY(array));
|
||||
expectArrayContentsInOrder(getOrderedElements(), array);
|
||||
}
|
||||
|
||||
public void testToArray_oversizedArray() {
|
||||
KEY_TYPE[] array = NEW_KEY_ARRAY(getNumElements() + 2);
|
||||
array[getNumElements()] = e3();
|
||||
array[getNumElements() + 1] = e3();
|
||||
assertSame("toLongArray(overSizedE[]) should return the given array", array, collection.TO_ARRAY(array));
|
||||
|
||||
LIST KEY_GENERIC_TYPE subArray = ARRAY_LIST.wrap(array).subList(0, getNumElements());
|
||||
KEY_TYPE[] expectedSubArray = createSamplesArray();
|
||||
for (int i = 0; i < getNumElements(); i++) {
|
||||
assertTrue("toLongArray(overSizedE[]) should contain element " + expectedSubArray[i], subArray.contains(expectedSubArray[i]));
|
||||
}
|
||||
assertEquals("The array element immediately following the end of the collection should be nulled", EMPTY_KEY_VALUE, array[getNumElements()]);
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(KNOWN_ORDER)
|
||||
public void testToArray_oversizedArray_ordered() {
|
||||
#endignore
|
||||
KEY_TYPE[] array = NEW_KEY_ARRAY(getNumElements() + 2);
|
||||
array[getNumElements()] = e3();
|
||||
array[getNumElements() + 1] = e3();
|
||||
assertSame("toLongArray(overSizedE[]) should return the given array", array, collection.TO_ARRAY(array));
|
||||
|
||||
LIST KEY_GENERIC_TYPE expected = getOrderedElements();
|
||||
for (int i = 0; i < getNumElements(); i++) {
|
||||
assertEquals(expected.GET_KEY(i), array[i]);
|
||||
}
|
||||
assertEquals("The array element immediately following the end of the collection should be nulled", EMPTY_KEY_VALUE, array[getNumElements()]);
|
||||
}
|
||||
|
||||
private void expectArrayContentsAnyOrder(KEY_OBJECT_TYPE[] expected, KEY_OBJECT_TYPE[] actual) {
|
||||
HELPERS.assertEqualIgnoringOrder(ARRAY_LIST.wrap(expected), ARRAY_LIST.wrap(actual));
|
||||
}
|
||||
|
||||
private void expectArrayContentsInOrder(LIST KEY_GENERIC_TYPE expected, KEY_TYPE[] actual) {
|
||||
assertEquals("TO_ARRAY() ordered contents: ", expected, ARRAY_LIST.wrap(actual));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,47 +1,47 @@
|
|||
package speiger.src.testers.PACKAGE.tests.iterable;
|
||||
|
||||
#if TYPE_OBJECT
|
||||
import java.util.Objects;
|
||||
|
||||
#endif
|
||||
import org.junit.Ignore;
|
||||
|
||||
import com.google.common.collect.testing.features.CollectionSize;
|
||||
|
||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPEIterableCountTester KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
public void testIterableCount_null() {
|
||||
try {
|
||||
collection.count(null);
|
||||
fail("This should throw a NullPointerException");
|
||||
} catch (NullPointerException e) {
|
||||
}
|
||||
}
|
||||
|
||||
public void testIterableCount_NoneFound() {
|
||||
assertEquals("Expected none to be found", 0, collection.count(T -> false));
|
||||
}
|
||||
|
||||
public void testIterableCount_AllFound() {
|
||||
assertEquals("Expected All to be found", getNumElements(), collection.count(T -> true));
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionSize.Require(absent = CollectionSize.ZERO)
|
||||
#endignore
|
||||
public void testIterableCount_FindFirst()
|
||||
{
|
||||
assertEquals("First element should be found", 1, collection.count(T -> KEY_EQUALS(T, e0())));
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionSize.Require(CollectionSize.SEVERAL)
|
||||
#endignore
|
||||
public void testIterableCount_FindLast() {
|
||||
assertEquals("Last element should be found", 1, collection.count(T -> KEY_EQUALS(T, e2())));
|
||||
}
|
||||
package speiger.src.testers.PACKAGE.tests.iterable;
|
||||
|
||||
#if TYPE_OBJECT
|
||||
import java.util.Objects;
|
||||
|
||||
#endif
|
||||
import org.junit.Ignore;
|
||||
|
||||
import com.google.common.collect.testing.features.CollectionSize;
|
||||
|
||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPEIterableCountTester KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
public void testIterableCount_null() {
|
||||
try {
|
||||
collection.count(null);
|
||||
fail("This should throw a NullPointerException");
|
||||
} catch (NullPointerException e) {
|
||||
}
|
||||
}
|
||||
|
||||
public void testIterableCount_NoneFound() {
|
||||
assertEquals("Expected none to be found", 0, collection.count(T -> false));
|
||||
}
|
||||
|
||||
public void testIterableCount_AllFound() {
|
||||
assertEquals("Expected All to be found", getNumElements(), collection.count(T -> true));
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionSize.Require(absent = CollectionSize.ZERO)
|
||||
#endignore
|
||||
public void testIterableCount_FindFirst()
|
||||
{
|
||||
assertEquals("First element should be found", 1, collection.count(T -> KEY_EQUALS(T, e0())));
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionSize.Require(CollectionSize.SEVERAL)
|
||||
#endignore
|
||||
public void testIterableCount_FindLast() {
|
||||
assertEquals("Last element should be found", 1, collection.count(T -> KEY_EQUALS(T, e2())));
|
||||
}
|
||||
}
|
|
@ -1,24 +1,24 @@
|
|||
package speiger.src.testers.PACKAGE.tests.iterable;
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
import com.google.common.collect.testing.features.CollectionSize;
|
||||
|
||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPEIterableDistinctTester KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
#ignore
|
||||
@CollectionSize.Require(CollectionSize.SEVERAL)
|
||||
#endignore
|
||||
public void testDistinct()
|
||||
{
|
||||
ArrayWithDuplicate KEY_GENERIC_TYPE duplicate = createArrayWithDuplicateElement();
|
||||
resetContainer(primitiveGenerator.create(duplicate.elements));
|
||||
LIST KEY_GENERIC_TYPE list = collection.distinct().pourAsList();
|
||||
assertEquals("Distinct should remove duplicate elements", list.indexOf(duplicate.duplicate), list.lastIndexOf(duplicate.duplicate));
|
||||
}
|
||||
}
|
||||
package speiger.src.testers.PACKAGE.tests.iterable;
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
import com.google.common.collect.testing.features.CollectionSize;
|
||||
|
||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPEIterableDistinctTester KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
#ignore
|
||||
@CollectionSize.Require(CollectionSize.SEVERAL)
|
||||
#endignore
|
||||
public void testDistinct()
|
||||
{
|
||||
ArrayWithDuplicate KEY_GENERIC_TYPE duplicate = createArrayWithDuplicateElement();
|
||||
resetContainer(primitiveGenerator.create(duplicate.elements));
|
||||
LIST KEY_GENERIC_TYPE list = collection.distinct().pourAsList();
|
||||
assertEquals("Distinct should remove duplicate elements", list.indexOf(duplicate.duplicate), list.lastIndexOf(duplicate.duplicate));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,52 +1,52 @@
|
|||
package speiger.src.testers.PACKAGE.tests.iterable;
|
||||
|
||||
#if TYPE_OBJECT
|
||||
import java.util.Objects;
|
||||
|
||||
#endif
|
||||
import org.junit.Ignore;
|
||||
|
||||
import com.google.common.collect.testing.features.CollectionSize;
|
||||
|
||||
import speiger.src.collections.PACKAGE.sets.SET;
|
||||
import speiger.src.collections.PACKAGE.utils.SETS;
|
||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPEIterableFilterTester KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
public void testIterableFilter_missingElement() {
|
||||
assertTrue(expectMissing(collection.filter(T -> KEY_EQUALS_NOT(T, e0())).pourAsSet(), e0()));
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionSize.Require(absent = CollectionSize.ZERO)
|
||||
#endignore
|
||||
public void testIterableFilter_filterElement() {
|
||||
assertFalse(expectMissing(SETS.singleton(e0()), collection.filter(T -> KEY_EQUALS(T, e0())).pourAsSet().TO_ARRAY()));
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionSize.Require(CollectionSize.ONE)
|
||||
#endignore
|
||||
public void testIterableFilter_filterMissing() {
|
||||
assertTrue(collection.filter(T -> KEY_EQUALS(T, e1())).pourAsList().isEmpty());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionSize.Require(CollectionSize.SEVERAL)
|
||||
#endignore
|
||||
public void testIterableFilter_filterSeveral() {
|
||||
assertTrue(expectMissing(SETS.singleton(e1()), collection.filter(T -> KEY_EQUALS_NOT(T, e1())).pourAsSet().TO_ARRAY()));
|
||||
}
|
||||
|
||||
protected boolean expectMissing(SET KEY_GENERIC_TYPE set, KEY_OBJECT_TYPE...elements)
|
||||
{
|
||||
for(KEY_OBJECT_TYPE element : elements)
|
||||
{
|
||||
if(set.contains(element)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
package speiger.src.testers.PACKAGE.tests.iterable;
|
||||
|
||||
#if TYPE_OBJECT
|
||||
import java.util.Objects;
|
||||
|
||||
#endif
|
||||
import org.junit.Ignore;
|
||||
|
||||
import com.google.common.collect.testing.features.CollectionSize;
|
||||
|
||||
import speiger.src.collections.PACKAGE.sets.SET;
|
||||
import speiger.src.collections.PACKAGE.utils.SETS;
|
||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPEIterableFilterTester KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
public void testIterableFilter_missingElement() {
|
||||
assertTrue(expectMissing(collection.filter(T -> KEY_EQUALS_NOT(T, e0())).pourAsSet(), e0()));
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionSize.Require(absent = CollectionSize.ZERO)
|
||||
#endignore
|
||||
public void testIterableFilter_filterElement() {
|
||||
assertFalse(expectMissing(SETS.singleton(e0()), collection.filter(T -> KEY_EQUALS(T, e0())).pourAsSet().TO_ARRAY()));
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionSize.Require(CollectionSize.ONE)
|
||||
#endignore
|
||||
public void testIterableFilter_filterMissing() {
|
||||
assertTrue(collection.filter(T -> KEY_EQUALS(T, e1())).pourAsList().isEmpty());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionSize.Require(CollectionSize.SEVERAL)
|
||||
#endignore
|
||||
public void testIterableFilter_filterSeveral() {
|
||||
assertTrue(expectMissing(SETS.singleton(e1()), collection.filter(T -> KEY_EQUALS_NOT(T, e1())).pourAsSet().TO_ARRAY()));
|
||||
}
|
||||
|
||||
protected boolean expectMissing(SET KEY_GENERIC_TYPE set, KEY_OBJECT_TYPE...elements)
|
||||
{
|
||||
for(KEY_OBJECT_TYPE element : elements)
|
||||
{
|
||||
if(set.contains(element)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,43 +1,43 @@
|
|||
package speiger.src.testers.PACKAGE.tests.iterable;
|
||||
|
||||
#if TYPE_OBJECT
|
||||
import java.util.Objects;
|
||||
|
||||
#endif
|
||||
import org.junit.Ignore;
|
||||
|
||||
import com.google.common.collect.testing.features.CollectionSize;
|
||||
|
||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPEIterableFindFirstTester KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
public void testIterableFindFirst_null() {
|
||||
try {
|
||||
container.findFirst(null);
|
||||
fail("This should throw a NullPointerException");
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
}
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionSize.Require(absent = CollectionSize.ZERO)
|
||||
#endignore
|
||||
public void testIterableFindFirst_FindFirstElements() {
|
||||
assertEquals("First Element should be found", e0(), container.findFirst(T -> KEY_EQUALS(T, e0())));
|
||||
}
|
||||
|
||||
public void testIterableFindFirst_FindNothing() {
|
||||
assertEquals("No element should be found", EMPTY_KEY_VALUE, container.findFirst(T -> KEY_EQUALS(T, e4())));
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionSize.Require(CollectionSize.SEVERAL)
|
||||
#endignore
|
||||
public void testIterableFindFirst_FindLastElement() {
|
||||
assertEquals("Last Element should be found", e2(), container.findFirst(T -> KEY_EQUALS(T, e2())));
|
||||
}
|
||||
}
|
||||
package speiger.src.testers.PACKAGE.tests.iterable;
|
||||
|
||||
#if TYPE_OBJECT
|
||||
import java.util.Objects;
|
||||
|
||||
#endif
|
||||
import org.junit.Ignore;
|
||||
|
||||
import com.google.common.collect.testing.features.CollectionSize;
|
||||
|
||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPEIterableFindFirstTester KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
public void testIterableFindFirst_null() {
|
||||
try {
|
||||
container.findFirst(null);
|
||||
fail("This should throw a NullPointerException");
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
}
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionSize.Require(absent = CollectionSize.ZERO)
|
||||
#endignore
|
||||
public void testIterableFindFirst_FindFirstElements() {
|
||||
assertEquals("First Element should be found", e0(), container.findFirst(T -> KEY_EQUALS(T, e0())));
|
||||
}
|
||||
|
||||
public void testIterableFindFirst_FindNothing() {
|
||||
assertEquals("No element should be found", EMPTY_KEY_VALUE, container.findFirst(T -> KEY_EQUALS(T, e4())));
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionSize.Require(CollectionSize.SEVERAL)
|
||||
#endignore
|
||||
public void testIterableFindFirst_FindLastElement() {
|
||||
assertEquals("Last Element should be found", e2(), container.findFirst(T -> KEY_EQUALS(T, e2())));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,25 +1,25 @@
|
|||
package speiger.src.testers.PACKAGE.tests.iterable;
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
import com.google.common.collect.testing.features.CollectionSize;
|
||||
|
||||
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPEIterableLimitTester KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
#ignore
|
||||
@CollectionSize.Require(absent = CollectionSize.ZERO)
|
||||
#endignore
|
||||
public void testIterableLimit() {
|
||||
LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES(collection);
|
||||
list.REMOVE(list.size()-1);
|
||||
LIST KEY_GENERIC_TYPE result = collection.limit(getNumElements()-1).pourAsList();
|
||||
assertEquals(list.size(), result.size());
|
||||
assertEquals("Limit does not retain the iteration order", list, result);
|
||||
}
|
||||
}
|
||||
package speiger.src.testers.PACKAGE.tests.iterable;
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
import com.google.common.collect.testing.features.CollectionSize;
|
||||
|
||||
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPEIterableLimitTester KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
#ignore
|
||||
@CollectionSize.Require(absent = CollectionSize.ZERO)
|
||||
#endignore
|
||||
public void testIterableLimit() {
|
||||
LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES(collection);
|
||||
list.REMOVE(list.size()-1);
|
||||
LIST KEY_GENERIC_TYPE result = collection.limit(getNumElements()-1).pourAsList();
|
||||
assertEquals(list.size(), result.size());
|
||||
assertEquals("Limit does not retain the iteration order", list, result);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,132 +1,132 @@
|
|||
package speiger.src.testers.PACKAGE.tests.iterable;
|
||||
|
||||
#if TYPE_OBJECT
|
||||
import java.util.Objects;
|
||||
#endif
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
import com.google.common.collect.testing.features.CollectionFeature;
|
||||
|
||||
#if TYPE_OBJECT
|
||||
import speiger.src.collections.chars.utils.CharArrays;
|
||||
#endif
|
||||
import speiger.src.collections.objects.lists.ObjectArrayList;
|
||||
import speiger.src.collections.objects.lists.ObjectList;
|
||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
||||
import speiger.src.testers.PACKAGE.utils.HELPERS;
|
||||
#if !TYPE_OBJECT
|
||||
import speiger.src.testers.objects.utils.ObjectHelpers;
|
||||
#endif
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPEIterableMapTester KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
public void testIterableMap_ToString() {
|
||||
assertEquals(HELPERS.copyToList(collection).toString(), collection.map(CLASS_OBJECT_TYPE::toString).pourAsList().toString());
|
||||
}
|
||||
#if !TYPE_OBJECT
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(CollectionFeature.KNOWN_ORDER)
|
||||
#endignore
|
||||
public void testIterableMap_Collection() {
|
||||
ObjectList<Integer> result = new ObjectArrayList<>();
|
||||
for(KEY_TYPE entry : getOrderedElements()) {
|
||||
result.addAll(toRange((int)entry));
|
||||
}
|
||||
assertEquals(result, collection.flatMap(T -> ObjectArrayList.wrap(toRange((int)T))).pourAsList());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(CollectionFeature.KNOWN_ORDER)
|
||||
#endignore
|
||||
public void testIterableMap_Array() {
|
||||
ObjectList<Integer> result = new ObjectArrayList<>();
|
||||
for(KEY_TYPE entry : getOrderedElements()) {
|
||||
result.addAll(toRange((int)entry));
|
||||
}
|
||||
assertEquals(result, collection.arrayflatMap(T -> toRange((int)T)).pourAsList());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(absent = CollectionFeature.KNOWN_ORDER)
|
||||
#endignore
|
||||
public void testIterableMap_CollectionUnordered() {
|
||||
ObjectList<Integer> result = new ObjectArrayList<>();
|
||||
for(KEY_TYPE entry : getOrderedElements()) {
|
||||
result.addAll(toRange((int)entry));
|
||||
}
|
||||
ObjectHelpers.assertEqualIgnoringOrder(result, collection.flatMap(T -> ObjectArrayList.wrap(toRange((int)T))).pourAsList());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(absent = CollectionFeature.KNOWN_ORDER)
|
||||
#endignore
|
||||
public void testIterableMap_ArrayUnordered() {
|
||||
ObjectList<Integer> result = new ObjectArrayList<>();
|
||||
for(KEY_TYPE entry : getOrderedElements()) {
|
||||
result.addAll(toRange((int)entry));
|
||||
}
|
||||
ObjectHelpers.assertEqualIgnoringOrder(result, collection.arrayflatMap(T -> toRange((int)T)).pourAsList());
|
||||
}
|
||||
|
||||
private Integer[] toRange(int range) {
|
||||
Integer[] result = new Integer[range];
|
||||
for(int i = 0;i<range;i++) {
|
||||
result[i] = Integer.valueOf(i);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
#else
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(CollectionFeature.KNOWN_ORDER)
|
||||
#endignore
|
||||
public void testIterableMap_Collection() {
|
||||
ObjectList<Character> result = new ObjectArrayList<>();
|
||||
for(KEY_TYPE entry : getOrderedElements()) {
|
||||
result.addAll(toRange(entry));
|
||||
}
|
||||
assertEquals(result, collection.flatMap(T -> ObjectArrayList.wrap(toRange(T))).pourAsList());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(CollectionFeature.KNOWN_ORDER)
|
||||
#endignore
|
||||
public void testIterableMap_Array() {
|
||||
ObjectList<Character> result = new ObjectArrayList<>();
|
||||
for(KEY_TYPE entry : getOrderedElements()) {
|
||||
result.addAll(toRange(entry));
|
||||
}
|
||||
assertEquals(result, collection.arrayflatMap(this::toRange).pourAsList());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(absent = CollectionFeature.KNOWN_ORDER)
|
||||
#endignore
|
||||
public void testIterableMap_CollectionUnordered() {
|
||||
ObjectList<Character> result = new ObjectArrayList<>();
|
||||
for(KEY_TYPE entry : getOrderedElements()) {
|
||||
result.addAll(toRange(entry));
|
||||
}
|
||||
ObjectHelpers.assertEqualIgnoringOrder(result, collection.flatMap(T -> ObjectArrayList.wrap(toRange(T))).pourAsList());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(absent = CollectionFeature.KNOWN_ORDER)
|
||||
#endignore
|
||||
public void testIterableMap_ArrayUnordered() {
|
||||
ObjectList<Character> result = new ObjectArrayList<>();
|
||||
for(KEY_TYPE entry : getOrderedElements()) {
|
||||
result.addAll(toRange(entry));
|
||||
}
|
||||
ObjectHelpers.assertEqualIgnoringOrder(result, collection.arrayflatMap(this::toRange).pourAsList());
|
||||
}
|
||||
|
||||
private Character[] toRange(T obj) {
|
||||
return CharArrays.wrap(Objects.toString(obj).toCharArray());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
package speiger.src.testers.PACKAGE.tests.iterable;
|
||||
|
||||
#if TYPE_OBJECT
|
||||
import java.util.Objects;
|
||||
#endif
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
import com.google.common.collect.testing.features.CollectionFeature;
|
||||
|
||||
#if TYPE_OBJECT
|
||||
import speiger.src.collections.chars.utils.CharArrays;
|
||||
#endif
|
||||
import speiger.src.collections.objects.lists.ObjectArrayList;
|
||||
import speiger.src.collections.objects.lists.ObjectList;
|
||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
||||
import speiger.src.testers.PACKAGE.utils.HELPERS;
|
||||
#if !TYPE_OBJECT
|
||||
import speiger.src.testers.objects.utils.ObjectHelpers;
|
||||
#endif
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPEIterableMapTester KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
public void testIterableMap_ToString() {
|
||||
assertEquals(HELPERS.copyToList(collection).toString(), collection.map(CLASS_OBJECT_TYPE::toString).pourAsList().toString());
|
||||
}
|
||||
#if !TYPE_OBJECT
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(CollectionFeature.KNOWN_ORDER)
|
||||
#endignore
|
||||
public void testIterableMap_Collection() {
|
||||
ObjectList<Integer> result = new ObjectArrayList<>();
|
||||
for(KEY_TYPE entry : getOrderedElements()) {
|
||||
result.addAll(toRange((int)entry));
|
||||
}
|
||||
assertEquals(result, collection.flatMap(T -> ObjectArrayList.wrap(toRange((int)T))).pourAsList());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(CollectionFeature.KNOWN_ORDER)
|
||||
#endignore
|
||||
public void testIterableMap_Array() {
|
||||
ObjectList<Integer> result = new ObjectArrayList<>();
|
||||
for(KEY_TYPE entry : getOrderedElements()) {
|
||||
result.addAll(toRange((int)entry));
|
||||
}
|
||||
assertEquals(result, collection.arrayflatMap(T -> toRange((int)T)).pourAsList());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(absent = CollectionFeature.KNOWN_ORDER)
|
||||
#endignore
|
||||
public void testIterableMap_CollectionUnordered() {
|
||||
ObjectList<Integer> result = new ObjectArrayList<>();
|
||||
for(KEY_TYPE entry : getOrderedElements()) {
|
||||
result.addAll(toRange((int)entry));
|
||||
}
|
||||
ObjectHelpers.assertEqualIgnoringOrder(result, collection.flatMap(T -> ObjectArrayList.wrap(toRange((int)T))).pourAsList());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(absent = CollectionFeature.KNOWN_ORDER)
|
||||
#endignore
|
||||
public void testIterableMap_ArrayUnordered() {
|
||||
ObjectList<Integer> result = new ObjectArrayList<>();
|
||||
for(KEY_TYPE entry : getOrderedElements()) {
|
||||
result.addAll(toRange((int)entry));
|
||||
}
|
||||
ObjectHelpers.assertEqualIgnoringOrder(result, collection.arrayflatMap(T -> toRange((int)T)).pourAsList());
|
||||
}
|
||||
|
||||
private Integer[] toRange(int range) {
|
||||
Integer[] result = new Integer[range];
|
||||
for(int i = 0;i<range;i++) {
|
||||
result[i] = Integer.valueOf(i);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
#else
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(CollectionFeature.KNOWN_ORDER)
|
||||
#endignore
|
||||
public void testIterableMap_Collection() {
|
||||
ObjectList<Character> result = new ObjectArrayList<>();
|
||||
for(KEY_TYPE entry : getOrderedElements()) {
|
||||
result.addAll(toRange(entry));
|
||||
}
|
||||
assertEquals(result, collection.flatMap(T -> ObjectArrayList.wrap(toRange(T))).pourAsList());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(CollectionFeature.KNOWN_ORDER)
|
||||
#endignore
|
||||
public void testIterableMap_Array() {
|
||||
ObjectList<Character> result = new ObjectArrayList<>();
|
||||
for(KEY_TYPE entry : getOrderedElements()) {
|
||||
result.addAll(toRange(entry));
|
||||
}
|
||||
assertEquals(result, collection.arrayflatMap(this::toRange).pourAsList());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(absent = CollectionFeature.KNOWN_ORDER)
|
||||
#endignore
|
||||
public void testIterableMap_CollectionUnordered() {
|
||||
ObjectList<Character> result = new ObjectArrayList<>();
|
||||
for(KEY_TYPE entry : getOrderedElements()) {
|
||||
result.addAll(toRange(entry));
|
||||
}
|
||||
ObjectHelpers.assertEqualIgnoringOrder(result, collection.flatMap(T -> ObjectArrayList.wrap(toRange(T))).pourAsList());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(absent = CollectionFeature.KNOWN_ORDER)
|
||||
#endignore
|
||||
public void testIterableMap_ArrayUnordered() {
|
||||
ObjectList<Character> result = new ObjectArrayList<>();
|
||||
for(KEY_TYPE entry : getOrderedElements()) {
|
||||
result.addAll(toRange(entry));
|
||||
}
|
||||
ObjectHelpers.assertEqualIgnoringOrder(result, collection.arrayflatMap(this::toRange).pourAsList());
|
||||
}
|
||||
|
||||
private Character[] toRange(T obj) {
|
||||
return CharArrays.wrap(Objects.toString(obj).toCharArray());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -1,107 +1,107 @@
|
|||
package speiger.src.testers.PACKAGE.tests.iterable;
|
||||
|
||||
#if TYPE_OBJECT
|
||||
import java.util.Objects;
|
||||
|
||||
#endif
|
||||
import org.junit.Ignore;
|
||||
|
||||
import com.google.common.collect.testing.features.CollectionSize;
|
||||
|
||||
import speiger.src.collections.PACKAGE.sets.HASH_SET;
|
||||
import speiger.src.collections.PACKAGE.sets.SET;
|
||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPEIterableMatchesTester KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
public void testIterableMatch_AnyNull() {
|
||||
try {
|
||||
collection.matchesAny(null);
|
||||
fail("MatchesAny should throw a NullPointException");
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
}
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionSize.Require(absent = CollectionSize.ZERO)
|
||||
#endignore
|
||||
public void testIterableMatch_AnyFoundFirstElement() {
|
||||
assertTrue("Element ["+e0()+"] should be found", collection.matchesAny(T -> KEY_EQUALS(T, e0())));
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionSize.Require(CollectionSize.SEVERAL)
|
||||
#endignore
|
||||
public void testIterableMatch_AnyFoundLastElement() {
|
||||
assertTrue("Element ["+e2()+"] should be found", collection.matchesAny(T -> KEY_EQUALS(T, e2())));
|
||||
}
|
||||
|
||||
public void testIterableMatch_AnyFoundNoElement() {
|
||||
assertFalse("Element ["+e4()+"] should not be found", collection.matchesAny(T -> KEY_EQUALS(T, e4())));
|
||||
}
|
||||
|
||||
public void testIterableMatch_NoneNull() {
|
||||
try {
|
||||
collection.matchesNone(null);
|
||||
fail("MatchesNone should throw a NullPointException");
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
}
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionSize.Require(absent = CollectionSize.ZERO)
|
||||
#endignore
|
||||
public void testIterableMatch_NoneFoundFirstElement() {
|
||||
assertFalse("Element ["+e0()+"] should not be found", collection.matchesNone(T -> KEY_EQUALS(T, e0())));
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionSize.Require(CollectionSize.SEVERAL)
|
||||
#endignore
|
||||
public void testIterableMatch_NoneFoundLastElement() {
|
||||
assertFalse("Element ["+e2()+"] should not be found", collection.matchesNone(T -> KEY_EQUALS(T, e2())));
|
||||
}
|
||||
|
||||
public void testIterableMatch_NoneFoundNoElement() {
|
||||
assertTrue("Element ["+e4()+"] should not be found", collection.matchesNone(T -> KEY_EQUALS(T, e4())));
|
||||
}
|
||||
|
||||
public void testIterableMatch_AllNull() {
|
||||
try {
|
||||
collection.matchesAll(null);
|
||||
fail("MatchesAny should throw a NullPointException");
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
}
|
||||
}
|
||||
|
||||
public void testIterableMatch_AllFoundAllElements() {
|
||||
SET KEY_GENERIC_TYPE set = new HASH_SETBRACES(collection);
|
||||
assertTrue("All elements should be found", collection.matchesAll(set::contains));
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionSize.Require(absent = CollectionSize.ZERO)
|
||||
#endignore
|
||||
public void testIterableMatch_AllFoundNone() {
|
||||
assertFalse("It should not find anything", collection.matchesAll(T -> false));
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionSize.Require(CollectionSize.ZERO)
|
||||
#endignore
|
||||
public void testIterableMatch_AllFoundNoneEmpty() {
|
||||
assertTrue("Empty Collections should return true even if all have to be found", collection.matchesAll(T -> false));
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionSize.Require(CollectionSize.SEVERAL)
|
||||
#endignore
|
||||
public void testIterableMatches_AllPartical() {
|
||||
assertFalse("Even if some elements were found, it should return false", collection.matchesAll(T -> KEY_EQUALS(T, e0())));
|
||||
}
|
||||
}
|
||||
package speiger.src.testers.PACKAGE.tests.iterable;
|
||||
|
||||
#if TYPE_OBJECT
|
||||
import java.util.Objects;
|
||||
|
||||
#endif
|
||||
import org.junit.Ignore;
|
||||
|
||||
import com.google.common.collect.testing.features.CollectionSize;
|
||||
|
||||
import speiger.src.collections.PACKAGE.sets.HASH_SET;
|
||||
import speiger.src.collections.PACKAGE.sets.SET;
|
||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPEIterableMatchesTester KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
public void testIterableMatch_AnyNull() {
|
||||
try {
|
||||
collection.matchesAny(null);
|
||||
fail("MatchesAny should throw a NullPointException");
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
}
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionSize.Require(absent = CollectionSize.ZERO)
|
||||
#endignore
|
||||
public void testIterableMatch_AnyFoundFirstElement() {
|
||||
assertTrue("Element ["+e0()+"] should be found", collection.matchesAny(T -> KEY_EQUALS(T, e0())));
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionSize.Require(CollectionSize.SEVERAL)
|
||||
#endignore
|
||||
public void testIterableMatch_AnyFoundLastElement() {
|
||||
assertTrue("Element ["+e2()+"] should be found", collection.matchesAny(T -> KEY_EQUALS(T, e2())));
|
||||
}
|
||||
|
||||
public void testIterableMatch_AnyFoundNoElement() {
|
||||
assertFalse("Element ["+e4()+"] should not be found", collection.matchesAny(T -> KEY_EQUALS(T, e4())));
|
||||
}
|
||||
|
||||
public void testIterableMatch_NoneNull() {
|
||||
try {
|
||||
collection.matchesNone(null);
|
||||
fail("MatchesNone should throw a NullPointException");
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
}
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionSize.Require(absent = CollectionSize.ZERO)
|
||||
#endignore
|
||||
public void testIterableMatch_NoneFoundFirstElement() {
|
||||
assertFalse("Element ["+e0()+"] should not be found", collection.matchesNone(T -> KEY_EQUALS(T, e0())));
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionSize.Require(CollectionSize.SEVERAL)
|
||||
#endignore
|
||||
public void testIterableMatch_NoneFoundLastElement() {
|
||||
assertFalse("Element ["+e2()+"] should not be found", collection.matchesNone(T -> KEY_EQUALS(T, e2())));
|
||||
}
|
||||
|
||||
public void testIterableMatch_NoneFoundNoElement() {
|
||||
assertTrue("Element ["+e4()+"] should not be found", collection.matchesNone(T -> KEY_EQUALS(T, e4())));
|
||||
}
|
||||
|
||||
public void testIterableMatch_AllNull() {
|
||||
try {
|
||||
collection.matchesAll(null);
|
||||
fail("MatchesAny should throw a NullPointException");
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
}
|
||||
}
|
||||
|
||||
public void testIterableMatch_AllFoundAllElements() {
|
||||
SET KEY_GENERIC_TYPE set = new HASH_SETBRACES(collection);
|
||||
assertTrue("All elements should be found", collection.matchesAll(set::contains));
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionSize.Require(absent = CollectionSize.ZERO)
|
||||
#endignore
|
||||
public void testIterableMatch_AllFoundNone() {
|
||||
assertFalse("It should not find anything", collection.matchesAll(T -> false));
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionSize.Require(CollectionSize.ZERO)
|
||||
#endignore
|
||||
public void testIterableMatch_AllFoundNoneEmpty() {
|
||||
assertTrue("Empty Collections should return true even if all have to be found", collection.matchesAll(T -> false));
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionSize.Require(CollectionSize.SEVERAL)
|
||||
#endignore
|
||||
public void testIterableMatches_AllPartical() {
|
||||
assertFalse("Even if some elements were found, it should return false", collection.matchesAll(T -> KEY_EQUALS(T, e0())));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
package speiger.src.testers.PACKAGE.tests.iterable;
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPEIterablePeekTester KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
public void testIterablePeek() {
|
||||
LIST KEY_GENERIC_TYPE peeked = new ARRAY_LISTBRACES();
|
||||
LIST KEY_GENERIC_TYPE result = new ARRAY_LISTBRACES();
|
||||
collection.peek(peeked::add).forEach(result::add);
|
||||
assertEquals("Collections should match since peek is just a preview of foreach", result, peeked);
|
||||
}
|
||||
}
|
||||
package speiger.src.testers.PACKAGE.tests.iterable;
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPEIterablePeekTester KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
public void testIterablePeek() {
|
||||
LIST KEY_GENERIC_TYPE peeked = new ARRAY_LISTBRACES();
|
||||
LIST KEY_GENERIC_TYPE result = new ARRAY_LISTBRACES();
|
||||
collection.peek(peeked::add).forEach(result::add);
|
||||
assertEquals("Collections should match since peek is just a preview of foreach", result, peeked);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,78 +1,78 @@
|
|||
package speiger.src.testers.PACKAGE.tests.iterable;
|
||||
|
||||
#if TYPE_OBJECT
|
||||
import java.util.Objects;
|
||||
|
||||
#endif
|
||||
import org.junit.Ignore;
|
||||
|
||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPEIterableReduceTester KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
public void testIterableReduce_Null() {
|
||||
try {
|
||||
collection.reduce(null);
|
||||
fail("This should crash");
|
||||
} catch (NullPointerException e) {
|
||||
}
|
||||
}
|
||||
|
||||
public void testIterableReduce_extraNull() {
|
||||
try {
|
||||
collection.reduce(EMPTY_KEY_VALUE, null);
|
||||
fail("This should crash");
|
||||
} catch (NullPointerException e) {
|
||||
}
|
||||
}
|
||||
|
||||
public void testIterableReduce() {
|
||||
assertEquals("The sum of the collection should match", getSum(), collection.reduce(this::sum));
|
||||
}
|
||||
|
||||
public void testIterableExtraReduce() {
|
||||
#if TYPE_OBJECT
|
||||
assertEquals("The sum of the collection should match", getObjectSum(), collection.reduce(new StringBuilder(), this::sum).toString());
|
||||
#else
|
||||
assertEquals("The sum of the collection should match", getSum(), collection.reduce(EMPTY_KEY_VALUE, this::sum));
|
||||
#endif
|
||||
}
|
||||
|
||||
public KEY_TYPE getSum()
|
||||
{
|
||||
KEY_TYPE result = EMPTY_KEY_VALUE;
|
||||
for(KEY_TYPE key : collection)
|
||||
{
|
||||
result = sum(result, key);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public KEY_TYPE sum(KEY_TYPE key, KEY_TYPE value)
|
||||
{
|
||||
#if TYPE_BYTE || TYPE_SHORT || TYPE_CHAR
|
||||
return (KEY_TYPE)(key + value);
|
||||
#else if TYPE_OBJECT
|
||||
return value;
|
||||
#else
|
||||
return key + value;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if TYPE_OBJECT
|
||||
public StringBuilder sum(StringBuilder builder, T value) {
|
||||
return builder.append(Objects.toString(value));
|
||||
}
|
||||
|
||||
public String getObjectSum() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for(T key : collection)
|
||||
{
|
||||
builder = sum(builder, key);
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
package speiger.src.testers.PACKAGE.tests.iterable;
|
||||
|
||||
#if TYPE_OBJECT
|
||||
import java.util.Objects;
|
||||
|
||||
#endif
|
||||
import org.junit.Ignore;
|
||||
|
||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPEIterableReduceTester KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
public void testIterableReduce_Null() {
|
||||
try {
|
||||
collection.reduce(null);
|
||||
fail("This should crash");
|
||||
} catch (NullPointerException e) {
|
||||
}
|
||||
}
|
||||
|
||||
public void testIterableReduce_extraNull() {
|
||||
try {
|
||||
collection.reduce(EMPTY_KEY_VALUE, null);
|
||||
fail("This should crash");
|
||||
} catch (NullPointerException e) {
|
||||
}
|
||||
}
|
||||
|
||||
public void testIterableReduce() {
|
||||
assertEquals("The sum of the collection should match", getSum(), collection.reduce(this::sum));
|
||||
}
|
||||
|
||||
public void testIterableExtraReduce() {
|
||||
#if TYPE_OBJECT
|
||||
assertEquals("The sum of the collection should match", getObjectSum(), collection.reduce(new StringBuilder(), this::sum).toString());
|
||||
#else
|
||||
assertEquals("The sum of the collection should match", getSum(), collection.reduce(EMPTY_KEY_VALUE, this::sum));
|
||||
#endif
|
||||
}
|
||||
|
||||
public KEY_TYPE getSum()
|
||||
{
|
||||
KEY_TYPE result = EMPTY_KEY_VALUE;
|
||||
for(KEY_TYPE key : collection)
|
||||
{
|
||||
result = sum(result, key);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public KEY_TYPE sum(KEY_TYPE key, KEY_TYPE value)
|
||||
{
|
||||
#if TYPE_BYTE || TYPE_SHORT || TYPE_CHAR
|
||||
return (KEY_TYPE)(key + value);
|
||||
#else if TYPE_OBJECT
|
||||
return value;
|
||||
#else
|
||||
return key + value;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if TYPE_OBJECT
|
||||
public StringBuilder sum(StringBuilder builder, T value) {
|
||||
return builder.append(Objects.toString(value));
|
||||
}
|
||||
|
||||
public String getObjectSum() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for(T key : collection)
|
||||
{
|
||||
builder = sum(builder, key);
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -1,43 +1,43 @@
|
|||
package speiger.src.testers.PACKAGE.tests.iterable;
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
#if TYPE_OBJECT
|
||||
import java.util.Comparator;
|
||||
import java.util.Map;
|
||||
#endif
|
||||
|
||||
import com.google.common.collect.testing.features.CollectionFeature;
|
||||
|
||||
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
||||
import speiger.src.testers.utils.SpecialFeature;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPEIterableSortedTester KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
#ignore
|
||||
@CollectionFeature.Require(absent = CollectionFeature.KNOWN_ORDER)
|
||||
@SpecialFeature.Require(absent = SpecialFeature.MAP_ENTRY)
|
||||
#endignore
|
||||
public void testIterableSorted() {
|
||||
LIST KEY_GENERIC_TYPE expected = new ARRAY_LISTBRACES(collection);
|
||||
expected.sort(null);
|
||||
assertEquals("Elements were expected to be sorted", expected, collection.sorted(null).pourAsList());
|
||||
}
|
||||
|
||||
#if TYPE_OBJECT
|
||||
#ignore
|
||||
@CollectionFeature.Require(absent = CollectionFeature.KNOWN_ORDER)
|
||||
@SpecialFeature.Require(SpecialFeature.MAP_ENTRY)
|
||||
#endignore
|
||||
public void testIterableSortedEntry() {
|
||||
ObjectList<T> expected = new ObjectArrayList<>(collection);
|
||||
Comparator<T> comparator = Comparator.comparing(T -> (Comparable<Object>)((Map.Entry<Object, Object>)T).getKey());
|
||||
expected.sort(comparator);
|
||||
assertEquals("Elements were expected to be sorted", expected, collection.sorted(comparator).pourAsList());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
package speiger.src.testers.PACKAGE.tests.iterable;
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
#if TYPE_OBJECT
|
||||
import java.util.Comparator;
|
||||
import java.util.Map;
|
||||
#endif
|
||||
|
||||
import com.google.common.collect.testing.features.CollectionFeature;
|
||||
|
||||
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
||||
import speiger.src.testers.utils.SpecialFeature;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPEIterableSortedTester KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
#ignore
|
||||
@CollectionFeature.Require(absent = CollectionFeature.KNOWN_ORDER)
|
||||
@SpecialFeature.Require(absent = SpecialFeature.MAP_ENTRY)
|
||||
#endignore
|
||||
public void testIterableSorted() {
|
||||
LIST KEY_GENERIC_TYPE expected = new ARRAY_LISTBRACES(collection);
|
||||
expected.sort(null);
|
||||
assertEquals("Elements were expected to be sorted", expected, collection.sorted(null).pourAsList());
|
||||
}
|
||||
|
||||
#if TYPE_OBJECT
|
||||
#ignore
|
||||
@CollectionFeature.Require(absent = CollectionFeature.KNOWN_ORDER)
|
||||
@SpecialFeature.Require(SpecialFeature.MAP_ENTRY)
|
||||
#endignore
|
||||
public void testIterableSortedEntry() {
|
||||
ObjectList<T> expected = new ObjectArrayList<>(collection);
|
||||
Comparator<T> comparator = Comparator.comparing(T -> (Comparable<Object>)((Map.Entry<Object, Object>)T).getKey());
|
||||
expected.sort(comparator);
|
||||
assertEquals("Elements were expected to be sorted", expected, collection.sorted(comparator).pourAsList());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -1,60 +1,60 @@
|
|||
package speiger.src.testers.PACKAGE.tests.list;
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
#ignore
|
||||
import static com.google.common.collect.testing.features.CollectionFeature.SUPPORTS_ADD;
|
||||
import static com.google.common.collect.testing.features.CollectionSize.ONE;
|
||||
#endignore
|
||||
|
||||
import com.google.common.collect.testing.features.CollectionFeature;
|
||||
import com.google.common.collect.testing.features.CollectionSize;
|
||||
|
||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_LIST_TESTER;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPEListAbsentTester KEY_GENERIC_TYPE extends ABSTRACT_LIST_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
#ignore
|
||||
@CollectionFeature.Require(SUPPORTS_ADD)
|
||||
@CollectionSize.Require(ONE)
|
||||
#endignore
|
||||
public void testIfAbsent() {
|
||||
assertTrue("addIfAbsent(absent) should return true", getList().addIfAbsent(e1()));
|
||||
expectAdded(e1());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(SUPPORTS_ADD)
|
||||
@CollectionSize.Require(ONE)
|
||||
#endignore
|
||||
public void testIfPresent() {
|
||||
assertFalse("addIfAbsent(present) should return false", getList().addIfAbsent(e0()));
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(absent = SUPPORTS_ADD)
|
||||
@CollectionSize.Require(ONE)
|
||||
#endignore
|
||||
public void test_IfAbsentUnsupported() {
|
||||
try {
|
||||
assertFalse("addIfAbsent(absent) should return false", getList().addIfAbsent(e1()));
|
||||
} catch (UnsupportedOperationException e) {
|
||||
//Success
|
||||
}
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(absent = SUPPORTS_ADD)
|
||||
@CollectionSize.Require(ONE)
|
||||
#endignore
|
||||
public void test_IfPresentUnsupported() {
|
||||
try {
|
||||
assertFalse("addIfAbsent(present) should return false", getList().addIfAbsent(e0()));
|
||||
} catch (UnsupportedOperationException e) {
|
||||
//Success
|
||||
}
|
||||
}
|
||||
}
|
||||
package speiger.src.testers.PACKAGE.tests.list;
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
#ignore
|
||||
import static com.google.common.collect.testing.features.CollectionFeature.SUPPORTS_ADD;
|
||||
import static com.google.common.collect.testing.features.CollectionSize.ONE;
|
||||
#endignore
|
||||
|
||||
import com.google.common.collect.testing.features.CollectionFeature;
|
||||
import com.google.common.collect.testing.features.CollectionSize;
|
||||
|
||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_LIST_TESTER;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPEListAbsentTester KEY_GENERIC_TYPE extends ABSTRACT_LIST_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
#ignore
|
||||
@CollectionFeature.Require(SUPPORTS_ADD)
|
||||
@CollectionSize.Require(ONE)
|
||||
#endignore
|
||||
public void testIfAbsent() {
|
||||
assertTrue("addIfAbsent(absent) should return true", getList().addIfAbsent(e1()));
|
||||
expectAdded(e1());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(SUPPORTS_ADD)
|
||||
@CollectionSize.Require(ONE)
|
||||
#endignore
|
||||
public void testIfPresent() {
|
||||
assertFalse("addIfAbsent(present) should return false", getList().addIfAbsent(e0()));
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(absent = SUPPORTS_ADD)
|
||||
@CollectionSize.Require(ONE)
|
||||
#endignore
|
||||
public void test_IfAbsentUnsupported() {
|
||||
try {
|
||||
assertFalse("addIfAbsent(absent) should return false", getList().addIfAbsent(e1()));
|
||||
} catch (UnsupportedOperationException e) {
|
||||
//Success
|
||||
}
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(absent = SUPPORTS_ADD)
|
||||
@CollectionSize.Require(ONE)
|
||||
#endignore
|
||||
public void test_IfPresentUnsupported() {
|
||||
try {
|
||||
assertFalse("addIfAbsent(present) should return false", getList().addIfAbsent(e0()));
|
||||
} catch (UnsupportedOperationException e) {
|
||||
//Success
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,194 +1,194 @@
|
|||
package speiger.src.testers.PACKAGE.tests.list;
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
#if !TYPE_BOOLEAN
|
||||
#ignore
|
||||
import static com.google.common.collect.testing.features.CollectionFeature.SUPPORTS_ADD;
|
||||
#endignore
|
||||
#endif
|
||||
#ignore
|
||||
import static com.google.common.collect.testing.features.CollectionSize.ONE;
|
||||
import static com.google.common.collect.testing.features.CollectionSize.ZERO;
|
||||
import static com.google.common.collect.testing.features.ListFeature.SUPPORTS_ADD_WITH_INDEX;
|
||||
#endignore
|
||||
|
||||
#if !TYPE_BOOLEAN
|
||||
import com.google.common.collect.testing.features.CollectionFeature;
|
||||
#endif
|
||||
import com.google.common.collect.testing.features.CollectionSize;
|
||||
import com.google.common.collect.testing.features.ListFeature;
|
||||
|
||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_LIST_TESTER;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPEListAddAllArrayAtIndexTester KEY_GENERIC_TYPE extends ABSTRACT_LIST_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
#ignore
|
||||
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testAddAllArrayAtIndex_supportedAllPresent() {
|
||||
getList().addElements(0, createArray(e0()));
|
||||
expectAddedIndex(0, e0());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(absent = SUPPORTS_ADD_WITH_INDEX)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testAddAllArrayAtIndex_unsupportedAllPresent() {
|
||||
try {
|
||||
getList().addElements(0, createArray(e0()));
|
||||
fail("addAll(n, allPresent) should throw");
|
||||
} catch (UnsupportedOperationException expected) {
|
||||
}
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testAddAllArrayAtIndex_supportedSomePresent() {
|
||||
getList().addElements(0, createArray(e0(), e3()));
|
||||
expectAddedIndex(0, e0(), e3());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(absent = SUPPORTS_ADD_WITH_INDEX)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testAddAllArrayAtIndex_unsupportedSomePresent() {
|
||||
try {
|
||||
getList().addElements(0, createArray(e0(), e3()));
|
||||
fail("addAll(n, allPresent) should throw");
|
||||
} catch (UnsupportedOperationException expected) {
|
||||
}
|
||||
expectUnchanged();
|
||||
expectMissing(e3());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
|
||||
#endignore
|
||||
public void testAddAllArrayAtIndex_supportedNothing() {
|
||||
getList().addElements(0, emptyArray());
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(absent = SUPPORTS_ADD_WITH_INDEX)
|
||||
#endignore
|
||||
public void testAddAllArrayAtIndex_unsupportedNothing() {
|
||||
try {
|
||||
getList().addElements(0, emptyArray());
|
||||
} catch (UnsupportedOperationException tolerated) {
|
||||
}
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
|
||||
#endignore
|
||||
public void testAddAllArrayAtIndex_withDuplicates() {
|
||||
getList().addElements(0, createArray(e0(), e1(), e0(), e1()));
|
||||
expectAddedIndex(0, e0(), e1(), e0(), e1());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
|
||||
@CollectionSize.Require(absent = { ZERO, ONE })
|
||||
#endignore
|
||||
public void testAddAllArrayAtIndex_middle() {
|
||||
getList().addElements(getNumElements() / 2, createDisjointArray());
|
||||
expectAdded(getNumElements() / 2, createDisjointCollection());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testAddAllArrayAtIndex_end() {
|
||||
getList().addElements(getNumElements(), createDisjointArray());
|
||||
expectAdded(getNumElements(), createDisjointCollection());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
|
||||
#endignore
|
||||
public void testAddAllArrayAtIndex_nullCollectionReference() {
|
||||
try {
|
||||
#if TYPE_OBJECT
|
||||
getList().addElements(0, (T[])null);
|
||||
#else
|
||||
getList().addElements(0, null);
|
||||
#endif
|
||||
fail("addElements(n, null) should throw");
|
||||
} catch (NullPointerException expected) {
|
||||
}
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
|
||||
#endignore
|
||||
public void testAddAllArrayAtIndex_negative() {
|
||||
try {
|
||||
getList().addElements(-1, createArray(e3()));
|
||||
fail("addElements(-1, e) should throw");
|
||||
} catch (IndexOutOfBoundsException expected) {
|
||||
}
|
||||
expectUnchanged();
|
||||
expectMissing(e3());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
|
||||
#endignore
|
||||
public void testAddAllArrayAtIndex_tooLarge() {
|
||||
try {
|
||||
getList().addElements(getNumElements() + 1, createArray(e3()));
|
||||
fail("addElements(size + 1, e) should throw");
|
||||
} catch (IndexOutOfBoundsException expected) {
|
||||
}
|
||||
expectUnchanged();
|
||||
expectMissing(e3());
|
||||
}
|
||||
|
||||
#if !TYPE_BOOLEAN
|
||||
#ignore
|
||||
@CollectionFeature.Require(SUPPORTS_ADD)
|
||||
#endignore
|
||||
public void testAddAllArray_supportedToLargeOffset() {
|
||||
try {
|
||||
getList().addElements(0, createDisjointArray(), 5, 2);
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
}
|
||||
expectUnchanged();
|
||||
expectMissing(e3(), e4());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(SUPPORTS_ADD)
|
||||
#endignore
|
||||
public void testAddAllArray_supportedToSmallOffset() {
|
||||
try {
|
||||
getList().addElements(0, createDisjointArray(), -1, 2);
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
}
|
||||
expectUnchanged();
|
||||
expectMissing(e3(), e4());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(SUPPORTS_ADD)
|
||||
#endignore
|
||||
public void testAddAllArray_supportedAddSubArray() {
|
||||
getList().addElements(0, createDisjointArray(), 0, 1);
|
||||
expectAddedIndex(0, e3());
|
||||
expectMissing(e4());
|
||||
}
|
||||
#endif
|
||||
package speiger.src.testers.PACKAGE.tests.list;
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
#if !TYPE_BOOLEAN
|
||||
#ignore
|
||||
import static com.google.common.collect.testing.features.CollectionFeature.SUPPORTS_ADD;
|
||||
#endignore
|
||||
#endif
|
||||
#ignore
|
||||
import static com.google.common.collect.testing.features.CollectionSize.ONE;
|
||||
import static com.google.common.collect.testing.features.CollectionSize.ZERO;
|
||||
import static com.google.common.collect.testing.features.ListFeature.SUPPORTS_ADD_WITH_INDEX;
|
||||
#endignore
|
||||
|
||||
#if !TYPE_BOOLEAN
|
||||
import com.google.common.collect.testing.features.CollectionFeature;
|
||||
#endif
|
||||
import com.google.common.collect.testing.features.CollectionSize;
|
||||
import com.google.common.collect.testing.features.ListFeature;
|
||||
|
||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_LIST_TESTER;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPEListAddAllArrayAtIndexTester KEY_GENERIC_TYPE extends ABSTRACT_LIST_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
#ignore
|
||||
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testAddAllArrayAtIndex_supportedAllPresent() {
|
||||
getList().addElements(0, createArray(e0()));
|
||||
expectAddedIndex(0, e0());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(absent = SUPPORTS_ADD_WITH_INDEX)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testAddAllArrayAtIndex_unsupportedAllPresent() {
|
||||
try {
|
||||
getList().addElements(0, createArray(e0()));
|
||||
fail("addAll(n, allPresent) should throw");
|
||||
} catch (UnsupportedOperationException expected) {
|
||||
}
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testAddAllArrayAtIndex_supportedSomePresent() {
|
||||
getList().addElements(0, createArray(e0(), e3()));
|
||||
expectAddedIndex(0, e0(), e3());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(absent = SUPPORTS_ADD_WITH_INDEX)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testAddAllArrayAtIndex_unsupportedSomePresent() {
|
||||
try {
|
||||
getList().addElements(0, createArray(e0(), e3()));
|
||||
fail("addAll(n, allPresent) should throw");
|
||||
} catch (UnsupportedOperationException expected) {
|
||||
}
|
||||
expectUnchanged();
|
||||
expectMissing(e3());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
|
||||
#endignore
|
||||
public void testAddAllArrayAtIndex_supportedNothing() {
|
||||
getList().addElements(0, emptyArray());
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(absent = SUPPORTS_ADD_WITH_INDEX)
|
||||
#endignore
|
||||
public void testAddAllArrayAtIndex_unsupportedNothing() {
|
||||
try {
|
||||
getList().addElements(0, emptyArray());
|
||||
} catch (UnsupportedOperationException tolerated) {
|
||||
}
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
|
||||
#endignore
|
||||
public void testAddAllArrayAtIndex_withDuplicates() {
|
||||
getList().addElements(0, createArray(e0(), e1(), e0(), e1()));
|
||||
expectAddedIndex(0, e0(), e1(), e0(), e1());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
|
||||
@CollectionSize.Require(absent = { ZERO, ONE })
|
||||
#endignore
|
||||
public void testAddAllArrayAtIndex_middle() {
|
||||
getList().addElements(getNumElements() / 2, createDisjointArray());
|
||||
expectAdded(getNumElements() / 2, createDisjointCollection());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testAddAllArrayAtIndex_end() {
|
||||
getList().addElements(getNumElements(), createDisjointArray());
|
||||
expectAdded(getNumElements(), createDisjointCollection());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
|
||||
#endignore
|
||||
public void testAddAllArrayAtIndex_nullCollectionReference() {
|
||||
try {
|
||||
#if TYPE_OBJECT
|
||||
getList().addElements(0, (T[])null);
|
||||
#else
|
||||
getList().addElements(0, null);
|
||||
#endif
|
||||
fail("addElements(n, null) should throw");
|
||||
} catch (NullPointerException expected) {
|
||||
}
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
|
||||
#endignore
|
||||
public void testAddAllArrayAtIndex_negative() {
|
||||
try {
|
||||
getList().addElements(-1, createArray(e3()));
|
||||
fail("addElements(-1, e) should throw");
|
||||
} catch (IndexOutOfBoundsException expected) {
|
||||
}
|
||||
expectUnchanged();
|
||||
expectMissing(e3());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
|
||||
#endignore
|
||||
public void testAddAllArrayAtIndex_tooLarge() {
|
||||
try {
|
||||
getList().addElements(getNumElements() + 1, createArray(e3()));
|
||||
fail("addElements(size + 1, e) should throw");
|
||||
} catch (IndexOutOfBoundsException expected) {
|
||||
}
|
||||
expectUnchanged();
|
||||
expectMissing(e3());
|
||||
}
|
||||
|
||||
#if !TYPE_BOOLEAN
|
||||
#ignore
|
||||
@CollectionFeature.Require(SUPPORTS_ADD)
|
||||
#endignore
|
||||
public void testAddAllArray_supportedToLargeOffset() {
|
||||
try {
|
||||
getList().addElements(0, createDisjointArray(), 5, 2);
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
}
|
||||
expectUnchanged();
|
||||
expectMissing(e3(), e4());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(SUPPORTS_ADD)
|
||||
#endignore
|
||||
public void testAddAllArray_supportedToSmallOffset() {
|
||||
try {
|
||||
getList().addElements(0, createDisjointArray(), -1, 2);
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
}
|
||||
expectUnchanged();
|
||||
expectMissing(e3(), e4());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@CollectionFeature.Require(SUPPORTS_ADD)
|
||||
#endignore
|
||||
public void testAddAllArray_supportedAddSubArray() {
|
||||
getList().addElements(0, createDisjointArray(), 0, 1);
|
||||
expectAddedIndex(0, e3());
|
||||
expectMissing(e4());
|
||||
}
|
||||
#endif
|
||||
}
|
|
@ -1,167 +1,167 @@
|
|||
package speiger.src.testers.PACKAGE.tests.list;
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
#ignore
|
||||
import static com.google.common.collect.testing.features.CollectionSize.ONE;
|
||||
import static com.google.common.collect.testing.features.CollectionSize.ZERO;
|
||||
import static com.google.common.collect.testing.features.ListFeature.SUPPORTS_ADD_WITH_INDEX;
|
||||
#endignore
|
||||
|
||||
import com.google.common.collect.testing.features.CollectionSize;
|
||||
import com.google.common.collect.testing.features.ListFeature;
|
||||
|
||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_LIST_TESTER;
|
||||
import speiger.src.testers.PACKAGE.utils.MINIMAL_COLLECTION;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPEListAddAllAtIndexTester KEY_GENERIC_TYPE extends ABSTRACT_LIST_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
#ignore
|
||||
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testAddAllAtIndex_supportedAllPresent() {
|
||||
assertTrue("addAll(n, allPresent) should return true", getList().addAll(0, MINIMAL_COLLECTION.of(e0())));
|
||||
expectAddedIndex(0, e0());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(absent = SUPPORTS_ADD_WITH_INDEX)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testAddAllAtIndex_unsupportedAllPresent() {
|
||||
try {
|
||||
getList().addAll(0, MINIMAL_COLLECTION.of(e0()));
|
||||
fail("addAll(n, allPresent) should throw");
|
||||
} catch (UnsupportedOperationException expected) {
|
||||
}
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testAddAllAtIndex_supportedSomePresent() {
|
||||
assertTrue("addAll(n, allPresent) should return true", getList().addAll(0, MINIMAL_COLLECTION.of(e0(), e3())));
|
||||
expectAddedIndex(0, e0(), e3());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(absent = SUPPORTS_ADD_WITH_INDEX)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testAddAllAtIndex_unsupportedSomePresent() {
|
||||
try {
|
||||
getList().addAll(0, MINIMAL_COLLECTION.of(e0(), e3()));
|
||||
fail("addAll(n, allPresent) should throw");
|
||||
} catch (UnsupportedOperationException expected) {
|
||||
}
|
||||
expectUnchanged();
|
||||
expectMissing(e3());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
|
||||
#endignore
|
||||
public void testAddAllAtIndex_supportedNothing() {
|
||||
assertFalse("addAll(n, nothing) should return false", getList().addAll(0, emptyCollection()));
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(absent = SUPPORTS_ADD_WITH_INDEX)
|
||||
#endignore
|
||||
public void testAddAllAtIndex_unsupportedNothing() {
|
||||
try {
|
||||
assertFalse("addAll(n, nothing) should return false or throw", getList().addAll(0, emptyCollection()));
|
||||
} catch (UnsupportedOperationException tolerated) {
|
||||
}
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
|
||||
#endignore
|
||||
public void testAddAllAtIndex_withDuplicates() {
|
||||
MINIMAL_COLLECTION KEY_GENERIC_TYPE elementsToAdd = MINIMAL_COLLECTION.of(e0(), e1(), e0(), e1());
|
||||
assertTrue("addAll(n, hasDuplicates) should return true", getList().addAll(0, elementsToAdd));
|
||||
expectAddedIndex(0, e0(), e1(), e0(), e1());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
|
||||
@CollectionSize.Require(absent = { ZERO, ONE })
|
||||
#endignore
|
||||
public void testAddAllAtIndex_middle() {
|
||||
assertTrue("addAll(middle, disjoint) should return true", getList().addAll(getNumElements() / 2, createDisjointCollection()));
|
||||
expectAdded(getNumElements() / 2, createDisjointCollection());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testAddAllAtIndex_end() {
|
||||
assertTrue("addAll(end, disjoint) should return true", getList().addAll(getNumElements(), createDisjointCollection()));
|
||||
expectAdded(getNumElements(), createDisjointCollection());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
|
||||
#endignore
|
||||
public void testAddAllAtIndex_nullCollectionReference() {
|
||||
try {
|
||||
getList().addAll(0, (COLLECTION KEY_GENERIC_TYPE)null);
|
||||
fail("addAll(n, null) should throw");
|
||||
} catch (NullPointerException expected) {
|
||||
}
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
|
||||
#endignore
|
||||
public void testAddAllAtIndex_nullListReference() {
|
||||
try {
|
||||
getList().addAll(0, (LIST KEY_GENERIC_TYPE)null);
|
||||
fail("addAll(n, null) should throw");
|
||||
} catch (NullPointerException expected) {
|
||||
}
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
|
||||
#endignore
|
||||
public void testAddAllAtIndex_negative() {
|
||||
try {
|
||||
getList().addAll(-1, MINIMAL_COLLECTION.of(e3()));
|
||||
fail("addAll(-1, e) should throw");
|
||||
} catch (IndexOutOfBoundsException expected) {
|
||||
}
|
||||
expectUnchanged();
|
||||
#if !TYPE_BOOLEAN
|
||||
expectMissing(e3());
|
||||
#endif
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
|
||||
#endignore
|
||||
public void testAddAllAtIndex_tooLarge() {
|
||||
try {
|
||||
getList().addAll(getNumElements() + 1, MINIMAL_COLLECTION.of(e3()));
|
||||
fail("addAll(size + 1, e) should throw");
|
||||
} catch (IndexOutOfBoundsException expected) {
|
||||
}
|
||||
expectUnchanged();
|
||||
#if !TYPE_BOOLEAN
|
||||
expectMissing(e3());
|
||||
#endif
|
||||
}
|
||||
}
|
||||
package speiger.src.testers.PACKAGE.tests.list;
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
#ignore
|
||||
import static com.google.common.collect.testing.features.CollectionSize.ONE;
|
||||
import static com.google.common.collect.testing.features.CollectionSize.ZERO;
|
||||
import static com.google.common.collect.testing.features.ListFeature.SUPPORTS_ADD_WITH_INDEX;
|
||||
#endignore
|
||||
|
||||
import com.google.common.collect.testing.features.CollectionSize;
|
||||
import com.google.common.collect.testing.features.ListFeature;
|
||||
|
||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_LIST_TESTER;
|
||||
import speiger.src.testers.PACKAGE.utils.MINIMAL_COLLECTION;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPEListAddAllAtIndexTester KEY_GENERIC_TYPE extends ABSTRACT_LIST_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
#ignore
|
||||
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testAddAllAtIndex_supportedAllPresent() {
|
||||
assertTrue("addAll(n, allPresent) should return true", getList().addAll(0, MINIMAL_COLLECTION.of(e0())));
|
||||
expectAddedIndex(0, e0());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(absent = SUPPORTS_ADD_WITH_INDEX)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testAddAllAtIndex_unsupportedAllPresent() {
|
||||
try {
|
||||
getList().addAll(0, MINIMAL_COLLECTION.of(e0()));
|
||||
fail("addAll(n, allPresent) should throw");
|
||||
} catch (UnsupportedOperationException expected) {
|
||||
}
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testAddAllAtIndex_supportedSomePresent() {
|
||||
assertTrue("addAll(n, allPresent) should return true", getList().addAll(0, MINIMAL_COLLECTION.of(e0(), e3())));
|
||||
expectAddedIndex(0, e0(), e3());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(absent = SUPPORTS_ADD_WITH_INDEX)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testAddAllAtIndex_unsupportedSomePresent() {
|
||||
try {
|
||||
getList().addAll(0, MINIMAL_COLLECTION.of(e0(), e3()));
|
||||
fail("addAll(n, allPresent) should throw");
|
||||
} catch (UnsupportedOperationException expected) {
|
||||
}
|
||||
expectUnchanged();
|
||||
expectMissing(e3());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
|
||||
#endignore
|
||||
public void testAddAllAtIndex_supportedNothing() {
|
||||
assertFalse("addAll(n, nothing) should return false", getList().addAll(0, emptyCollection()));
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(absent = SUPPORTS_ADD_WITH_INDEX)
|
||||
#endignore
|
||||
public void testAddAllAtIndex_unsupportedNothing() {
|
||||
try {
|
||||
assertFalse("addAll(n, nothing) should return false or throw", getList().addAll(0, emptyCollection()));
|
||||
} catch (UnsupportedOperationException tolerated) {
|
||||
}
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
|
||||
#endignore
|
||||
public void testAddAllAtIndex_withDuplicates() {
|
||||
MINIMAL_COLLECTION KEY_GENERIC_TYPE elementsToAdd = MINIMAL_COLLECTION.of(e0(), e1(), e0(), e1());
|
||||
assertTrue("addAll(n, hasDuplicates) should return true", getList().addAll(0, elementsToAdd));
|
||||
expectAddedIndex(0, e0(), e1(), e0(), e1());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
|
||||
@CollectionSize.Require(absent = { ZERO, ONE })
|
||||
#endignore
|
||||
public void testAddAllAtIndex_middle() {
|
||||
assertTrue("addAll(middle, disjoint) should return true", getList().addAll(getNumElements() / 2, createDisjointCollection()));
|
||||
expectAdded(getNumElements() / 2, createDisjointCollection());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testAddAllAtIndex_end() {
|
||||
assertTrue("addAll(end, disjoint) should return true", getList().addAll(getNumElements(), createDisjointCollection()));
|
||||
expectAdded(getNumElements(), createDisjointCollection());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
|
||||
#endignore
|
||||
public void testAddAllAtIndex_nullCollectionReference() {
|
||||
try {
|
||||
getList().addAll(0, (COLLECTION KEY_GENERIC_TYPE)null);
|
||||
fail("addAll(n, null) should throw");
|
||||
} catch (NullPointerException expected) {
|
||||
}
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
|
||||
#endignore
|
||||
public void testAddAllAtIndex_nullListReference() {
|
||||
try {
|
||||
getList().addAll(0, (LIST KEY_GENERIC_TYPE)null);
|
||||
fail("addAll(n, null) should throw");
|
||||
} catch (NullPointerException expected) {
|
||||
}
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
|
||||
#endignore
|
||||
public void testAddAllAtIndex_negative() {
|
||||
try {
|
||||
getList().addAll(-1, MINIMAL_COLLECTION.of(e3()));
|
||||
fail("addAll(-1, e) should throw");
|
||||
} catch (IndexOutOfBoundsException expected) {
|
||||
}
|
||||
expectUnchanged();
|
||||
#if !TYPE_BOOLEAN
|
||||
expectMissing(e3());
|
||||
#endif
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
|
||||
#endignore
|
||||
public void testAddAllAtIndex_tooLarge() {
|
||||
try {
|
||||
getList().addAll(getNumElements() + 1, MINIMAL_COLLECTION.of(e3()));
|
||||
fail("addAll(size + 1, e) should throw");
|
||||
} catch (IndexOutOfBoundsException expected) {
|
||||
}
|
||||
expectUnchanged();
|
||||
#if !TYPE_BOOLEAN
|
||||
expectMissing(e3());
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,155 +1,155 @@
|
|||
package speiger.src.testers.PACKAGE.tests.list;
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
#ignore
|
||||
import static com.google.common.collect.testing.features.CollectionSize.ONE;
|
||||
import static com.google.common.collect.testing.features.CollectionSize.ZERO;
|
||||
import static com.google.common.collect.testing.features.ListFeature.SUPPORTS_ADD_WITH_INDEX;
|
||||
#endignore
|
||||
|
||||
import com.google.common.collect.testing.features.CollectionSize;
|
||||
import com.google.common.collect.testing.features.ListFeature;
|
||||
|
||||
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_LIST_TESTER;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPEListAddAllListAtIndexTester KEY_GENERIC_TYPE extends ABSTRACT_LIST_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
#ignore
|
||||
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testAddAllListAtIndex_supportedAllPresent() {
|
||||
assertTrue("addAll(n, allPresent) should return true", getList().addAll(0, ARRAY_LIST.wrap(e0())));
|
||||
expectAddedIndex(0, e0());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(absent = SUPPORTS_ADD_WITH_INDEX)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testAddAllListAtIndex_unsupportedAllPresent() {
|
||||
try {
|
||||
getList().addAll(0, ARRAY_LIST.wrap(e0()));
|
||||
fail("addAll(n, allPresent) should throw");
|
||||
} catch (UnsupportedOperationException expected) {
|
||||
}
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testAddAllListAtIndex_supportedSomePresent() {
|
||||
assertTrue("addAll(n, allPresent) should return true", getList().addAll(0, ARRAY_LIST.wrap(e0(), e3())));
|
||||
expectAddedIndex(0, e0(), e3());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(absent = SUPPORTS_ADD_WITH_INDEX)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testAddAllListAtIndex_unsupportedSomePresent() {
|
||||
try {
|
||||
getList().addAll(0, ARRAY_LIST.wrap(e0(), e3()));
|
||||
fail("addAll(n, allPresent) should throw");
|
||||
} catch (UnsupportedOperationException expected) {
|
||||
}
|
||||
expectUnchanged();
|
||||
#if !TYPE_BOOLEAN
|
||||
expectMissing(e3());
|
||||
#endif
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
|
||||
#endignore
|
||||
public void testAddAllListAtIndex_supportedNothing() {
|
||||
assertFalse("addAll(n, nothing) should return false", getList().addAll(0, new ARRAY_LISTBRACES()));
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(absent = SUPPORTS_ADD_WITH_INDEX)
|
||||
#endignore
|
||||
public void testAddAllListAtIndex_unsupportedNothing() {
|
||||
try {
|
||||
assertFalse("addAll(n, nothing) should return false or throw", getList().addAll(0, new ARRAY_LISTBRACES()));
|
||||
} catch (UnsupportedOperationException tolerated) {
|
||||
}
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
|
||||
#endignore
|
||||
public void testAddAllListAtIndex_withDuplicates() {
|
||||
assertTrue("addAll(n, hasDuplicates) should return true", getList().addAll(0, ARRAY_LIST.wrap(e0(), e1(), e0(), e1())));
|
||||
expectAddedIndex(0, e0(), e1(), e0(), e1());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
|
||||
@CollectionSize.Require(absent = { ZERO, ONE })
|
||||
#endignore
|
||||
public void testAddAllListAtIndex_middle() {
|
||||
assertTrue("addAll(middle, disjoint) should return true", getList().addAll(getNumElements() / 2, new ARRAY_LISTBRACES(createDisjointCollection())));
|
||||
expectAdded(getNumElements() / 2, createDisjointCollection());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testAddAllListAtIndex_end() {
|
||||
assertTrue("addAll(end, disjoint) should return true", getList().addAll(getNumElements(), new ARRAY_LISTBRACES(createDisjointCollection())));
|
||||
expectAdded(getNumElements(), createDisjointCollection());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
|
||||
#endignore
|
||||
public void testAddAllListAtIndex_nullListReference() {
|
||||
try {
|
||||
getList().addAll(0, (LIST KEY_GENERIC_TYPE)null);
|
||||
fail("addAll(n, null) should throw");
|
||||
} catch (NullPointerException expected) {
|
||||
}
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
|
||||
#endignore
|
||||
public void testAddAllListAtIndex_negative() {
|
||||
try {
|
||||
getList().addAll(-1, ARRAY_LIST.wrap(e3()));
|
||||
fail("addAll(-1, e) should throw");
|
||||
} catch (IndexOutOfBoundsException expected) {
|
||||
}
|
||||
expectUnchanged();
|
||||
#if !TYPE_BOOLEAN
|
||||
expectMissing(e3());
|
||||
#endif
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
|
||||
#endignore
|
||||
public void testAddAllListAtIndex_tooLarge() {
|
||||
try {
|
||||
getList().addAll(getNumElements() + 1, ARRAY_LIST.wrap(e3()));
|
||||
fail("addAll(size + 1, e) should throw");
|
||||
} catch (IndexOutOfBoundsException expected) {
|
||||
}
|
||||
expectUnchanged();
|
||||
#if !TYPE_BOOLEAN
|
||||
expectMissing(e3());
|
||||
#endif
|
||||
}
|
||||
}
|
||||
package speiger.src.testers.PACKAGE.tests.list;
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
#ignore
|
||||
import static com.google.common.collect.testing.features.CollectionSize.ONE;
|
||||
import static com.google.common.collect.testing.features.CollectionSize.ZERO;
|
||||
import static com.google.common.collect.testing.features.ListFeature.SUPPORTS_ADD_WITH_INDEX;
|
||||
#endignore
|
||||
|
||||
import com.google.common.collect.testing.features.CollectionSize;
|
||||
import com.google.common.collect.testing.features.ListFeature;
|
||||
|
||||
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_LIST_TESTER;
|
||||
|
||||
@Ignore
|
||||
@SuppressWarnings("javadoc")
|
||||
public class FILE_KEY_TYPEListAddAllListAtIndexTester KEY_GENERIC_TYPE extends ABSTRACT_LIST_TESTER KEY_GENERIC_TYPE
|
||||
{
|
||||
#ignore
|
||||
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testAddAllListAtIndex_supportedAllPresent() {
|
||||
assertTrue("addAll(n, allPresent) should return true", getList().addAll(0, ARRAY_LIST.wrap(e0())));
|
||||
expectAddedIndex(0, e0());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(absent = SUPPORTS_ADD_WITH_INDEX)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testAddAllListAtIndex_unsupportedAllPresent() {
|
||||
try {
|
||||
getList().addAll(0, ARRAY_LIST.wrap(e0()));
|
||||
fail("addAll(n, allPresent) should throw");
|
||||
} catch (UnsupportedOperationException expected) {
|
||||
}
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testAddAllListAtIndex_supportedSomePresent() {
|
||||
assertTrue("addAll(n, allPresent) should return true", getList().addAll(0, ARRAY_LIST.wrap(e0(), e3())));
|
||||
expectAddedIndex(0, e0(), e3());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(absent = SUPPORTS_ADD_WITH_INDEX)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testAddAllListAtIndex_unsupportedSomePresent() {
|
||||
try {
|
||||
getList().addAll(0, ARRAY_LIST.wrap(e0(), e3()));
|
||||
fail("addAll(n, allPresent) should throw");
|
||||
} catch (UnsupportedOperationException expected) {
|
||||
}
|
||||
expectUnchanged();
|
||||
#if !TYPE_BOOLEAN
|
||||
expectMissing(e3());
|
||||
#endif
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
|
||||
#endignore
|
||||
public void testAddAllListAtIndex_supportedNothing() {
|
||||
assertFalse("addAll(n, nothing) should return false", getList().addAll(0, new ARRAY_LISTBRACES()));
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(absent = SUPPORTS_ADD_WITH_INDEX)
|
||||
#endignore
|
||||
public void testAddAllListAtIndex_unsupportedNothing() {
|
||||
try {
|
||||
assertFalse("addAll(n, nothing) should return false or throw", getList().addAll(0, new ARRAY_LISTBRACES()));
|
||||
} catch (UnsupportedOperationException tolerated) {
|
||||
}
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
|
||||
#endignore
|
||||
public void testAddAllListAtIndex_withDuplicates() {
|
||||
assertTrue("addAll(n, hasDuplicates) should return true", getList().addAll(0, ARRAY_LIST.wrap(e0(), e1(), e0(), e1())));
|
||||
expectAddedIndex(0, e0(), e1(), e0(), e1());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
|
||||
@CollectionSize.Require(absent = { ZERO, ONE })
|
||||
#endignore
|
||||
public void testAddAllListAtIndex_middle() {
|
||||
assertTrue("addAll(middle, disjoint) should return true", getList().addAll(getNumElements() / 2, new ARRAY_LISTBRACES(createDisjointCollection())));
|
||||
expectAdded(getNumElements() / 2, createDisjointCollection());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
|
||||
@CollectionSize.Require(absent = ZERO)
|
||||
#endignore
|
||||
public void testAddAllListAtIndex_end() {
|
||||
assertTrue("addAll(end, disjoint) should return true", getList().addAll(getNumElements(), new ARRAY_LISTBRACES(createDisjointCollection())));
|
||||
expectAdded(getNumElements(), createDisjointCollection());
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
|
||||
#endignore
|
||||
public void testAddAllListAtIndex_nullListReference() {
|
||||
try {
|
||||
getList().addAll(0, (LIST KEY_GENERIC_TYPE)null);
|
||||
fail("addAll(n, null) should throw");
|
||||
} catch (NullPointerException expected) {
|
||||
}
|
||||
expectUnchanged();
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
|
||||
#endignore
|
||||
public void testAddAllListAtIndex_negative() {
|
||||
try {
|
||||
getList().addAll(-1, ARRAY_LIST.wrap(e3()));
|
||||
fail("addAll(-1, e) should throw");
|
||||
} catch (IndexOutOfBoundsException expected) {
|
||||
}
|
||||
expectUnchanged();
|
||||
#if !TYPE_BOOLEAN
|
||||
expectMissing(e3());
|
||||
#endif
|
||||
}
|
||||
|
||||
#ignore
|
||||
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
|
||||
#endignore
|
||||
public void testAddAllListAtIndex_tooLarge() {
|
||||
try {
|
||||
getList().addAll(getNumElements() + 1, ARRAY_LIST.wrap(e3()));
|
||||
fail("addAll(size + 1, e) should throw");
|
||||
} catch (IndexOutOfBoundsException expected) {
|
||||
}
|
||||
expectUnchanged();
|
||||
#if !TYPE_BOOLEAN
|
||||
expectMissing(e3());
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue