Skip to content

Commit

Permalink
adjust
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason3S committed Dec 5, 2024
1 parent a8e7f6d commit 2ff6b05
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
37 changes: 19 additions & 18 deletions packages/cspell-lib/src/lib/textValidation/isRandomString.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,38 @@ describe('isRandomString', () => {
${'Hello'} | ${false}
${'expectCategorizeStringStrToBeExpected'} | ${false}
${'expect categorizeString str .toBe expected'} | ${false}
${'H4sIAAAAAAAAA72d3ZLjNpK276X6O6ztFX4l+WxnPN5whD3jsGd3DzomHGqJVa21StLqp9uOibn3LwgIKiD5AkyQ7Dpyu0QmkmQy'} | ${true}
${'H4sIAAAAAAAAA72d3ZLjNpK276X6O6ztFX4l_WxnPN5whD3jsGd3DzomHGqJVa21StLqp9uOibn3LwgIKiD5AkyQ7Dpyu0QmkmQy'} | ${true}
${'izfrNTmQLnfsLzi2Wb9xPz2Qj9fQYGgeug3N2MkDuVHwpPcgkhHkJgCQuuvT+qZI'} | ${true}
${'sampleOldFalsePositivesBase64'} | ${false}
${'residencyStandard2DMultisampleBlockShape'} | ${false}
${'myNameSpace1/MyNameSpace2/mynamespace3/myserviceName'} | ${false}
${'PxTransform12transformInvERKS0_'} | ${false}
${'_ZNK5physx11PxTransform12transformInvERKNS_6PxVec3E'} | ${false}
${'_ZNK5physx11PxERKNS_6PxVec3E'} | ${true}
${'_ZNK5physx11PxERKNS_6PxVec3E'} | ${false}
`('isRandomString $str', ({ str, expected }) => {
expect(isRandomString(str)).toBe(expected);
});
// cspell:enable

// cspell:disable
test.each`
str | expected
${''} | ${0}
${'hello'} | ${0.2}
${'café'} | ${0.25}
${'café'.normalize('NFD')} | ${0.2}
${'Hello'} | ${0.4}
${'expectCategorizeStringStrToBeExpected'} | ${0.35}
${'expect categorizeString str .toBe expected'} | ${0.33}
${'H4sIAAAAAAAAA72d3ZLjNpK276X6O6ztFX4l+WxnPN5whD3jsGd3DzomHGqJVa21StLqp9uOibn3LwgIKiD5AkyQ7Dpyu0QmkmQy'} | ${0.66}
${'izfrNTmQLnfsLzi2Wb9xPz2Qj9fQYGgeug3N2MkDuVHwpPcgkhHkJgCQuuvT+qZI'} | ${0.65}
${'sampleOldFalsePositivesBase64'} | ${0.34}
${'residencyStandard2DMultisampleBlockShape'} | ${0.25}
${'myNameSpace1/MyNameSpace2/mynamespace3/myserviceName'} | ${0.4}
${'PxTransform12transformInvERKS0_'} | ${0.35}
${'_ZNK5physx11PxTransform12transformInvERKNS_6PxVec3E'} | ${0.43}
${'_ZNK5physx11PxERKNS_6PxVec3E'} | ${0.57}
str | expected
${''} | ${0}
${'hello'} | ${0.2}
${'café'} | ${0.25}
${'café'.normalize('NFD')} | ${0.2}
${'Hello'} | ${0.4}
${'expectCategorizeStringStrToBeExpected'} | ${0.35}
${'expect categorizeString str .toBe expected'} | ${0.33}
${'H4sIAAAAAAAAA72d3ZLjNpK276X6O6ztFX4lWxnPN5whD3jsGd3DzomHGqJVa21StLqp9uOibn3LwgIKiD5AkyQ7Dpyu0QmkmQy'} | ${0.65}
${'izfrNTmQLnfsLzi2Wb9xPz2Qj9fQYGgeug3N2MkDuVHwpPcgkhHkJgCQuuvT+qZI'} | ${0.65}
${'sampleOldFalsePositivesBase64'} | ${0.34}
${'residencyStandard2DMultisampleBlockShape'} | ${0.25}
${'myNameSpace1/MyNameSpace2/mynamespace3/myserviceName'} | ${0.4}
${'PxTransform12transformInvERKS0_'} | ${0.32}
${'_ZNK5physx11PxTransform12transformInvERKNS_6PxVec3E'} | ${0.39}
${'_ZNK5physx11PxERKNS_6PxVec3E'} | ${0.5}
${'To_EntityDto_And_To_DrivedEntityDto'} | ${0.45}
`('isRandomString $str', ({ str, expected }) => {
expect(scoreRandomString(str))
.greaterThanOrEqual(expected)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export function categorizeString(s: string): string {
.replaceAll(/\p{Lu}+/gu, '2')
.replaceAll(/\p{Ll}+/gu, '1')
.replaceAll(/\p{M}/gu, '4')
.replaceAll('_', '')
.replaceAll(/[-_.']+/g, '3');
return n;
}

0 comments on commit 2ff6b05

Please sign in to comment.