blob: 5f1c0e57e1dd1435d1791123dc8f3c194c0b4a8b [file] [log] [blame]
Adrià Vilanova Martínezf19ea432024-01-23 20:20:52 +01001// Copyright 2016 The Chromium Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
Copybara854996b2021-09-07 19:36:02 +00004
5var firstCharMap;
6
7function setUp() {
8 firstCharMap = new Object();
9}
10
11function testAddItemToFirstCharMap_OneWordLabel() {
12 _AC_AddItemToFirstCharMap(firstCharMap, 'h', 'Hot');
13 let hArray = firstCharMap['h'];
14 assertEquals(1, hArray.length);
15 assertEquals('Hot', hArray[0].value);
16
17 _AC_AddItemToFirstCharMap(firstCharMap, '-', '-Hot');
18 _AC_AddItemToFirstCharMap(firstCharMap, 'h', '-Hot');
19 let minusArray = firstCharMap['-'];
20 assertEquals(1, minusArray.length);
21 assertEquals('-Hot', minusArray[0].value);
22 hArray = firstCharMap['h'];
23 assertEquals(2, hArray.length);
24 assertEquals('Hot', hArray[0].value);
25 assertEquals('-Hot', hArray[1].value);
26}
27
28function testAddItemToFirstCharMap_KeyValueLabels() {
29 _AC_AddItemToFirstCharMap(firstCharMap, 'p', 'Priority-High');
30 _AC_AddItemToFirstCharMap(firstCharMap, 'h', 'Priority-High');
31 let pArray = firstCharMap['p'];
32 assertEquals(1, pArray.length);
33 assertEquals('Priority-High', pArray[0].value);
34 let hArray = firstCharMap['h'];
35 assertEquals(1, hArray.length);
36 assertEquals('Priority-High', hArray[0].value);
37}