Skip to content

Commit

Permalink
Merge pull request #170642 from microsoft/tyriar/link_parsing_tests
Browse files Browse the repository at this point in the history
Add more link parsing unit tests
  • Loading branch information
Tyriar authored Jan 5, 2023
2 parents 277131e + bff0b5a commit 727d2d3
Showing 1 changed file with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@ interface ITestLink {
const testRow = 339;
const testCol = 12;
const testLinks: ITestLink[] = [
// Simple
{ link: 'foo', suffix: undefined, hasRow: false, hasCol: false },
{ link: 'foo:339', suffix: ':339', hasRow: true, hasCol: false },
{ link: 'foo:339:12', suffix: ':339:12', hasRow: true, hasCol: true },
{ link: 'foo 339', suffix: ' 339', hasRow: true, hasCol: false },
{ link: 'foo 339:12', suffix: ' 339:12', hasRow: true, hasCol: true },

// Double quotes
{ link: '"foo",339', suffix: '",339', hasRow: true, hasCol: false },
{ link: '"foo",339:12', suffix: '",339:12', hasRow: true, hasCol: true },
{ link: '"foo", line 339', suffix: '", line 339', hasRow: true, hasCol: false },
Expand All @@ -35,12 +38,46 @@ const testLinks: ITestLink[] = [
{ link: '"foo" on line 339', suffix: '" on line 339', hasRow: true, hasCol: false },
{ link: '"foo" on line 339, col 12', suffix: '" on line 339, col 12', hasRow: true, hasCol: true },
{ link: '"foo" on line 339, column 12', suffix: '" on line 339, column 12', hasRow: true, hasCol: true },

// Single quotes
{ link: '\'foo\',339', suffix: '\',339', hasRow: true, hasCol: false },
{ link: '\'foo\',339:12', suffix: '\',339:12', hasRow: true, hasCol: true },
{ link: '\'foo\', line 339', suffix: '\', line 339', hasRow: true, hasCol: false },
{ link: '\'foo\', line 339, col 12', suffix: '\', line 339, col 12', hasRow: true, hasCol: true },
{ link: '\'foo\', line 339, column 12', suffix: '\', line 339, column 12', hasRow: true, hasCol: true },
{ link: '\'foo\':line 339', suffix: '\':line 339', hasRow: true, hasCol: false },
{ link: '\'foo\':line 339, col 12', suffix: '\':line 339, col 12', hasRow: true, hasCol: true },
{ link: '\'foo\':line 339, column 12', suffix: '\':line 339, column 12', hasRow: true, hasCol: true },
{ link: '\'foo\': line 339', suffix: '\': line 339', hasRow: true, hasCol: false },
{ link: '\'foo\': line 339, col 12', suffix: '\': line 339, col 12', hasRow: true, hasCol: true },
{ link: '\'foo\': line 339, column 12', suffix: '\': line 339, column 12', hasRow: true, hasCol: true },
{ link: '\'foo\' on line 339', suffix: '\' on line 339', hasRow: true, hasCol: false },
{ link: '\'foo\' on line 339, col 12', suffix: '\' on line 339, col 12', hasRow: true, hasCol: true },
{ link: '\'foo\' on line 339, column 12', suffix: '\' on line 339, column 12', hasRow: true, hasCol: true },

// Parentheses
{ link: 'foo(339)', suffix: '(339)', hasRow: true, hasCol: false },
{ link: 'foo(339,12)', suffix: '(339,12)', hasRow: true, hasCol: true },
{ link: 'foo(339, 12)', suffix: '(339, 12)', hasRow: true, hasCol: true },
{ link: 'foo (339)', suffix: ' (339)', hasRow: true, hasCol: false },
{ link: 'foo (339,12)', suffix: ' (339,12)', hasRow: true, hasCol: true },
{ link: 'foo (339, 12)', suffix: ' (339, 12)', hasRow: true, hasCol: true },

// Square brackets
{ link: 'foo[339]', suffix: '[339]', hasRow: true, hasCol: false },
{ link: 'foo[339,12]', suffix: '[339,12]', hasRow: true, hasCol: true },
{ link: 'foo[339, 12]', suffix: '[339, 12]', hasRow: true, hasCol: true },
{ link: 'foo [339]', suffix: ' [339]', hasRow: true, hasCol: false },
{ link: 'foo [339,12]', suffix: ' [339,12]', hasRow: true, hasCol: true },
{ link: 'foo [339, 12]', suffix: ' [339, 12]', hasRow: true, hasCol: true },

// Non-breaking space
{ link: 'foo\u00A0339:12', suffix: '\u00A0339:12', hasRow: true, hasCol: true },
{ link: '"foo" on line 339,\u00A0column 12', suffix: '" on line 339,\u00A0column 12', hasRow: true, hasCol: true },
{ link: '\'foo\' on line\u00A0339, column 12', suffix: '\' on line\u00A0339, column 12', hasRow: true, hasCol: true },
{ link: 'foo (339,\u00A012)', suffix: ' (339,\u00A012)', hasRow: true, hasCol: true },
{ link: 'foo\u00A0[339, 12]', suffix: '\u00A0[339, 12]', hasRow: true, hasCol: true },

];

suite('TerminalLinkParsing', () => {
Expand Down

0 comments on commit 727d2d3

Please sign in to comment.