blob: 30eedc59fd522ee2098db4143d9e04defa146590 [file] [log] [blame]
Copybara854996b2021-09-07 19:36:02 +00001/* Copyright 2016 The Chromium Authors. All Rights Reserved.
2 *
3 * Use of this source code is governed by a BSD-style
4 * license that can be found in the LICENSE file or at
5 * https://developers.google.com/open-source/licenses/bsd
6 */
7
8var firstCharMap;
9
10function setUp() {
11 firstCharMap = new Object();
12}
13
14function testAddItemToFirstCharMap_OneWordLabel() {
15 _AC_AddItemToFirstCharMap(firstCharMap, 'h', 'Hot');
16 let hArray = firstCharMap['h'];
17 assertEquals(1, hArray.length);
18 assertEquals('Hot', hArray[0].value);
19
20 _AC_AddItemToFirstCharMap(firstCharMap, '-', '-Hot');
21 _AC_AddItemToFirstCharMap(firstCharMap, 'h', '-Hot');
22 let minusArray = firstCharMap['-'];
23 assertEquals(1, minusArray.length);
24 assertEquals('-Hot', minusArray[0].value);
25 hArray = firstCharMap['h'];
26 assertEquals(2, hArray.length);
27 assertEquals('Hot', hArray[0].value);
28 assertEquals('-Hot', hArray[1].value);
29}
30
31function testAddItemToFirstCharMap_KeyValueLabels() {
32 _AC_AddItemToFirstCharMap(firstCharMap, 'p', 'Priority-High');
33 _AC_AddItemToFirstCharMap(firstCharMap, 'h', 'Priority-High');
34 let pArray = firstCharMap['p'];
35 assertEquals(1, pArray.length);
36 assertEquals('Priority-High', pArray[0].value);
37 let hArray = firstCharMap['h'];
38 assertEquals(1, hArray.length);
39 assertEquals('Priority-High', hArray[0].value);
40}