1
0
Code Issues Pull Requests Packages Projects Releases Wiki Activity GitHub Gitee

添加测试用例

This commit is contained in:
zhangbk1 2024-04-01 17:32:35 +08:00
parent be9952f6bc
commit aff9af95ac
3 changed files with 130 additions and 30 deletions

View File

@ -5,36 +5,6 @@ import * as assert from 'assert';
import * as vscode from 'vscode'; import * as vscode from 'vscode';
// import * as myExtension from '../../extension'; // import * as myExtension from '../../extension';
enum TextFormat {
/** 独立单词 */
SINGLE_WORD,
/** 小驼峰 */
CAMEL_CASE,
/** 大驼峰 */
PASCAL_CASE,
/** 大写 */
UPPER_CASE,
/** 小写 */
LOWER_CASE,
}
interface TestCase {
input: string
inputType: TextFormat | Array<TextFormat>
output: {
camelCase: string
}
}
const testCase: Array<TestCase> = [
{
input: '',
inputType: [],
output: {
camelCase: '',
}
},
];
suite('Extension Test Suite', () => { suite('Extension Test Suite', () => {
vscode.window.showInformationMessage('Start all tests.'); vscode.window.showInformationMessage('Start all tests.');

128
src/test/test-case.ts Normal file
View File

@ -0,0 +1,128 @@
enum SkipReason {
/** 空字符串 */
EMPTY_STRING,
/** 字符串过长 */
STRING_TOO_LONG,
/** 不包含英文字母 */
NOT_CONTAIN_LETTERS,
}
type TestSkipCase = {
/** 当 input 不是规范的输入时isSkip 为 true */
isSkip: true
skipReason: SkipReason
};
type TestReplaceCase = {
isSkip: false
splitResult: Array<string>
output: {
camelCase: string
pascalCase: string
}
};
type TestCase = (TestSkipCase | TestReplaceCase) & {
input: string | Array<string>
};
/*
Have a nice day!
foo--bar
foo -bar
pineApple
*/
const testCase: Array<TestCase> = [
{
input:
''
,
isSkip: true,
skipReason: SkipReason.EMPTY_STRING
},
{
input:
`China's factory activity expanded in March after five consecutive months of contraction, an official survey revealed on Sunday, adding to a run of indicators that suggest the stabilization of the world's second-largest economy.`
,
isSkip: true,
skipReason: SkipReason.STRING_TOO_LONG
},
{
input:
`今天是星期日`
,
isSkip: true,
skipReason: SkipReason.NOT_CONTAIN_LETTERS
},
{
input: [
'test case',
'test_case',
'test-case',
'testCase',
'TestCase',
'TEST_CASE',
],
isSkip: false,
splitResult: [
''
],
output: {
camelCase: 'testCase',
pascalCase: 'TestCase',
}
},
{
input: [
' A nice day! ',
' a_nice_day! ',
' ANiceDay! ',
' A_NICE_DAY! ',
' A_Nice_DaY ',
' A-NiCe_Day ',
' A----NiCe_Day_-_-- ',
],
isSkip: false,
splitResult: [
''
],
output: {
camelCase: ' aNiceDay! ',
pascalCase: ' ANiceDay! ',
}
},
{
input: [
' A niCe-Day-',
' A niceDay',
],
isSkip: false,
splitResult: [
''
],
output: {
camelCase: ' a niceDay',
pascalCase: ' A NiceDay',
}
},
{
input: [
'Have a nice day!',
'have a nice day!',
'Have-a-nice-day!',
'have-a-nice-day!',
'HAVE-A-NICE-DAY!',
'Have_a_nice_day!',
'have_a_nice_day!',
'HAVE_A_NICE_DAY!',
'HaveANiceDay!',
'haveANiceDay!',
],
isSkip: false,
splitResult: ['have', 'a', 'nice', 'day', '!'],
output: {
camelCase: ' a niceDay',
pascalCase: ' A NiceDay',
}
},
];

View File

@ -13,4 +13,6 @@ const HELLO_WORLD = ''
const helloworld = '' const helloworld = ''
// 大写 // 大写
const HELLOWORLD = '' const HELLOWORLD = ''
// 加空格
const a = 'hello world'
``` ```