Adrià Vilanova MartÃnez | f19ea43 | 2024-01-23 20:20:52 +0100 | [diff] [blame] | 1 | // 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. |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 4 | |
| 5 | var firstCharMap; |
| 6 | |
| 7 | function setUp() { |
| 8 | firstCharMap = new Object(); |
| 9 | } |
| 10 | |
| 11 | function 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 | |
| 28 | function 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 | } |