support min/max in stream api migration, rearrange tests

This commit is contained in:
Roman Ivanov
2017-08-02 12:57:45 +07:00
parent dd4ba58889
commit 72bab18a58
561 changed files with 2091 additions and 17 deletions
@@ -0,0 +1,10 @@
// "Replace with count()" "true"
import java.util.Arrays;
public class Main {
public long test(String[] array) {
long longStrings = Arrays.stream(array).map(String::trim).filter(trimmed -> trimmed.length() > 10).count();
return longStrings;
}
}
@@ -0,0 +1,14 @@
// "Replace with count()" "true"
import java.util.List;
import java.util.Set;
public class Main {
public void test(List<Set<String>> nested) {
int count = 0;
for(Set<String> element : nested) {
if(element != null) {
count += element.stream().filter(str -> str.startsWith("xyz")).count();
}
}
}
}
@@ -0,0 +1,11 @@
// "Replace with count()" "true"
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import java.util.Set;
public class Main {
public void test(List<Set<String>> nested) {
int count = (int) nested.stream().filter(Objects::nonNull).flatMap(Collection::stream).filter(str -> str.startsWith("xyz")).count();
}
}
@@ -0,0 +1,10 @@
// "Replace with count()" "true"
import java.util.Arrays;
public class Main {
public int testPrimitiveArray(int[] data) {
int count = (int) Arrays.stream(data).mapToLong(val -> val * val).filter(square -> square > 100).count();
return count;
}
}
@@ -0,0 +1,14 @@
// "Replace with count()" "true"
public class Main {
public long test(String[] array) {
long longStrings = 0;
for(String str : a<caret>rray) {
String trimmed = str.trim();
if(trimmed.length() > 10) {
longStrings = longStrings + 1;
}
}
return longStrings;
}
}
@@ -0,0 +1,18 @@
// "Replace with count()" "true"
import java.util.List;
import java.util.Set;
public class Main {
public void test(List<Set<String>> nested) {
int count = 0;
for(Set<String> element : nested) {
if(element != null) {
for(String str : eleme<caret>nt) {
if(str.startsWith("xyz")) {
count++;
}
}
}
}
}
}
@@ -0,0 +1,18 @@
// "Replace with count()" "true"
import java.util.List;
import java.util.Set;
public class Main {
public void test(List<Set<String>> nested) {
int count = 0;
for(Set<String> element : neste<caret>d) {
if(element != null) {
for(String str : element) {
if(str.startsWith("xyz")) {
++count;
}
}
}
}
}
}
@@ -0,0 +1,14 @@
// "Replace with count()" "true"
public class Main {
public int testPrimitiveArray(int[] data) {
int count = 0;
for(int val : dat<caret>a) {
long square = val*val;
if(square > 100) {
count++;
}
}
return count;
}
}
@@ -0,0 +1,14 @@
// "Replace with count()" "false"
public class Main {
public int testPrimitiveArray(short[] data) {
int count = 0;
for(int val : dat<caret>a) {
long square = val*val;
if(square > 100) {
count++;
}
}
return count;
}
}