-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #211 from HubSpot/fix-equalto-exp-test
Deepen equalto expression test comparison.
- Loading branch information
Showing
2 changed files
with
55 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/test/java/com/hubspot/jinjava/lib/exptest/IsEqualToExpTestTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package com.hubspot.jinjava.lib.exptest; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.util.HashMap; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import com.hubspot.jinjava.Jinjava; | ||
|
||
public class IsEqualToExpTestTest { | ||
|
||
private static final String EQUAL_TEMPLATE = "{{ %s is equalto %s }}"; | ||
|
||
private Jinjava jinjava; | ||
|
||
@Before | ||
public void setup() { | ||
jinjava = new Jinjava(); | ||
} | ||
|
||
@Test | ||
public void itEquatesNumbers() { | ||
assertThat(jinjava.render(String.format(EQUAL_TEMPLATE, "4", "4"), new HashMap<>())).isEqualTo("true"); | ||
assertThat(jinjava.render(String.format(EQUAL_TEMPLATE, "4", "5"), new HashMap<>())).isEqualTo("false"); | ||
} | ||
|
||
@Test | ||
public void itEquatesStrings() { | ||
assertThat(jinjava.render(String.format(EQUAL_TEMPLATE, "\"jinjava\"", "\"jinjava\""), new HashMap<>())).isEqualTo("true"); | ||
assertThat(jinjava.render(String.format(EQUAL_TEMPLATE, "\"jinjava\"", "\"not jinjava\""), new HashMap<>())).isEqualTo("false"); | ||
} | ||
|
||
@Test | ||
public void itEquatesBooleans() { | ||
assertThat(jinjava.render(String.format(EQUAL_TEMPLATE, "true", "true"), new HashMap<>())).isEqualTo("true"); | ||
assertThat(jinjava.render(String.format(EQUAL_TEMPLATE, "true", "false"), new HashMap<>())).isEqualTo("false"); | ||
} | ||
|
||
@Test | ||
public void itEquatesDifferentTypes() { | ||
assertThat(jinjava.render(String.format(EQUAL_TEMPLATE, "4", "\"4\""), new HashMap<>())).isEqualTo("true"); | ||
assertThat(jinjava.render(String.format(EQUAL_TEMPLATE, "4", "\"5\""), new HashMap<>())).isEqualTo("false"); | ||
assertThat(jinjava.render(String.format(EQUAL_TEMPLATE, "'c'", "\"c\""), new HashMap<>())).isEqualTo("true"); | ||
assertThat(jinjava.render(String.format(EQUAL_TEMPLATE, "'c'", "\"b\""), new HashMap<>())).isEqualTo("false"); | ||
} | ||
} |