package soot.jimple.infoflow.test.junit;

import static org.junit.Assert.assertTrue;

import java.util.ArrayList;
import java.util.List;

import org.junit.Test;

import soot.jimple.infoflow.Infoflow;

public class ArrayTests extends JUnitTests {

	  @Test
	    public void arrayTest(){
	    	Infoflow infoflow = new Infoflow();
	    	List<String> epoints = new ArrayList<String>();
	    	epoints.add("<soot.jimple.infoflow.test.ArrayTestCode: void concreteWriteReadTest()>");
			infoflow.computeInfoflow(path, epoints,new ArrayList<String>(), new ArrayList<String>());
			assertTrue(errOutputStream.toString().contains("taintedElement2 contains value from staticinvoke <soot.jimple.infoflow.test.android.TelephonyManager: java.lang.String getDeviceId()>"));
			assertTrue(errOutputStream.toString().contains("taintedElement contains value from staticinvoke"));
			assertTrue(errOutputStream.toString().contains("tainted456 contains value from staticinvoke"));
			assertTrue(errOutputStream.toString().contains("tainted123 contains value from staticinvoke"));
			assertTrue(errOutputStream.toString().contains("alsoTainted contains value from staticinvoke"));
			assertTrue(errOutputStream.toString().contains("taintedElement contains value from staticinvoke"));
	    }
	    
	    @Test
	    public void arrayAsFieldOfClassTest(){
	    	Infoflow infoflow = new Infoflow();
	    	List<String> epoints = new ArrayList<String>();
	    	epoints.add("<soot.jimple.infoflow.test.ArrayTestCode: void arrayAsFieldOfClass()>");
			infoflow.computeInfoflow(path, epoints,null, null);
	    	
	    }
	    
	    @Test
	    public void arrayAsListTest(){
	    	Infoflow infoflow = new Infoflow();
	    	List<String> epoints = new ArrayList<String>();
	    	epoints.add("<soot.jimple.infoflow.test.ArrayTestCode: void arrayAsListTest()>");
			infoflow.computeInfoflow(path, epoints,null, null);
			
			assertTrue(errOutputStream.toString().contains("<java.util.Arrays$ArrayList: java.lang.Object[] a> contains value from staticinvoke <soot.jimple.infoflow.test.android.TelephonyManager: java.lang.String getDeviceId()>()"));
			assertTrue(errOutputStream.toString().contains("taintedElement contains value from staticinvoke"));
	    }
	    

	    
}

@@ -930,18 +930,123 @@
 ns(%22
-tainted456
+alsoTainted contains value from staticinvoke%22));%0D%0A%09%09%09assertTrue(errOutputStream.toString().contains(%22taintedElement
  con
@@ -1227,35 +1227,34 @@
 ).contains(%22
-alsoT
+t
 ainted
+789
  contains va
@@ -1330,39 +1330,35 @@
 ontains(%22tainted
-Element
+456
  contains value 
@@ -1372,32 +1372,37 @@
 aticinvoke%22));%0D%0A
+%09%09%09%0D%0A
 %09    %7D%0D%0A%09    %0D%0A%09
@@ -1700,24 +1700,207 @@
 ll, null);%0D%0A
+%09%09%09%0D%0A%09%09%09assertTrue(errOutputStream.toString().contains(%22y contains value from staticinvoke %3Csoot.jimple.infoflow.test.android.TelephonyManager: java.lang.String getDeviceId()%3E()%22));%0D%0A
 %09    %09%0D%0A%09   

check for variable in test