Skip to content

Commit d2193e1

Browse files
committed
refactor: change the name of method GetCheck to GetAndCheck
1 parent 74031b0 commit d2193e1

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

mapkeyvalue.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ func (r *MapKeyValue[K, T]) Set(key K, value T) {
5454
r.data[key] = value
5555
}
5656

57-
// GetCheck returns the value associated with the key if this exist also a
57+
// GetAndCheck returns the value associated with the key if this exist also a
5858
// boolean value if this exist of not.
59-
func (r *MapKeyValue[K, T]) GetCheck(key K) (T, bool) {
59+
func (r *MapKeyValue[K, T]) GetAndCheck(key K) (T, bool) {
6060
r.mu.RLock()
6161
defer r.mu.RUnlock()
6262

mapkeyvalue_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,8 @@ func TestSet(t *testing.T) {
203203
})
204204
}
205205

206-
func TestGetCheck(t *testing.T) {
207-
t.Run("test GetCheck for NewMapKeyValue[string, struct] key exist", func(t *testing.T) {
206+
func TestGetAndCheck(t *testing.T) {
207+
t.Run("test GetAndCheck for NewMapKeyValue[string, struct] key exist", func(t *testing.T) {
208208
type testStruct struct {
209209
Name string
210210
value float64
@@ -217,9 +217,9 @@ func TestGetCheck(t *testing.T) {
217217
t.Errorf("Expected size to be %v, got %v", 1, kv.Size())
218218
}
219219

220-
value, ok := kv.GetCheck("Archimedes")
220+
value, ok := kv.GetAndCheck("Archimedes")
221221
if !ok {
222-
t.Errorf("Expected GetCheck to return true, got %v", ok)
222+
t.Errorf("Expected GetAndCheck to return true, got %v", ok)
223223
}
224224

225225
if value.Name != "This is Archimedes' Constant (Pi)" {
@@ -230,7 +230,7 @@ func TestGetCheck(t *testing.T) {
230230
}
231231
})
232232

233-
t.Run("test GetCheck for NewMapKeyValue[string, struct] key doesn't exist", func(t *testing.T) {
233+
t.Run("test GetAndCheck for NewMapKeyValue[string, struct] key doesn't exist", func(t *testing.T) {
234234
type testStruct struct {
235235
Name string
236236
value float64
@@ -243,9 +243,9 @@ func TestGetCheck(t *testing.T) {
243243
t.Errorf("Expected size to be %v, got %v", 1, kv.Size())
244244
}
245245

246-
_, ok := kv.GetCheck("Euler")
246+
_, ok := kv.GetAndCheck("Euler")
247247
if ok {
248-
t.Errorf("Expected GetCheck to return true, got %v", ok)
248+
t.Errorf("Expected GetAndCheck to return true, got %v", ok)
249249
}
250250
})
251251
}

0 commit comments

Comments
 (0)