package edu.columbia.cs.psl.test.phosphor;

import static org.junit.Assert.*;

import org.junit.Test;

import edu.columbia.cs.psl.phosphor.runtime.MultiTainter;
import edu.columbia.cs.psl.phosphor.runtime.Taint;
import edu.columbia.cs.psl.phosphor.struct.TaintedWithObjTag;

public class StringConcatObjTagITCase {
	@Test
	public void testLDCStringConcat() throws Exception {
		String str1 = "abcdefg";
		((TaintedWithObjTag)((Object)str1)).setPHOSPHOR_TAG(new Taint("sensitive"));
		String str2 = "a"+str1;
		assertTrue(MultiTainter.getTaint(str2.charAt(0)) == null);
		assertTrue(MultiTainter.getTaint(str2.charAt(1)) != null);
	}

	@Test
	public void testNewStringConcat() throws Exception {
		String str1 = new String("abcdefg");
		((TaintedWithObjTag)((Object)str1)).setPHOSPHOR_TAG(new Taint("sensitive"));
		String str2 = "a"+str1;
		assertTrue(MultiTainter.getTaint(str2.charAt(0)) == null);
		assertTrue(MultiTainter.getTaint(str2.charAt(1)) != null);
	}
	
	
}

@@ -960,11 +960,328 @@
 ;%0A%09%7D%0A%09%0A%09
+@Test%0A%09public void testConcatAndMultiTainter() throws Exception %7B%0A%09%09String str1 = new String(%22abcdefg%22);%0A%09%09MultiTainter.taintedObject(str1, new Taint(%22Sensitive%22));%0A%09%09String str2 = str1 + %22a%22;%0A%09%09assertTrue(MultiTainter.getTaint(str2.charAt(0)) != null);%0A%09%09assertTrue(MultiTainter.getTaint(str2.charAt(7)) == null);%0A%09%7D
 %0A%7D%0A

Add additional string concat test case with multitainter.taintedobj and reverse concat