use of com.google.template.soy.data.SoyValue in project closure-templates by google.
the class StrContainsFunctionTest method testComputeForJava_containsString.
@Test
public void testComputeForJava_containsString() {
StrContainsFunction strContains = new StrContainsFunction();
SoyValue arg0 = StringData.forValue("foobarfoo");
SoyValue arg1 = StringData.forValue("bar");
assertThat(strContains.computeForJava(ImmutableList.of(arg0, arg1))).isEqualTo(BooleanData.TRUE);
}
use of com.google.template.soy.data.SoyValue in project closure-templates by google.
the class StrLenFunctionTest method testComputeForJava_containsSanitizedContent.
@Test
public void testComputeForJava_containsSanitizedContent() {
StrLenFunction strLen = new StrLenFunction();
SoyValue arg0 = ordainAsSafe("foobarfoo", ContentKind.TEXT);
assertThat(strLen.computeForJava(ImmutableList.of(arg0))).isEqualTo(IntegerData.forValue(9));
}
use of com.google.template.soy.data.SoyValue in project closure-templates by google.
the class BidiTextDirFunctionTest method testComputeForJava.
@Test
public void testComputeForJava() {
BidiTextDirFunction bidiTextDirFunction = new BidiTextDirFunction();
SoyValue text = StringData.EMPTY_STRING;
assertThat(bidiTextDirFunction.computeForJava(ImmutableList.of(text))).isEqualTo(IntegerData.ZERO);
text = StringData.forValue("a");
assertThat(bidiTextDirFunction.computeForJava(ImmutableList.of(text))).isEqualTo(IntegerData.ONE);
text = StringData.forValue("\u05E0");
assertThat(bidiTextDirFunction.computeForJava(ImmutableList.of(text))).isEqualTo(IntegerData.MINUS_ONE);
text = SanitizedContents.unsanitizedText("a");
assertThat(bidiTextDirFunction.computeForJava(ImmutableList.of(text))).isEqualTo(IntegerData.ONE);
text = SanitizedContents.unsanitizedText("a", Dir.LTR);
assertThat(bidiTextDirFunction.computeForJava(ImmutableList.of(text))).isEqualTo(IntegerData.ONE);
text = SanitizedContents.unsanitizedText("a", Dir.RTL);
assertThat(bidiTextDirFunction.computeForJava(ImmutableList.of(text))).isEqualTo(IntegerData.MINUS_ONE);
text = SanitizedContents.unsanitizedText("a", Dir.NEUTRAL);
assertThat(bidiTextDirFunction.computeForJava(ImmutableList.of(text))).isEqualTo(IntegerData.ZERO);
}
use of com.google.template.soy.data.SoyValue in project closure-templates by google.
the class CeilingFunctionTest method testComputeForJava.
@Test
public void testComputeForJava() {
CeilingFunction ceilingFunction = new CeilingFunction();
SoyValue float0 = FloatData.forValue(7.5);
assertThat(ceilingFunction.computeForJava(ImmutableList.of(float0))).isEqualTo(IntegerData.forValue(8));
SoyValue integer = IntegerData.forValue(14);
assertThat(ceilingFunction.computeForJava(ImmutableList.of(integer))).isEqualTo(IntegerData.forValue(14));
}
use of com.google.template.soy.data.SoyValue in project closure-templates by google.
the class LengthFunctionTest method testComputeForJava.
@Test
public void testComputeForJava() {
LengthFunction lengthFunction = new LengthFunction();
SoyValue list = SoyValueConverterUtility.newList(1, 3, 5, 7);
assertThat(lengthFunction.computeForJava(ImmutableList.of(list))).isEqualTo(IntegerData.forValue(4));
}
Aggregations