-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9fbe896
commit bbebf9c
Showing
3 changed files
with
21 additions
and
0 deletions.
There are no files selected for viewing
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,3 @@ | ||
#codeing_case | ||
|
||
텍스트가 스네이크 케이스인지 확인하는 함수 |
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,14 @@ | ||
import { describe, expect, it } from 'vitest'; | ||
import { isSnakeCase } from './is-snake-case.ts'; | ||
|
||
describe('isSnakeCase', () => { | ||
it('should return true for valid snake case strings', () => { | ||
expect(isSnakeCase('this_is_snake_case')).toBe(true); | ||
expect(isSnakeCase('snake_case')).toBe(true); | ||
expect(isSnakeCase('snake_case123')).toBe(false); | ||
}); | ||
|
||
it('should return false for non-snake case strings', () => { | ||
expect(isSnakeCase('ThisIsNotSnakeCase')).toBe(false); | ||
}); | ||
}); |
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,4 @@ | ||
export function isSnakeCase(text: string): boolean { | ||
const snakeCaseRegex = /^[a-z0-9]+(_[a-z0-9]+)*$/; | ||
return snakeCaseRegex.test(text); | ||
} |