Search in sources :

Example 11 with SoyMsgPlaceholderPart

use of com.google.template.soy.msgs.restricted.SoyMsgPlaceholderPart in project closure-templates by google.

the class SoyMsgIdComputerTest method testKnownMsgIds.

@Test
public void testKnownMsgIds() {
    // Important: Do not change these hard-coded values. Changes to the algorithm will break
    // backwards compatibility.
    assertThat(SoyMsgIdComputer.computeMsgId(HELLO_WORLD_MSG_PARTS, null, null)).isEqualTo(3022994926184248873L);
    assertThat(SoyMsgIdComputer.computeMsgId(HELLO_WORLD_MSG_PARTS, null, "text/html")).isEqualTo(3022994926184248873L);
    assertThat(SoyMsgIdComputer.computeMsgId(HELLO_NAME_MSG_PARTS, null, null)).isEqualTo(6936162475751860807L);
    assertThat(SoyMsgIdComputer.computeMsgId(HELLO_NAME_MSG_PARTS, null, "text/html")).isEqualTo(6936162475751860807L);
    assertThat(SoyMsgIdComputer.computeMsgId(PLURAL_MSG_PARTS, null, null)).isEqualTo(947930983556630648L);
    assertThat(SoyMsgIdComputer.computeMsgIdUsingBracedPhs(PLURAL_MSG_PARTS, null, null)).isEqualTo(1429579464553183506L);
    ImmutableList<SoyMsgPart> archiveMsgParts = ImmutableList.<SoyMsgPart>of(SoyMsgRawTextPart.of("Archive"));
    assertThat(SoyMsgIdComputer.computeMsgId(archiveMsgParts, "noun", null)).isEqualTo(7224011416745566687L);
    assertThat(SoyMsgIdComputer.computeMsgId(archiveMsgParts, "verb", null)).isEqualTo(4826315192146469447L);
    ImmutableList<SoyMsgPart> unicodeMsgParts = ImmutableList.of(new SoyMsgPlaceholderPart("\u2222\uEEEE", /* placeholderExample= */
    null), SoyMsgRawTextPart.of("\u9EC4\u607A"));
    assertThat(SoyMsgIdComputer.computeMsgId(unicodeMsgParts, null, null)).isEqualTo(7971596007260280311L);
    assertThat(SoyMsgIdComputer.computeMsgId(unicodeMsgParts, null, "application/javascript")).isEqualTo(5109146044343713753L);
}
Also used : SoyMsgPlaceholderPart(com.google.template.soy.msgs.restricted.SoyMsgPlaceholderPart) SoyMsgPart(com.google.template.soy.msgs.restricted.SoyMsgPart) Test(org.junit.Test)

Aggregations

SoyMsgPlaceholderPart (com.google.template.soy.msgs.restricted.SoyMsgPlaceholderPart)11 SoyMsgPart (com.google.template.soy.msgs.restricted.SoyMsgPart)9 SoyMsgRawTextPart (com.google.template.soy.msgs.restricted.SoyMsgRawTextPart)8 SoyMsgPluralPart (com.google.template.soy.msgs.restricted.SoyMsgPluralPart)3 SoyMsgSelectPart (com.google.template.soy.msgs.restricted.SoyMsgSelectPart)3 RawTextNode (com.google.template.soy.soytree.RawTextNode)3 ImmutableList (com.google.common.collect.ImmutableList)2 SoyMsg (com.google.template.soy.msgs.restricted.SoyMsg)2 SoyMsgPluralRemainderPart (com.google.template.soy.msgs.restricted.SoyMsgPluralRemainderPart)2 MsgHtmlTagNode (com.google.template.soy.soytree.MsgHtmlTagNode)2 MsgPlaceholderNode (com.google.template.soy.soytree.MsgPlaceholderNode)2 StandaloneNode (com.google.template.soy.soytree.SoyNode.StandaloneNode)2 Test (org.junit.Test)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Escaper (com.google.common.escape.Escaper)1 IndentedLinesBuilder (com.google.template.soy.base.internal.IndentedLinesBuilder)1 Expression (com.google.template.soy.jbcsrc.restricted.Expression)1 SoyExpression (com.google.template.soy.jbcsrc.restricted.SoyExpression)1 SoyMsgBundle (com.google.template.soy.msgs.SoyMsgBundle)1 SoyMsgBundleImpl (com.google.template.soy.msgs.restricted.SoyMsgBundleImpl)1