mirror of
https://github.com/github/codeql.git
synced 2026-04-29 18:55:14 +02:00
Genericise test util functions
This commit is contained in:
@@ -45,11 +45,11 @@ import org.springframework.util.SystemPropertyUtils;
|
||||
// Test case generated by GenerateFlowTestCase.ql
|
||||
public class Test {
|
||||
|
||||
Object getArrayElement(Object[] container) { return container[0]; }
|
||||
Object getElement(Collection container) { return container.iterator().next(); }
|
||||
Object getElement(Iterator container) { return container.next(); }
|
||||
Object getMapKey(Map container) { return container.keySet().iterator().next(); }
|
||||
Object getMapValue(Map container) { return container.get(null); }
|
||||
<E> E getArrayElement(E[] container) { return container[0]; }
|
||||
<E> E getElement(Collection<E> container) { return container.iterator().next(); }
|
||||
<E> E getElement(Iterator<E> container) { return container.next(); }
|
||||
<K, V> K getMapKey(Map<K, V> container) { return container.keySet().iterator().next(); }
|
||||
<K, V> V getMapValue(Map<K, V> container) { return container.get(null); }
|
||||
Object[] newWithArrayElement(Object element) { return new Object[] {element}; }
|
||||
Properties newPropertiesWithMapKey(Object element) { Properties p = new Properties(); p.put(element, null); return p; }
|
||||
Properties newPropertiesWithMapValue(Object element) { Properties p = new Properties(); p.put(null, element); return p; }
|
||||
@@ -192,7 +192,7 @@ public class Test {
|
||||
{
|
||||
// "org.springframework.util;CollectionUtils;false;arrayToList;;;ArrayElement of Argument[0];Element of ReturnValue;value"
|
||||
List out = null;
|
||||
Object in = (Object)newWithArrayElement(source());
|
||||
Object[] in = newWithArrayElement(source());
|
||||
out = CollectionUtils.arrayToList(in);
|
||||
sink(getElement(out)); // $hasValueFlow
|
||||
}
|
||||
@@ -248,7 +248,7 @@ public class Test {
|
||||
{
|
||||
// "org.springframework.util;CollectionUtils;false;mergeArrayIntoCollection;;;ArrayElement of Argument[0];Element of Argument[1];value"
|
||||
Collection out = null;
|
||||
Object in = (Object)newWithArrayElement(source());
|
||||
Object[] in = newWithArrayElement(source());
|
||||
CollectionUtils.mergeArrayIntoCollection(in, out);
|
||||
sink(getElement(out)); // $hasValueFlow
|
||||
}
|
||||
@@ -721,7 +721,7 @@ public class Test {
|
||||
{
|
||||
// "org.springframework.util;ObjectUtils;false;toObjectArray;;;ArrayElement of Argument[0];ArrayElement of ReturnValue;value"
|
||||
Object[] out = null;
|
||||
Object in = (Object)newWithArrayElement(source());
|
||||
Object[] in = newWithArrayElement(source());
|
||||
out = ObjectUtils.toObjectArray(in);
|
||||
sink(getArrayElement(out)); // $hasValueFlow
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user