Skip to content

Commit da59201

Browse files
g41797linkdotnet
authored andcommitted
Added tests and changed CHANGELOG
1 parent 18c782f commit da59201

File tree

3 files changed

+44
-6
lines changed

3 files changed

+44
-6
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@ All notable changes to **ValueStringBuilder** will be documented in this file. T
44

55
<!-- The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) -->
66

7-
## [Unreleased]
7+
## [Unreleased] - 2023-10-19
8+
9+
### Added
10+
11+
- `SetRuneAt` is added to the string builder
12+
- `Skip` is added to the string builder
813

914
## [0.10.0] - 2023-08-31
1015

stringbuilder.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -337,11 +337,6 @@ func createTrimSet(chars ...rune) map[rune]bool {
337337
return trimSet
338338
}
339339

340-
// Set initial position
341-
func (s *StringBuilder) Rewind() {
342-
s.position = 0
343-
}
344-
345340
// Sets the rune at the specific position
346341
func (s *StringBuilder) SetRuneAt(index int, val rune) error {
347342
if index < 0 {

stringbuilder_test.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,3 +493,41 @@ func slicesEqual(a []int, b []int) bool {
493493

494494
return true
495495
}
496+
497+
func TestSetRuneAt(t *testing.T) {
498+
sb := NewStringBuilderFromString("Hello")
499+
500+
err := sb.SetRuneAt(10, 'a')
501+
if err == nil {
502+
t.Errorf("Should throw error but did not")
503+
}
504+
505+
err = sb.SetRuneAt(0, 'a')
506+
if err != nil {
507+
t.Errorf("Should not throw error")
508+
}
509+
510+
if result := sb.RuneAt(0); result != 'a' {
511+
t.Errorf("Actual %q, Expected: %q", result, 'e')
512+
}
513+
}
514+
515+
func TestSkip(t *testing.T) {
516+
sb := NewStringBuilderFromString("Hello")
517+
518+
err := sb.Skip(1)
519+
if err == nil {
520+
t.Errorf("Should throw error but did not")
521+
}
522+
523+
sb.Clear()
524+
525+
err = sb.Skip(1)
526+
if err != nil {
527+
t.Errorf("Should not throw error")
528+
}
529+
530+
if sb.position != 1 {
531+
t.Errorf("Actual position %d, Expected: 1", sb.position)
532+
}
533+
}

0 commit comments

Comments
 (0)