Files
skillshare/internal/utils/strings_test.go
T
Willie f5e9d9644e docs: improve README with better structure and content
- Add badges (License, Go version, Release)
- Add ASCII flow diagram showing architecture
- Add Table of Contents for navigation
- Add "Why skillshare?" comparison table
- Add Use Cases section (Individual, Team, Open Source)
- Add FAQ section with common questions
- Add Contributing guide with development setup
- Reorganize sections for better readability
2026-01-14 22:12:56 +08:00

54 lines
1.2 KiB
Go

package utils
import "testing"
func TestIsHidden(t *testing.T) {
tests := []struct {
name string
input string
expected bool
}{
{"empty string", "", false},
{"hidden file", ".hidden", true},
{"hidden directory", ".git", true},
{"normal file", "file.txt", false},
{"normal directory", "src", false},
{"dot only", ".", true},
{"double dot", "..", true},
{"file starting with number", "1file", false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := IsHidden(tt.input)
if got != tt.expected {
t.Errorf("IsHidden(%q) = %v, want %v", tt.input, got, tt.expected)
}
})
}
}
func TestHasTildePrefix(t *testing.T) {
tests := []struct {
name string
input string
expected bool
}{
{"empty string", "", false},
{"tilde path", "~/Documents", true},
{"tilde only", "~", true},
{"absolute path", "/home/user", false},
{"relative path", "./config", false},
{"tilde in middle", "/home/~user", false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := HasTildePrefix(tt.input)
if got != tt.expected {
t.Errorf("HasTildePrefix(%q) = %v, want %v", tt.input, got, tt.expected)
}
})
}
}