Refactor of the Project on Github.
-Added: Better System to decide what code should be generated. -Added: Unit Tests are now included in the main branch. -Added: Automatic System to test the main branch and ensure that tests work. -Added: Pull Requests now run tests too.
This commit is contained in:
parent
ddc58ee221
commit
fb7c417394
|
@ -0,0 +1,34 @@
|
|||
name: Latest Build
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
jdk: [8, 11, 14, 16, 17]
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Set up JDK ${{ matrix.jdk }}
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: ${{ matrix.jdk }}
|
||||
distribution: temurin
|
||||
cache: gradle
|
||||
|
||||
- name: Validate Gradle wrapper
|
||||
uses: gradle/wrapper-validation-action@e6e38bacfdf1a337459f332974bb2327a31aaf4b
|
||||
|
||||
- name: Make gradlew executable
|
||||
run: chmod +x ./gradlew
|
||||
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew build
|
|
@ -0,0 +1,84 @@
|
|||
name: Unit Tests
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Unit Tests
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up JDK 11
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: 11
|
||||
cache: gradle
|
||||
|
||||
- name: Make gradlew executable
|
||||
run: chmod +x ./gradlew
|
||||
- name: Build and Test
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: ./gradlew generateTestSource test jacocoTestReport --info -Dfull_test_suite=true
|
||||
|
||||
- name: Publish Test Result
|
||||
uses: EnricoMi/publish-unit-test-result-action@v1
|
||||
id: test-results
|
||||
if: always()
|
||||
with:
|
||||
files: build/test-results/**/*.xml
|
||||
fail_on: nothing
|
||||
ignore_runs: true
|
||||
json_thousands_separator: .
|
||||
time_unit: milliseconds
|
||||
|
||||
- name: Create Badge Color
|
||||
shell: bash
|
||||
run: |
|
||||
case ${{ fromJSON( steps.test-results.outputs.json ).conclusion }} in
|
||||
success)
|
||||
echo "BADGE_COLOR=31c653" >> $GITHUB_ENV
|
||||
;;
|
||||
failure)
|
||||
echo "BADGE_COLOR=800000" >> $GITHUB_ENV
|
||||
;;
|
||||
neutral)
|
||||
echo "BADGE_COLOR=696969" >> $GITHUB_ENV
|
||||
;;
|
||||
esac
|
||||
|
||||
- name: Create Test Badge
|
||||
uses: emibcn/badge-action@v1.2.4
|
||||
with:
|
||||
label: Tests
|
||||
status: '${{ fromJSON( steps.test-results.outputs.json ).conclusion }}, Passed: ${{ fromJSON( steps.test-results.outputs.json ).formatted.stats.tests_succ }}, Skipped: ${{ fromJSON( steps.test-results.outputs.json ).formatted.stats.tests_skip }}, Failed: ${{ fromJSON( steps.test-results.outputs.json ).formatted.stats.tests_fail }}'
|
||||
color: ${{ env.BADGE_COLOR }}
|
||||
path: tests.svg
|
||||
|
||||
- name: Create Coverage Badge
|
||||
id: jacoco
|
||||
uses: cicirello/jacoco-badge-generator@v2
|
||||
with:
|
||||
jacoco-csv-file: build/reports/jacoco/test/jacocoTestReport.csv
|
||||
badges-directory: null
|
||||
intervals: 95 80 70 60 50 0
|
||||
|
||||
- name: Upload Test Badge
|
||||
uses: exuanbo/actions-deploy-gist@v1
|
||||
with:
|
||||
token: ${{ secrets.GIST_TOKEN }}
|
||||
gist_id: 280257cd19cbe1dda3789bebd4ff65cf
|
||||
file_path: tests.svg
|
||||
|
||||
- name: Upload Coverage Badge
|
||||
uses: exuanbo/actions-deploy-gist@v1
|
||||
with:
|
||||
token: ${{ secrets.GIST_TOKEN }}
|
||||
gist_id: 280257cd19cbe1dda3789bebd4ff65cf
|
||||
file_path: jacoco.svg
|
|
@ -1,36 +0,0 @@
|
|||
# This workflow uses actions that are not certified by GitHub.
|
||||
# They are provided by a third-party and are governed by
|
||||
# separate terms of service, privacy policy, and support
|
||||
# documentation.
|
||||
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
|
||||
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
|
||||
|
||||
name: Latest Build
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
jdk: [8, 11, 14, 16, 17]
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up JDK ${{ matrix.jdk }}
|
||||
uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: ${{ matrix.jdk }}
|
||||
- name: Validate Gradle wrapper
|
||||
uses: gradle/wrapper-validation-action@e6e38bacfdf1a337459f332974bb2327a31aaf4b
|
||||
- name: Make gradlew executable
|
||||
run: chmod +x ./gradlew
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew build
|
|
@ -0,0 +1,39 @@
|
|||
name: Unit Tests
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Unit Tests
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up JDK 11
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: 11
|
||||
cache: gradle
|
||||
|
||||
- name: Make gradlew executable
|
||||
run: chmod +x ./gradlew
|
||||
- name: Build and Test
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: ./gradlew generateTestSource test jacocoTestReport --info -Dfull_test_suite=true
|
||||
|
||||
- name: Publish Test Result
|
||||
uses: EnricoMi/publish-unit-test-result-action@v1
|
||||
id: test-results
|
||||
if: always()
|
||||
with:
|
||||
files: build/test-results/**/*.xml
|
||||
fail_on: nothing
|
||||
ignore_runs: true
|
||||
json_thousands_separator: .
|
||||
time_unit: milliseconds
|
|
@ -30,5 +30,19 @@ gradle-app.setting
|
|||
/src/main/java/speiger/src/collections/doubles/*
|
||||
/src/main/java/speiger/src/collections/objects/*
|
||||
|
||||
#Generated Tests
|
||||
/src/test/java/speiger/src/testers/booleans/*
|
||||
/src/test/java/speiger/src/testers/bytes/*
|
||||
/src/test/java/speiger/src/testers/shorts/*
|
||||
/src/test/java/speiger/src/testers/chars/*
|
||||
/src/test/java/speiger/src/testers/ints/*
|
||||
/src/test/java/speiger/src/testers/longs/*
|
||||
/src/test/java/speiger/src/testers/floats/*
|
||||
/src/test/java/speiger/src/testers/doubles/*
|
||||
/src/test/java/speiger/src/testers/objects/*
|
||||
/src/test/java/speiger/src/tests/*
|
||||
|
||||
#Cache result
|
||||
/src/builder/resources/speiger/assets/collections/cache.bin
|
||||
/src/builder/resources/speiger/assets/testers/cache.bin
|
||||
/src/builder/resources/speiger/assets/tests/cache.bin
|
||||
|
|
159
build.gradle
159
build.gradle
|
@ -1,5 +1,6 @@
|
|||
plugins {
|
||||
id 'java-library'
|
||||
id "jacoco"
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
|
@ -62,7 +63,7 @@ task generateGithubSource(type: JavaExec) {
|
|||
description = 'Builds the sourcecode for Github Actions'
|
||||
classpath = sourceSets.builder.runtimeClasspath
|
||||
main = 'speiger.src.builder.PrimitiveCollectionsBuilder'
|
||||
args = ['false', 'true']
|
||||
args = ['silent']
|
||||
}
|
||||
|
||||
task forceGenerateSource(type: JavaExec) {
|
||||
|
@ -70,7 +71,15 @@ task forceGenerateSource(type: JavaExec) {
|
|||
description = 'Builds the sourcecode forceful'
|
||||
classpath = sourceSets.builder.runtimeClasspath
|
||||
main = 'speiger.src.builder.PrimitiveCollectionsBuilder'
|
||||
args = ['true']
|
||||
args = ['force']
|
||||
}
|
||||
|
||||
task generateTestSource(type: JavaExec) {
|
||||
group = 'internal'
|
||||
description = 'Builds the sourcecode for the Tests'
|
||||
classpath = sourceSets.builder.runtimeClasspath
|
||||
main = 'speiger.src.builder.PrimitiveCollectionsBuilder'
|
||||
args = ['tests']
|
||||
}
|
||||
|
||||
task javadocJar(type: Jar) {
|
||||
|
@ -94,8 +103,152 @@ artifacts {
|
|||
archives srcJar
|
||||
}
|
||||
|
||||
task testBooleans(type: Test) {
|
||||
group 'tests'
|
||||
description 'Tests all Boolean Collections'
|
||||
filter {
|
||||
excludeTestsMatching "speiger.src.testers.**.*"
|
||||
includeTestsMatching "speiger.src.tests.booleans.**.*"
|
||||
}
|
||||
useJUnit()
|
||||
ignoreFailures = true
|
||||
maxHeapSize = "1024m"
|
||||
}
|
||||
|
||||
task testBytes(type: Test) {
|
||||
group 'tests'
|
||||
description 'Tests all Byte Collections'
|
||||
filter {
|
||||
excludeTestsMatching "speiger.src.testers.**.*"
|
||||
includeTestsMatching "speiger.src.tests.bytes.**.*"
|
||||
}
|
||||
useJUnit()
|
||||
ignoreFailures = true
|
||||
maxHeapSize = "1024m"
|
||||
maxParallelForks = 2
|
||||
}
|
||||
|
||||
task testShorts(type: Test) {
|
||||
group 'tests'
|
||||
description 'Tests all Short Collections'
|
||||
filter {
|
||||
excludeTestsMatching "speiger.src.testers.**.*"
|
||||
includeTestsMatching "speiger.src.tests.shorts.**.*"
|
||||
}
|
||||
useJUnit()
|
||||
ignoreFailures = true
|
||||
maxHeapSize = "1024m"
|
||||
maxParallelForks = 2
|
||||
}
|
||||
|
||||
task testChars(type: Test) {
|
||||
group 'tests'
|
||||
description 'Tests all Character Collections'
|
||||
filter {
|
||||
excludeTestsMatching "speiger.src.testers.**.*"
|
||||
includeTestsMatching "speiger.src.tests.chars.**.*"
|
||||
}
|
||||
useJUnit()
|
||||
ignoreFailures = true
|
||||
maxHeapSize = "1024m"
|
||||
maxParallelForks = 2
|
||||
}
|
||||
|
||||
task testInts(type: Test) {
|
||||
group 'tests'
|
||||
description 'Tests all Int Collections'
|
||||
filter {
|
||||
excludeTestsMatching "speiger.src.testers.**.*"
|
||||
includeTestsMatching "speiger.src.tests.ints.**.*"
|
||||
}
|
||||
useJUnit()
|
||||
ignoreFailures = true
|
||||
maxHeapSize = "1024m"
|
||||
maxParallelForks = 2
|
||||
}
|
||||
|
||||
task testLongs(type: Test) {
|
||||
group 'tests'
|
||||
description 'Tests all Long Collections'
|
||||
filter {
|
||||
excludeTestsMatching "speiger.src.testers.**.*"
|
||||
includeTestsMatching "speiger.src.tests.longs.**.*"
|
||||
}
|
||||
useJUnit()
|
||||
ignoreFailures = true
|
||||
maxHeapSize = "1024m"
|
||||
maxParallelForks = 2
|
||||
}
|
||||
|
||||
task testFloats(type: Test) {
|
||||
group 'tests'
|
||||
description 'Tests all Float Collections'
|
||||
filter {
|
||||
excludeTestsMatching "speiger.src.testers.**.*"
|
||||
includeTestsMatching "speiger.src.tests.floats.**.*"
|
||||
}
|
||||
useJUnit()
|
||||
ignoreFailures = true
|
||||
maxHeapSize = "1024m"
|
||||
maxParallelForks = 2
|
||||
}
|
||||
|
||||
task testDoubles(type: Test) {
|
||||
group 'tests'
|
||||
description 'Tests all Double Collections'
|
||||
filter {
|
||||
excludeTestsMatching "speiger.src.testers.**.*"
|
||||
includeTestsMatching "speiger.src.tests.doubles.**.*"
|
||||
}
|
||||
useJUnit()
|
||||
ignoreFailures = true
|
||||
maxHeapSize = "1024m"
|
||||
maxParallelForks = 2
|
||||
}
|
||||
|
||||
task testObjects(type: Test) {
|
||||
group 'tests'
|
||||
description 'Tests all Object Collections'
|
||||
filter {
|
||||
excludeTestsMatching "speiger.src.testers.**.*"
|
||||
includeTestsMatching "speiger.src.tests.objects.**.*"
|
||||
}
|
||||
useJUnit()
|
||||
ignoreFailures = true
|
||||
maxHeapSize = "1024m"
|
||||
maxParallelForks = 2
|
||||
}
|
||||
|
||||
if(System.getProperty("full_test_suite", "false").toBoolean()) {
|
||||
test.dependsOn testBooleans
|
||||
test.dependsOn testBytes
|
||||
test.dependsOn testShorts
|
||||
test.dependsOn testChars
|
||||
test.dependsOn testInts
|
||||
test.dependsOn testLongs
|
||||
test.dependsOn testFloats
|
||||
test.dependsOn testDoubles
|
||||
test.dependsOn testObjects
|
||||
}
|
||||
|
||||
test {
|
||||
useJUnit()
|
||||
filter {
|
||||
excludeTestsMatching "speiger.src.testers.**.*"
|
||||
excludeTestsMatching "speiger.src.tests.**.*"
|
||||
excludeTestsMatching "tests.**.*"
|
||||
}
|
||||
useJUnit()
|
||||
ignoreFailures = true
|
||||
maxHeapSize = "1024m"
|
||||
}
|
||||
|
||||
jacocoTestReport {
|
||||
executionData fileTree(project.buildDir.absolutePath).include("jacoco/*.exec")
|
||||
reports {
|
||||
xml.enabled true
|
||||
html.enabled = true
|
||||
csv.enabled true
|
||||
}
|
||||
}
|
||||
|
||||
publishing {
|
||||
|
|
|
@ -3,15 +3,15 @@ package speiger.src.builder;
|
|||
@SuppressWarnings("javadoc")
|
||||
public enum ClassType
|
||||
{
|
||||
BOOLEAN("boolean", "Boolean", "Boolean", "booleans", "BOOLEAN", "false"),
|
||||
BYTE("byte", "Byte", "Byte", "bytes", "BYTE", "(byte)0"),
|
||||
SHORT("short", "Short", "Short", "shorts", "SHORT", "(short)0"),
|
||||
CHAR("char", "Character", "Char", "chars", "CHAR", "(char)0"),
|
||||
INT("int", "Integer", "Int", "ints", "INT", "0"),
|
||||
LONG("long", "Long", "Long", "longs", "LONG", "0L"),
|
||||
FLOAT("float", "Float", "Float", "floats", "FLOAT", "0F"),
|
||||
DOUBLE("double", "Double", "Double", "doubles", "DOUBLE", "0D"),
|
||||
OBJECT("T", "T", "Object", "objects", "OBJECT", "null");
|
||||
BOOLEAN("boolean", "Boolean", "Boolean", "booleans", "BOOLEAN", "false", "false"),
|
||||
BYTE("byte", "Byte", "Byte", "bytes", "BYTE", "(byte)0", "(byte)-1"),
|
||||
SHORT("short", "Short", "Short", "shorts", "SHORT", "(short)0", "(short)-1"),
|
||||
CHAR("char", "Character", "Char", "chars", "CHAR", "(char)0", "(char)-1"),
|
||||
INT("int", "Integer", "Int", "ints", "INT", "0", "-1"),
|
||||
LONG("long", "Long", "Long", "longs", "LONG", "0L", "-1L"),
|
||||
FLOAT("float", "Float", "Float", "floats", "FLOAT", "0F", "-1F"),
|
||||
DOUBLE("double", "Double", "Double", "doubles", "DOUBLE", "0D", "-1D"),
|
||||
OBJECT("T", "T", "Object", "objects", "OBJECT", "null", "null");
|
||||
|
||||
String keyType;
|
||||
String classType;
|
||||
|
@ -19,8 +19,9 @@ public enum ClassType
|
|||
String pathType;
|
||||
String capType;
|
||||
String emptyValue;
|
||||
String invalidValue;
|
||||
|
||||
private ClassType(String keyType, String classType, String fileType, String pathType, String capType, String emptyValue)
|
||||
private ClassType(String keyType, String classType, String fileType, String pathType, String capType, String emptyValue, String invalidValue)
|
||||
{
|
||||
this.keyType = keyType;
|
||||
this.classType = classType;
|
||||
|
@ -28,6 +29,7 @@ public enum ClassType
|
|||
this.pathType = pathType;
|
||||
this.capType = capType;
|
||||
this.emptyValue = emptyValue;
|
||||
this.invalidValue = invalidValue;
|
||||
}
|
||||
|
||||
public String getKeyType()
|
||||
|
@ -90,6 +92,11 @@ public enum ClassType
|
|||
return emptyValue;
|
||||
}
|
||||
|
||||
public String getInvalidValue()
|
||||
{
|
||||
return invalidValue;
|
||||
}
|
||||
|
||||
public boolean isObject()
|
||||
{
|
||||
return this == OBJECT;
|
||||
|
|
|
@ -35,21 +35,43 @@ public class GlobalVariables
|
|||
addSimpleMapper("CLASS_TYPE", type.getClassType());
|
||||
addSimpleMapper("CLASS_VALUE_TYPE", valueType.getClassValueType());
|
||||
addSimpleMapper("KEY_TYPE", type.getKeyType());
|
||||
addSimpleMapper("KEY_OBJECT_TYPE", type.isObject() ? "Object" : type.getKeyType());
|
||||
addSimpleMapper("KEY_STRING_TYPE", type.isObject() ? "String" : type.getKeyType());
|
||||
addSimpleMapper("KEY_SPECIAL_TYPE", type.isObject() ? "E" : type.getKeyType());
|
||||
addSimpleMapper("CLASS_OBJECT_TYPE", type.getClassType());
|
||||
addSimpleMapper("CLASS_OBJECT_VALUE_TYPE", valueType.getClassValueType());
|
||||
addSimpleMapper("CLASS_STRING_TYPE", type.isObject() ? "String" : type.getClassType());
|
||||
addSimpleMapper("CLASS_STRING_VALUE_TYPE", valueType.isObject() ? "String" : valueType.getClassValueType());
|
||||
addSimpleMapper("VALUE_TYPE", valueType.getValueType());
|
||||
addSimpleMapper("VALUE_OBJECT_TYPE", valueType.isObject() ? "Object" : valueType.getValueType());
|
||||
addSimpleMapper("VALUE_STRING_TYPE", valueType.isObject() ? "String" : valueType.getValueType());
|
||||
addSimpleMapper("VALUE_SPECIAL_TYPE", valueType.isObject() ? "E" : valueType.getKeyType());
|
||||
addSimpleMapper("KEY_JAVA_TYPE", type.getCustomJDKType().getKeyType());
|
||||
addSimpleMapper("VALUE_JAVA_TYPE", type.getCustomJDKType().getKeyType());
|
||||
|
||||
addSimpleMapper("EMPTY_KEY_VALUE", type.getEmptyValue());
|
||||
addSimpleMapper("EMPTY_VALUE", valueType.getEmptyValue());
|
||||
|
||||
addSimpleMapper("INVALID_KEY_VALUE", type.getInvalidValue());
|
||||
addSimpleMapper("INVALID_VALUE", valueType.getInvalidValue());
|
||||
|
||||
addSimpleMapper(" KEY_STRING_GENERIC_TYPE", type.isObject() ? "<String>" : "");
|
||||
addSimpleMapper(" VALUE_STRING_GENERIC_TYPE", valueType.isObject() ? "<String>" : "");
|
||||
addSimpleMapper(" KEY_VALUE_STRING_GENERIC_TYPE", type.isObject() ? (valueType.isObject() ? "<String, String>" : "<String>") : (valueType.isObject() ? "<String>" : ""));
|
||||
|
||||
|
||||
addSimpleMapper(" KEY_GENERIC_TYPE", type.isObject() ? "<"+type.getKeyType()+">" : "");
|
||||
addSimpleMapper(" KEY_KEY_GENERIC_TYPE", type.isObject() ? "<"+type.getKeyType()+", "+type.getKeyType()+">" : "");
|
||||
addSimpleMapper(" KEY_CLASS_GENERIC_TYPE", type.isObject() ? "<"+type.getClassType()+">" : "");
|
||||
|
||||
|
||||
addSimpleMapper(" VALUE_GENERIC_TYPE", valueType.isObject() ? "<"+valueType.getValueType()+">" : "");
|
||||
addSimpleMapper(" VALUE_VALUE_GENERIC_TYPE", valueType.isObject() ? "<"+valueType.getValueType()+", "+valueType.getValueType()+">" : "");
|
||||
addSimpleMapper(" VALUE_CLASS_GENERIC_TYPE", valueType.isObject() ? "<"+valueType.getClassValueType()+">" : "");
|
||||
|
||||
addSimpleMapper(" KEY_VALUE_GENERIC_TYPE", type.isObject() ? (valueType.isObject() ? "<"+type.getKeyType()+", "+valueType.getValueType()+">" : "<"+type.getKeyType()+">") : (valueType.isObject() ? "<"+valueType.getValueType()+">" : ""));
|
||||
addSimpleMapper(" KEY_VALUE_VALUE_GENERIC_TYPE", type.isObject() ? (valueType.isObject() ? "<"+type.getKeyType()+", "+valueType.getValueType()+", "+valueType.getValueType()+">" : "<"+type.getKeyType()+">") : (valueType.isObject() ? "<"+valueType.getValueType()+", "+valueType.getValueType()+">" : ""));
|
||||
addInjectMapper(" KEY_VALUE_SPECIAL_GENERIC_TYPE", type.isObject() ? (valueType.isObject() ? "<"+type.getKeyType()+", "+valueType.getValueType()+", %s>" : "<"+type.getKeyType()+", %s>") : (valueType.isObject() ? "<"+valueType.getValueType()+", %s>" : "<%s>")).setBraceType("<>").removeBraces();
|
||||
|
||||
addSimpleMapper(" NO_GENERIC_TYPE", type.isObject() ? "<?>" : "");
|
||||
addSimpleMapper(" NO_KV_GENERIC_TYPE", type.isObject() ? (valueType.isObject() ? "<?, ?>" : "<?>") : valueType.isObject() ? "<?>" : "");
|
||||
|
@ -59,6 +81,10 @@ public class GlobalVariables
|
|||
addSimpleMapper(" VALUE_SUPER_GENERIC_TYPE", valueType.isObject() ? "<? super "+valueType.getValueType()+">" : "");
|
||||
addSimpleMapper(" KEY_VALUE_SUPER_GENERIC_TYPE", type.isObject() ? (valueType.isObject() ? "<? super "+type.getKeyType()+", ? super "+valueType.getValueType()+">" : "<? super "+type.getKeyType()+">") : (valueType.isObject() ? "<? super "+valueType.getValueType()+">" : ""));
|
||||
|
||||
addSimpleMapper(" KEY_UNKNOWN_GENERIC_TYPE", type.isObject() ? "<? extends "+type.getKeyType()+">" : "");
|
||||
addSimpleMapper(" VALUE_UNKNOWN_GENERIC_TYPE", valueType.isObject() ? "<? extends "+valueType.getValueType()+">" : "");
|
||||
addSimpleMapper(" KEY_VALUE_UNKNOWN_GENERIC_TYPE", type.isObject() ? (valueType.isObject() ? "<? extends "+type.getKeyType()+", ? extends "+valueType.getValueType()+">" : "<? extends "+type.getKeyType()+">") : (valueType.isObject() ? "<? extends "+valueType.getValueType()+">" : ""));
|
||||
|
||||
addSimpleMapper(" KEY_ENUM_VALUE_GENERIC_TYPE", type.isObject() ? (valueType.isObject() ? "<"+type.getKeyType()+" extends Enum<"+type.getKeyType()+">, "+valueType.getValueType()+">" : "<"+type.getKeyType()+" extends Enum<"+type.getKeyType()+">>") : (valueType.isObject() ? "<"+valueType.getValueType()+">" : ""));
|
||||
addSimpleMapper(" KEY_VALUE_ENUM_GENERIC_TYPE", type.isObject() ? (valueType.isObject() ? "<"+type.getKeyType()+", "+valueType.getValueType()+" extends Enum<"+valueType.getValueType()+">>" : "<"+type.getKeyType()+">") : (valueType.isObject() ? "<"+valueType.getValueType()+" extends Enum<"+valueType.getValueType()+">>" : ""));
|
||||
|
||||
|
@ -83,6 +109,7 @@ public class GlobalVariables
|
|||
addSimpleMapper(" GENERIC_KEY_VALUE_BRACES", type.isObject() ? (valueType.isObject() ? " <"+type.getKeyType()+", "+valueType.getValueType()+">" : " <"+type.getKeyType()+">") : (valueType.isObject() ? " <"+valueType.getValueType()+">" : ""));
|
||||
addSimpleMapper(" COMPAREABLE_KEY_BRACES", type.isObject() ? " <"+type.getKeyType()+" extends Comparable<T>>" : "");
|
||||
addSimpleMapper("KV_BRACES", type.isObject() || valueType.isObject() ? "<>" : "");
|
||||
addSimpleMapper("VALUE_BRACES", valueType.isObject() ? "<>" : "");
|
||||
addSimpleMapper("BRACES", type.isObject() ? "<>" : "");
|
||||
if(type.needsCustomJDKType())
|
||||
{
|
||||
|
@ -120,6 +147,7 @@ public class GlobalVariables
|
|||
addInjectMapper(fix+"_EQUALS_NULL", type.getComparableValue()+" == "+(type.isPrimitiveBlocking() || type.needsCast() ? type.getEmptyValue() : "0")).removeBraces();
|
||||
addArgumentMapper(fix+"_EQUALS_NOT", type.getEquals(true)).removeBraces();
|
||||
addArgumentMapper(fix+"_EQUALS", type.getEquals(false)).removeBraces();
|
||||
addSimpleMapper("FILE_"+fix+"_TYPE", type.getFileType());
|
||||
|
||||
addArgumentMapper("COMPAREABLE_TO_"+fix, type.isObject() ? "((Comparable<"+type.getKeyType(value)+">)%1$s).compareTo(("+type.getKeyType(value)+")%2$s)" : type.getClassType(value)+".compare(%1$s, %2$s)").removeBraces();
|
||||
addArgumentMapper("COMPARE_TO_"+fix, type.isObject() ? "%1$s.compareTo(%2$s)" : type.getClassType(value)+".compare(%1$s, %2$s)").removeBraces();
|
||||
|
@ -135,7 +163,8 @@ public class GlobalVariables
|
|||
addSimpleMapper("EMPTY_"+fix+"_ARRAY", type.isObject() ? "("+fix+"_TYPE[])ARRAYS.EMPTY_ARRAY" : "ARRAYS.EMPTY_ARRAY");
|
||||
addInjectMapper("NEW_"+fix+"_ARRAY", type.isObject() ? "("+fix+"_TYPE[])new Object[%s]" : "new "+fix+"_TYPE[%s]").removeBraces();
|
||||
addInjectMapper("NEW_SPECIAL_"+fix+"_ARRAY", type.isObject() ? "(E[])new Object[%s]" : "new "+fix+"_TYPE[%s]").removeBraces();
|
||||
addInjectMapper("NEW_CLASS"+(value ? "_VALUE" : "")+"_ARRAY", type.isObject() ? "(CLASS_TYPE[])new Object[%s]" : "new CLASS_TYPE[%s]").removeBraces();
|
||||
if(value) addInjectMapper("NEW_CLASS_VALUE_ARRAY", type.isObject() ? "(CLASS_VALUE_TYPE[])new Object[%s]" : "new CLASS_VALUE_TYPE[%s]").removeBraces();
|
||||
else addInjectMapper("NEW_CLASS_ARRAY", type.isObject() ? "(CLASS_TYPE[])new Object[%s]" : "new CLASS_TYPE[%s]").removeBraces();
|
||||
}
|
||||
|
||||
public GlobalVariables createPreFunctions()
|
||||
|
@ -186,7 +215,43 @@ public class GlobalVariables
|
|||
addClassMapper("RB_TREE_SET", "RBTreeSet");
|
||||
addClassMapper("AVL_TREE_SET", "AVLTreeSet");
|
||||
addClassMapper("ARRAY_SET", "ArraySet");
|
||||
addAbstractBiMapper("SIMPLE_TEST_MAP", "Test%sMap", "2");
|
||||
|
||||
//Final UnitTest Classes
|
||||
addAbstractMapper("MINIMAL_COLLECTION", "Minimal%sCollection");
|
||||
addAbstractMapper("MINIMAL_SET", "Minimal%sSet");
|
||||
addAbstractMapper("ABSTRACT_CONTAINER_TESTER", "Abstract%sContainerTester");
|
||||
addAbstractMapper("ABSTRACT_COLLECTION_TESTER", "Abstract%sCollectionTester");
|
||||
addAbstractMapper("ABSTRACT_QUEUE_TESTER", "Abstract%sQueueTester");
|
||||
addAbstractMapper("ABSTRACT_LIST_INDEX_OF_TESTER", "Abstract%sListIndexOfTester");
|
||||
addAbstractMapper("ABSTRACT_LIST_TESTER", "Abstract%sListTester");
|
||||
addAbstractMapper("ABSTRACT_SET_TESTER", "Abstract%sSetTester");
|
||||
addAbstractMapper("ABSTRACT_ITERATOR_TESTER", "Abstract%sIteratorTester");
|
||||
addAbstractBiMapper("ABSTRACT_MAP_TESTER", "Abstract%sMapTester", "2");
|
||||
addClassMapper("LIST_ITERATOR_TESTER", "ListIteratorTester");
|
||||
addClassMapper("BIDIRECTIONAL_ITERATOR_TESTER", "BidirectionalteratorTester");
|
||||
addClassMapper("ITERATOR_TESTER", "IteratorTester");
|
||||
addClassMapper("COLLECTION_TEST_BUILDER", "CollectionTestSuiteBuilder");
|
||||
addClassMapper("DEQUEUE_TEST_BUILDER", "DequeueTestSuiteBuilder");
|
||||
addClassMapper("QUEUE_TEST_BUILDER", "QueueTestSuiteBuilder");
|
||||
addClassMapper("LIST_TEST_BUILDER", "ListTestSuiteBuilder");
|
||||
addClassMapper("ORDERED_SET_TEST_BUILDER", "OrderedSetTestSuiteBuilder");
|
||||
addClassMapper("SORTED_SET_TEST_BUILDER", "SortedSetTestSuiteBuilder");
|
||||
addClassMapper("NAVIGABLE_SET_TEST_BUILDER", "NavigableSetTestSuiteBuilder");
|
||||
addClassMapper("SET_TEST_BUILDER", "SetTestSuiteBuilder");
|
||||
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");
|
||||
addAbstractBiMapper("MAP_CONSTRUCTOR_TESTS", "%sMapConstructorTests", "2");
|
||||
addClassMapper("COLLECTION_CONSTRUCTOR_TESTS", "CollectionConstructorTests");
|
||||
addClassMapper("SUB_SORTED_SET_CLASS_GENERATOR", "SortedSetSubsetTestSetGenerator");
|
||||
addClassMapper("SUB_NAVIGABLE_SET_CLASS_GENERATOR", "NavigableSetSubsetTestSetGenerator");
|
||||
addClassMapper("LIST_TESTS", "ListTests");
|
||||
addClassMapper("SET_TESTS", "SetTests");
|
||||
addClassMapper("QUEUE_TESTS", "QueueTests");
|
||||
addBiClassMapper("MAP_TESTS", "MapTests", "2");
|
||||
|
||||
//Abstract Classes
|
||||
addAbstractMapper("ABSTRACT_COLLECTION", "Abstract%sCollection");
|
||||
addAbstractMapper("ABSTRACT_PRIORITY_QUEUE", "Abstract%sPriorityQueue");
|
||||
|
@ -206,6 +271,24 @@ public class GlobalVariables
|
|||
addClassMapper("ITERATORS", "Iterators");
|
||||
addClassMapper("ITERABLES", "Iterables");
|
||||
addBiClassMapper("MAPS", "Maps", "2");
|
||||
addClassMapper("SAMPLE_ELEMENTS", "Samples");
|
||||
|
||||
//UnitTest Helper Classes
|
||||
addClassMapper("HELPERS", "Helpers");
|
||||
addAbstractMapper("TEST_COLLECTION_GENERATOR", "Test%sCollectionGenerator");
|
||||
addAbstractMapper("TEST_QUEUE_GENERATOR", "Test%sQueueGenerator");
|
||||
addAbstractMapper("TEST_LIST_GENERATOR", "Test%sListGenerator");
|
||||
addAbstractMapper("TEST_NAVIGABLE_SET_GENERATOR", "Test%sNavigableSetGenerator");
|
||||
addAbstractMapper("TEST_SORTED_SET_GENERATOR", "Test%sSortedSetGenerator");
|
||||
addAbstractMapper("TEST_ORDERED_SET_GENERATOR", "Test%sOrderedSetGenerator");
|
||||
addAbstractMapper("TEST_SET_GENERATOR", "Test%sSetGenerator");
|
||||
addAbstractMapper("SIMPLE_TEST_GENERATOR", "Simple%sTestGenerator");
|
||||
addAbstractMapper("SIMPLE_QUEUE_TEST_GENERATOR", "Simple%sQueueTestGenerator");
|
||||
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");
|
||||
|
||||
//Interfaces
|
||||
addClassMapper("LIST_ITERATOR", "ListIterator");
|
||||
|
@ -245,7 +328,6 @@ public class GlobalVariables
|
|||
if(!valueType.isObject()) addSimpleMapper("VALUE_CONSUMER", valueType.getFileType()+"Consumer");
|
||||
else addSimpleMapper("VALUE_CONSUMER", "Consumer");
|
||||
addSimpleMapper("CONSUMER", "Consumer");
|
||||
addSimpleMapper("COMPARATOR", "Comparator");
|
||||
addSimpleMapper("IARRAY", "IObjectArray");
|
||||
}
|
||||
else
|
||||
|
@ -256,9 +338,10 @@ public class GlobalVariables
|
|||
addSimpleMapper("CONSUMER", type.getFileType()+"Consumer");
|
||||
}
|
||||
else addClassMapper("CONSUMER", "Consumer");
|
||||
addClassMapper("COMPARATOR", "Comparator");
|
||||
addFunctionMappers("IARRAY", "I%sArray");
|
||||
}
|
||||
addSimpleMapper("VALUE_COMPARATOR", valueType.isObject() ? "Comparator" : String.format("%sComparator", valueType.getNonFileType()));
|
||||
addSimpleMapper("COMPARATOR", type.isObject() ? "Comparator" : String.format("%sComparator", type.getNonFileType()));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -308,6 +391,7 @@ public class GlobalVariables
|
|||
addSimpleMapper("VALUE_TEST_VALUE", valueType.isObject() ? "getBoolean" : "get");
|
||||
addSimpleMapper("TEST_VALUE", type.isObject() ? "getBoolean" : "get");
|
||||
addSimpleMapper("NEW_STREAM", type.isPrimitiveBlocking() ? "" : type.getCustomJDKType().getKeyType()+"Stream");
|
||||
addSimpleMapper("VALUE_TO_ARRAY", "to"+valueType.getNonFileType()+"Array");
|
||||
addSimpleMapper("TO_ARRAY", "to"+type.getNonFileType()+"Array");
|
||||
addSimpleMapper("[SPACE]", " ");
|
||||
return this;
|
||||
|
|
|
@ -6,6 +6,8 @@ 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.EnumMap;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
@ -14,6 +16,7 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
import java.util.StringJoiner;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import speiger.src.builder.processor.TemplateProcess;
|
||||
|
@ -23,6 +26,7 @@ import speiger.src.builder.processor.TemplateProcessor;
|
|||
public class PrimitiveCollectionsBuilder extends TemplateProcessor
|
||||
{
|
||||
Map<String, EnumSet<ClassType>> blocked = new HashMap<>();
|
||||
EnumMap<ClassType, List<Predicate<String>>> blockedPredicate = new EnumMap<>(ClassType.class);
|
||||
Map<String, String> nameRemapper = new HashMap<>();
|
||||
Map<String, String> biRequired = new HashMap<>();
|
||||
Set<String> enumRequired = new HashSet<>();
|
||||
|
@ -30,6 +34,7 @@ public class PrimitiveCollectionsBuilder extends TemplateProcessor
|
|||
List<GlobalVariables> variables = new ArrayList<>();
|
||||
List<GlobalVariables> biVariables = new ArrayList<>();
|
||||
List<GlobalVariables> enumVariables = new ArrayList<>();
|
||||
boolean special = false;
|
||||
|
||||
public PrimitiveCollectionsBuilder()
|
||||
{
|
||||
|
@ -51,6 +56,19 @@ public class PrimitiveCollectionsBuilder extends TemplateProcessor
|
|||
super(silencedSuccess, sourceFolder, outputFolder, dataFolder);
|
||||
}
|
||||
|
||||
private PrimitiveCollectionsBuilder setSpecial() {
|
||||
special = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
private static PrimitiveCollectionsBuilder createTests(boolean silent) {
|
||||
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/")).setSpecial();
|
||||
}
|
||||
|
||||
private static PrimitiveCollectionsBuilder createTesters(boolean silent) {
|
||||
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/")).setSpecial();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isFileValid(Path fileName)
|
||||
{
|
||||
|
@ -72,7 +90,7 @@ public class PrimitiveCollectionsBuilder extends TemplateProcessor
|
|||
@Override
|
||||
protected void afterFinish()
|
||||
{
|
||||
if(getVersion() > 8)
|
||||
if(!special && getVersion() > 8)
|
||||
{
|
||||
Path basePath = Paths.get("src/main/java");
|
||||
try(BufferedWriter writer = Files.newBufferedWriter(basePath.resolve("module-info.java")))
|
||||
|
@ -119,9 +137,50 @@ public class PrimitiveCollectionsBuilder extends TemplateProcessor
|
|||
nameRemapper.put("ImmutableOpenHashSet", "Immutable%sOpenHashSet");
|
||||
nameRemapper.put("ImmutableOpenHashMap", "Immutable%sOpenHashMap");
|
||||
|
||||
|
||||
addBlockage(ClassType.OBJECT, "Consumer", "Comparator", "Stack");
|
||||
addBlockage(ClassType.BOOLEAN, "ArraySet", "AVLTreeSet", "RBTreeSet", "SortedSet", "OrderedSet", "NavigableSet", "OpenHashSet", "OpenCustomHashSet", "LinkedOpenHashSet", "LinkedOpenCustomHashSet");
|
||||
addBlockage(ClassType.BOOLEAN, "ConcurrentOpenHashMap", "ImmutableOpenHashMap", "ImmutableOpenHashSet", "SortedMap", "OrderedMap", "NavigableMap", "ConcurrentMap", "OpenHashMap", "LinkedOpenHashMap", "OpenCustomHashMap", "LinkedOpenCustomHashMap", "ArrayMap", "RBTreeMap", "AVLTreeMap");
|
||||
|
||||
//UnitTesters
|
||||
nameRemapper.put("AbstractIteratorTester", "Abstract%sIteratorTester");
|
||||
nameRemapper.put("MinimalCollection", "Minimal%sCollection");
|
||||
nameRemapper.put("MinimalSet", "Minimal%sSet");
|
||||
nameRemapper.put("TestCollectionGenerator", "Test%sCollectionGenerator");
|
||||
nameRemapper.put("TestQueueGenerator", "Test%sQueueGenerator");
|
||||
nameRemapper.put("TestListGenerator", "Test%sListGenerator");
|
||||
nameRemapper.put("TestNavigableSetGenerator", "Test%sNavigableSetGenerator");
|
||||
nameRemapper.put("TestSortedSetGenerator", "Test%sSortedSetGenerator");
|
||||
nameRemapper.put("TestOrderedSetGenerator", "Test%sOrderedSetGenerator");
|
||||
nameRemapper.put("TestSetGenerator", "Test%sSetGenerator");
|
||||
nameRemapper.put("AbstractContainerTester", "Abstract%sContainerTester");
|
||||
nameRemapper.put("AbstractCollectionTester", "Abstract%sCollectionTester");
|
||||
nameRemapper.put("AbstractQueueTester", "Abstract%sQueueTester");
|
||||
nameRemapper.put("AbstractListTester", "Abstract%sListTester");
|
||||
nameRemapper.put("AbstractListIndexOfTester", "Abstract%sListIndexOfTester");
|
||||
nameRemapper.put("AbstractSetTester", "Abstract%sSetTester");
|
||||
nameRemapper.put("SimpleTestGenerator", "Simple%sTestGenerator");
|
||||
nameRemapper.put("SimpleQueueTestGenerator", "Simple%sQueueTestGenerator");
|
||||
nameRemapper.put("TestMapGenerator", "Test%sMapGenerator");
|
||||
nameRemapper.put("TestSortedMapGenerator", "Test%sSortedMapGenerator");
|
||||
nameRemapper.put("TestOrderedMapGenerator", "Test%sOrderedMapGenerator");
|
||||
nameRemapper.put("SimpleMapTestGenerator", "Simple%sMapTestGenerator");
|
||||
nameRemapper.put("DerivedMapGenerators", "Derived%sMapGenerators");
|
||||
nameRemapper.put("AbstractMapTester", "Abstract%sMapTester");
|
||||
nameRemapper.put("TestMap", "Test%sMap");
|
||||
biRequired.put("PairTester", "");
|
||||
|
||||
addBiClass("TestMapGenerator", "TestSortedMapGenerator", "TestOrderedMapGenerator", "SimpleMapTestGenerator", "DerivedMapGenerators", "AbstractMapTester", "MapTestSuiteBuilder", "SortedMapTestSuiteBuilder", "NavigableMapTestSuiteBuilder", "OrderedMapTestSuiteBuilder", "MapTests", "MapConstructorTests", "TestMap");
|
||||
addBiClass("MapAddToTester", "MapSubFromTester", "MapClearTester", "MapComputeIfAbsentTester", "MapComputeIfPresentTester", "MapComputeTester", "MapCopyTester", "MapContainsTester", "MapContainsKeyTester", "MapContainsValueTester", "MapCreatorTester", "MapEntrySetTester",
|
||||
"MapEqualsTester", "MapForEachTester", "MapGetOrDefaultTester", "MapGetTester", "MapHashCodeTester", "MapIsEmptyTester", "MapMergeTester", "MapMergeBulkTester", "MapPutAllArrayTester", "MapPutAllTester", "MapPutIfAbsentTester", "MapPutTester",
|
||||
"MapRemoveEntryTester", "MapRemoveOrDefaultTester", "MapRemoveTester", "MapReplaceAllTester", "MapReplaceEntryTester", "MapReplaceTester", "MapSizeTester", "MapSupplyIfAbsentTester", "MapToStringTester",
|
||||
"NavigableMapNavigationTester", "SortedMapNavigationTester", "OrderedMapNavigationTester", "OrderedMapMoveTester", "MapConstructorTester");
|
||||
|
||||
addBlockage(ClassType.OBJECT, "CollectionStreamTester", "ListFillBufferTester");
|
||||
addBlockage(ClassType.BOOLEAN, "TestOrderedSetGenerator", "TestSortedSetGenerator", "TestNavigableSetGenerator", "CollectionRemoveIfTester", "CollectionStreamTester", "ListFillBufferTester", "ListReplaceAllTester", "NavigableSetNavigationTester", "SetTests", "MapConstructorTests", "TestMap", "QueueTests");
|
||||
addBlockage(ClassType.BOOLEAN, "OrderedSetMoveTester", "OrderedSetNavigationTester", "SortedSetNaviationTester", "SetTestSuiteBuilder", "OrderedSetTestSuiteBuilder", "SortedSetTestSuiteBuilder", "NavigableSetTestSuiteBuilder", "SortedSetSubsetTestSetGenerator", "OrderedMapNavigationTester", "OrderedMapTestSuiteBuilder", "OrderedSetIterationTester", "SortedSetIterationTester");
|
||||
addBlockage(ClassType.BOOLEAN, "TestMapGenerator", "TestSortedMapGenerator", "TestOrderedMapGenerator", "SimpleMapTestGenerator", "DerivedMapGenerators", "AbstractMapTester", "MapTestSuiteBuilder", "SortedMapTestSuiteBuilder", "NavigableMapTestSuiteBuilder", "MapTests");
|
||||
addBlockage(ClassType.BOOLEAN, T -> T.endsWith("Tester") && (T.startsWith("Iterable") ||T.startsWith("Map") || T.startsWith("OrderedMap") || T.startsWith("SortedMap") || T.startsWith("NavigableMap")));
|
||||
}
|
||||
|
||||
protected void create(ClassType mainType, ClassType subType)
|
||||
|
@ -146,6 +205,11 @@ public class PrimitiveCollectionsBuilder extends TemplateProcessor
|
|||
}
|
||||
}
|
||||
|
||||
protected void addBlockage(ClassType type, Predicate<String> filter)
|
||||
{
|
||||
blockedPredicate.computeIfAbsent(type, T -> new ArrayList<>()).add(filter);
|
||||
}
|
||||
|
||||
protected void addBlockage(ClassType type, String...args)
|
||||
{
|
||||
for(String s : args)
|
||||
|
@ -166,17 +230,29 @@ public class PrimitiveCollectionsBuilder extends TemplateProcessor
|
|||
String splitter = biRequired.get(name);
|
||||
boolean valueRequired = enumRequired.contains(name);
|
||||
List<GlobalVariables> vars = getVariablesByClass(name, splitter != null);
|
||||
EnumSet<ClassType> types = blocked.get(name);
|
||||
for(int i = 0,m=vars.size();i<m;i++)
|
||||
{
|
||||
GlobalVariables type = vars.get(i);
|
||||
if(types == null || !types.contains(type.getType()))
|
||||
if(isAllowed(type.getType(), name))
|
||||
{
|
||||
acceptor.accept(type.create(nameRemapper.getOrDefault(name, "%s"+name), splitter, valueRequired));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean isAllowed(ClassType type, String fileName)
|
||||
{
|
||||
EnumSet<ClassType> types = blocked.get(fileName);
|
||||
if(types != null && types.contains(type)) return false;
|
||||
List<Predicate<String>> list = blockedPredicate.get(type);
|
||||
if(list != null) {
|
||||
for(int i = 0,m=list.size();i<m;i++) {
|
||||
if(list.get(i).test(fileName)) return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected List<GlobalVariables> getVariablesByClass(String name, boolean bi) {
|
||||
if(enumRequired.contains(name)) return enumVariables;
|
||||
if(bi) return biVariables;
|
||||
|
@ -236,28 +312,19 @@ public class PrimitiveCollectionsBuilder extends TemplateProcessor
|
|||
{
|
||||
try
|
||||
{
|
||||
if(args.length == 0) {
|
||||
new PrimitiveCollectionsBuilder().process(false);
|
||||
} else if(args.length == 1) {
|
||||
new PrimitiveCollectionsBuilder().process(Boolean.parseBoolean(args[0]));
|
||||
} else if(args.length == 2) {
|
||||
new PrimitiveCollectionsBuilder(Boolean.parseBoolean(args[1])).process(Boolean.parseBoolean(args[0]));
|
||||
} else if(args.length == 3) {
|
||||
new PrimitiveCollectionsBuilder(Paths.get(args[0]), Paths.get(args[1]), Paths.get(args[2])).process(false);
|
||||
} else if(args.length == 4) {
|
||||
new PrimitiveCollectionsBuilder(false, Paths.get(args[0]), Paths.get(args[1]), Paths.get(args[2])).process(Boolean.parseBoolean(args[3]));
|
||||
} else if(args.length == 4) {
|
||||
new PrimitiveCollectionsBuilder(Boolean.parseBoolean(args[4]), Paths.get(args[0]), Paths.get(args[1]), Paths.get(args[2])).process(Boolean.parseBoolean(args[3]));
|
||||
} else {
|
||||
System.out.println("Invalid argument count passed in");
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
catch(InterruptedException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(IOException e)
|
||||
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");
|
||||
|
||||
new PrimitiveCollectionsBuilder(silent).process(force);
|
||||
if(tests) {
|
||||
createTests(silent).process(force || forceTests);
|
||||
createTesters(silent).process(force || forceTests);
|
||||
}
|
||||
}
|
||||
catch(InterruptedException | IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,91 @@
|
|||
package speiger.src.testers.PACKAGE.builder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.testing.AbstractTester;
|
||||
import com.google.common.collect.testing.CollectionTestSuiteBuilder;
|
||||
import com.google.common.collect.testing.Helpers;
|
||||
import com.google.common.collect.testing.testers.CollectionRemoveIfTester;
|
||||
|
||||
import speiger.src.testers.base.tests.collection.JavaCollectionRemoveIfTester;
|
||||
import speiger.src.testers.PACKAGE.generators.TEST_COLLECTION_GENERATOR;
|
||||
import speiger.src.testers.PACKAGE.tests.collection.FILE_KEY_TYPECollectionAddAllArrayTester;
|
||||
import speiger.src.testers.PACKAGE.tests.collection.FILE_KEY_TYPECollectionAddAllTester;
|
||||
import speiger.src.testers.PACKAGE.tests.collection.FILE_KEY_TYPECollectionAddTester;
|
||||
import speiger.src.testers.PACKAGE.tests.collection.FILE_KEY_TYPECollectionClearTester;
|
||||
import speiger.src.testers.PACKAGE.tests.collection.FILE_KEY_TYPECollectionContainsAllTester;
|
||||
import speiger.src.testers.PACKAGE.tests.collection.FILE_KEY_TYPECollectionContainsAnyTester;
|
||||
import speiger.src.testers.PACKAGE.tests.collection.FILE_KEY_TYPECollectionContainsTester;
|
||||
import speiger.src.testers.PACKAGE.tests.collection.FILE_KEY_TYPECollectionCopyTester;
|
||||
import speiger.src.testers.PACKAGE.tests.collection.FILE_KEY_TYPECollectionEqualsTester;
|
||||
import speiger.src.testers.PACKAGE.tests.collection.FILE_KEY_TYPECollectionForEachTester;
|
||||
import speiger.src.testers.PACKAGE.tests.collection.FILE_KEY_TYPECollectionIteratorTester;
|
||||
import speiger.src.testers.PACKAGE.tests.collection.FILE_KEY_TYPECollectionRemoveAllTester;
|
||||
#if !TYPE_BOOLEAN
|
||||
import speiger.src.testers.PACKAGE.tests.collection.FILE_KEY_TYPECollectionRemoveIfTester;
|
||||
#if !TYPE_OBJECT
|
||||
import speiger.src.testers.PACKAGE.tests.collection.FILE_KEY_TYPECollectionStreamTester;
|
||||
#endif
|
||||
#endif
|
||||
import speiger.src.testers.PACKAGE.tests.collection.FILE_KEY_TYPECollectionRetainAllTester;
|
||||
import speiger.src.testers.PACKAGE.tests.collection.FILE_KEY_TYPECollectionToArrayTester;
|
||||
#if !TYPE_BOOLEAN
|
||||
import speiger.src.testers.PACKAGE.tests.iterable.FILE_KEY_TYPEIterableCountTester;
|
||||
import speiger.src.testers.PACKAGE.tests.iterable.FILE_KEY_TYPEIterableDistinctTester;
|
||||
import speiger.src.testers.PACKAGE.tests.iterable.FILE_KEY_TYPEIterableFilterTester;
|
||||
import speiger.src.testers.PACKAGE.tests.iterable.FILE_KEY_TYPEIterableFindFirstTester;
|
||||
import speiger.src.testers.PACKAGE.tests.iterable.FILE_KEY_TYPEIterableLimitTester;
|
||||
import speiger.src.testers.PACKAGE.tests.iterable.FILE_KEY_TYPEIterableMapTester;
|
||||
import speiger.src.testers.PACKAGE.tests.iterable.FILE_KEY_TYPEIterableMatchesTester;
|
||||
import speiger.src.testers.PACKAGE.tests.iterable.FILE_KEY_TYPEIterablePeekTester;
|
||||
import speiger.src.testers.PACKAGE.tests.iterable.FILE_KEY_TYPEIterableReduceTester;
|
||||
import speiger.src.testers.PACKAGE.tests.iterable.FILE_KEY_TYPEIterableSortedTester;
|
||||
#endif
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public class COLLECTION_TEST_BUILDER KEY_GENERIC_TYPE extends CollectionTestSuiteBuilder<CLASS_TYPE> {
|
||||
public static GENERIC_KEY_BRACES COLLECTION_TEST_BUILDER KEY_GENERIC_TYPE using(TEST_COLLECTION_GENERATOR KEY_GENERIC_TYPE generator) {
|
||||
return (COLLECTION_TEST_BUILDER KEY_GENERIC_TYPE) new COLLECTION_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.remove(CollectionRemoveIfTester.class);
|
||||
testers.add(JavaCollectionRemoveIfTester.class);
|
||||
#if !TYPE_BOOLEAN
|
||||
testers.add(FILE_KEY_TYPEIterableMapTester.class);
|
||||
testers.add(FILE_KEY_TYPEIterableFilterTester.class);
|
||||
testers.add(FILE_KEY_TYPEIterableDistinctTester.class);
|
||||
testers.add(FILE_KEY_TYPEIterableLimitTester.class);
|
||||
testers.add(FILE_KEY_TYPEIterableSortedTester.class);
|
||||
testers.add(FILE_KEY_TYPEIterableMatchesTester.class);
|
||||
testers.add(FILE_KEY_TYPEIterablePeekTester.class);
|
||||
testers.add(FILE_KEY_TYPEIterableReduceTester.class);
|
||||
testers.add(FILE_KEY_TYPEIterableCountTester.class);
|
||||
testers.add(FILE_KEY_TYPEIterableFindFirstTester.class);
|
||||
#endif
|
||||
testers.add(FILE_KEY_TYPECollectionAddAllTester.class);
|
||||
testers.add(FILE_KEY_TYPECollectionAddAllArrayTester.class);
|
||||
testers.add(FILE_KEY_TYPECollectionAddTester.class);
|
||||
testers.add(FILE_KEY_TYPECollectionClearTester.class);
|
||||
testers.add(FILE_KEY_TYPECollectionContainsAllTester.class);
|
||||
testers.add(FILE_KEY_TYPECollectionContainsAnyTester.class);
|
||||
testers.add(FILE_KEY_TYPECollectionContainsTester.class);
|
||||
testers.add(FILE_KEY_TYPECollectionCopyTester.class);
|
||||
testers.add(FILE_KEY_TYPECollectionEqualsTester.class);
|
||||
testers.add(FILE_KEY_TYPECollectionForEachTester.class);
|
||||
testers.add(FILE_KEY_TYPECollectionIteratorTester.class);
|
||||
testers.add(FILE_KEY_TYPECollectionRemoveAllTester.class);
|
||||
testers.add(FILE_KEY_TYPECollectionRetainAllTester.class);
|
||||
#if !TYPE_BOOLEAN
|
||||
testers.add(FILE_KEY_TYPECollectionRemoveIfTester.class);
|
||||
#if !TYPE_OBJECT
|
||||
testers.add(FILE_KEY_TYPECollectionStreamTester.class);
|
||||
#endif
|
||||
#endif
|
||||
testers.add(FILE_KEY_TYPECollectionToArrayTester.class);
|
||||
return testers;
|
||||
}
|
||||
}
|
|
@ -0,0 +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;
|
||||
}
|
||||
}
|
|
@ -0,0 +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);
|
||||