-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pw_tokenizer: Fix CSV database parsing in TS
This replaces the custom CSV parser with a more robust library that should handle variations in file format better. This change also adds support for 4 column token databases and removal dates. Change-Id: Ia71da392a6eec4c3bb5a97b8fac0efbdbecf1734 Bug: 379172909 Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/251892 Reviewed-by: Wyatt Hepler <hepler@google.com> Commit-Queue: Chad Norvell <chadnorvell@google.com> Lint: Lint 🤖 <android-build-ayeaye@system.gserviceaccount.com> Docs-Not-Needed: Chad Norvell <chadnorvell@google.com>
- Loading branch information
1 parent
935559e
commit 48dfcf5
Showing
5 changed files
with
216 additions
and
69 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright 2022 The Pigweed Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
// use this file except in compliance with the License. You may obtain a copy of | ||
// the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
// License for the specific language governing permissions and limitations under | ||
// the License. | ||
|
||
/* eslint-env browser */ | ||
|
||
import Papa from 'papaparse'; | ||
import { parseCsvEntry } from './token_database'; | ||
|
||
const CSV = ` | ||
86fc33f3, ,"normal and ""quoted"" text" | ||
`; | ||
|
||
describe('parseCsvEntry', () => { | ||
it('correctly parses double quotes', () => { | ||
const parsedCsv = Papa.parse(CSV, { header: false }); | ||
const data = parsedCsv.data[1] as string[]; | ||
const results = parseCsvEntry(data); | ||
expect(results).toBeDefined(); | ||
expect(results.template).toEqual('normal and "quoted" text'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters