Debian Codegraph @

test/com/google/javascript/jscomp/JsMessageTest.java

raw symbols SCIP
1 /*
2 * Copyright 2009 The Closure Compiler Authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package com.google.javascript.jscomp;
18
19 import junit.framework.*;
20
21 /**
22 * @author [email protected] (Anatol Pomazau)
23 */
24 public class JsMessageTest extends TestCase {
25
26 public void testIsEmpty() {
27 assertTrue(new JsMessage.Builder().build().isEmpty());
28 assertTrue(new JsMessage.Builder().appendStringPart("").build().isEmpty());
29 assertTrue(new JsMessage.Builder().appendStringPart("")
30 .appendStringPart("").build().isEmpty());
31 assertFalse(new JsMessage.Builder().appendStringPart("s")
32 .appendStringPart("").build().isEmpty());
33 assertFalse(new JsMessage.Builder().appendPlaceholderReference("3")
34 .build().isEmpty());
35 }
36
37 public void testMeaningChangesId() {
38 String id1 = new JsMessage.Builder()
39 .appendStringPart("foo").build().getId();
40 String id2 = new JsMessage.Builder()
41 .appendStringPart("foo").setMeaning("bar").build().getId();
42 assertFalse(id1.equals(id2));
43 }
44
45 public void testHashValues() {
46 final String EMPTY = "";
47 final String VAL = "Hello, world";
48 final long ANSWER_STRING_64 = 0x43ec5d9731515874L;
49 final long ANSWER_EMPTY_64 = 0x468d9ea2c42361aaL;
50
51 assertEquals(ANSWER_STRING_64, JsMessage.Hash.hash64(VAL));
52 assertEquals(ANSWER_EMPTY_64, JsMessage.Hash.hash64(EMPTY));
53 }
54 }