Skip to content

Conversation

@karngyan
Copy link
Member

Add comprehensive case conversion utilities

This PR introduces several new string case conversion functions to complement the existing PascalCase functionality:

New Functions Added:

  • CamelCase: Converts strings to camelCase format
  • KebabCase: Converts strings to kebab-case with customizable separators
  • SnakeCase: Converts strings to snake_case format
  • TrainCase: Converts strings to Train-Case format
  • FlatCase: Converts strings to flatcase (no separators)
  • UpperFirst: Capitalizes first character
  • LowerFirst: Lowercases first character

Key Improvements:

  • Enhanced joinWords function to handle empty word filtering
  • Support for generic types with StringOrStringSlice constraint
  • Comprehensive test coverage for all new functions including edge cases
  • Consistent API design across all case conversion functions

Testing:

  • 254 new test cases covering various input scenarios
  • Edge case handling for unicode characters, numbers, and mixed separators
  • Full backward compatibility maintained

All functions support both string and []string inputs with type safety through generics.

Copilot AI review requested due to automatic review settings September 17, 2025 21:55
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds comprehensive case conversion utilities to complement the existing PascalCase functionality. The implementation provides seven new string manipulation functions that handle various common case formats.

  • Adds CamelCase, KebabCase, SnakeCase, TrainCase, FlatCase, UpperFirst, and LowerFirst functions
  • Enhances the joinWords function to support empty word filtering for better case conversion handling
  • Provides comprehensive test coverage with 254 new test cases covering edge cases and various input scenarios

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
sx.go Implements seven new case conversion functions and enhances joinWords with empty word filtering
sx_test.go Adds comprehensive test coverage for all new case conversion functions
.cursor/commands/pr.md Adds PR creation workflow documentation

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@github-actions
Copy link

📊 Code Coverage Report

total:					(statements)			88.7%
Coverage by file
github.com/gomantics/sx/sx.go:14:	isSeparator			100.0%
github.com/gomantics/sx/sx.go:19:	isSeparatorCustom		100.0%
github.com/gomantics/sx/sx.go:24:	isLetterCaseChange		100.0%
github.com/gomantics/sx/sx.go:51:	splitByCaseWithCustomSeparators	100.0%
github.com/gomantics/sx/sx.go:124:	defaultSplitConfig		100.0%
github.com/gomantics/sx/sx.go:131:	WithSeparators			100.0%
github.com/gomantics/sx/sx.go:140:	SplitByCase			100.0%
github.com/gomantics/sx/sx.go:150:	normalizeWord			100.0%
github.com/gomantics/sx/sx.go:158:	capitalizeWord			66.7%
github.com/gomantics/sx/sx.go:172:	joinWords			100.0%
github.com/gomantics/sx/sx.go:209:	WithNormalize			100.0%
github.com/gomantics/sx/sx.go:221:	PascalCase			92.9%
github.com/gomantics/sx/sx.go:249:	lowercaseWord			83.3%
github.com/gomantics/sx/sx.go:263:	CamelCase			93.3%
github.com/gomantics/sx/sx.go:293:	KebabCase			66.7%
github.com/gomantics/sx/sx.go:317:	SnakeCase			100.0%
github.com/gomantics/sx/sx.go:322:	TrainCase			64.3%
github.com/gomantics/sx/sx.go:348:	FlatCase			100.0%
github.com/gomantics/sx/sx.go:353:	UpperFirst			0.0%
github.com/gomantics/sx/sx.go:358:	LowerFirst			0.0%
total:					(statements)			88.7%

@karngyan karngyan merged commit 6a4990c into main Sep 17, 2025
2 checks passed
@karngyan karngyan deleted the camel-case branch September 17, 2025 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants