|
|
|
@ -19,7 +19,6 @@
|
|
|
|
|
package remote |
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
|
"fmt" |
|
|
|
|
"testing" |
|
|
|
|
"time" |
|
|
|
|
|
|
|
|
@ -33,7 +32,7 @@ func TestIntern(t *testing.T) {
|
|
|
|
|
interned, ok := interner.pool[testString] |
|
|
|
|
|
|
|
|
|
require.True(t, ok) |
|
|
|
|
require.Equal(t, int64(1), interned.refs.Load(), fmt.Sprintf("expected refs to be 1 but it was %d", interned.refs.Load())) |
|
|
|
|
require.Equalf(t, int64(1), interned.refs.Load(), "expected refs to be 1 but it was %d", interned.refs.Load()) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func TestIntern_MultiRef(t *testing.T) { |
|
|
|
@ -44,13 +43,13 @@ func TestIntern_MultiRef(t *testing.T) {
|
|
|
|
|
interned, ok := interner.pool[testString] |
|
|
|
|
|
|
|
|
|
require.True(t, ok) |
|
|
|
|
require.Equal(t, int64(1), interned.refs.Load(), fmt.Sprintf("expected refs to be 1 but it was %d", interned.refs.Load())) |
|
|
|
|
require.Equalf(t, int64(1), interned.refs.Load(), "expected refs to be 1 but it was %d", interned.refs.Load()) |
|
|
|
|
|
|
|
|
|
interner.intern(testString) |
|
|
|
|
interned, ok = interner.pool[testString] |
|
|
|
|
|
|
|
|
|
require.True(t, ok) |
|
|
|
|
require.Equal(t, int64(2), interned.refs.Load(), fmt.Sprintf("expected refs to be 2 but it was %d", interned.refs.Load())) |
|
|
|
|
require.Equalf(t, int64(2), interned.refs.Load(), "expected refs to be 2 but it was %d", interned.refs.Load()) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func TestIntern_DeleteRef(t *testing.T) { |
|
|
|
@ -61,7 +60,7 @@ func TestIntern_DeleteRef(t *testing.T) {
|
|
|
|
|
interned, ok := interner.pool[testString] |
|
|
|
|
|
|
|
|
|
require.True(t, ok) |
|
|
|
|
require.Equal(t, int64(1), interned.refs.Load(), fmt.Sprintf("expected refs to be 1 but it was %d", interned.refs.Load())) |
|
|
|
|
require.Equalf(t, int64(1), interned.refs.Load(), "expected refs to be 1 but it was %d", interned.refs.Load()) |
|
|
|
|
|
|
|
|
|
interner.release(testString) |
|
|
|
|
_, ok = interner.pool[testString] |
|
|
|
@ -75,7 +74,7 @@ func TestIntern_MultiRef_Concurrent(t *testing.T) {
|
|
|
|
|
interner.intern(testString) |
|
|
|
|
interned, ok := interner.pool[testString] |
|
|
|
|
require.True(t, ok) |
|
|
|
|
require.Equal(t, int64(1), interned.refs.Load(), fmt.Sprintf("expected refs to be 1 but it was %d", interned.refs.Load())) |
|
|
|
|
require.Equalf(t, int64(1), interned.refs.Load(), "expected refs to be 1 but it was %d", interned.refs.Load()) |
|
|
|
|
|
|
|
|
|
go interner.release(testString) |
|
|
|
|
|
|
|
|
@ -87,5 +86,5 @@ func TestIntern_MultiRef_Concurrent(t *testing.T) {
|
|
|
|
|
interned, ok = interner.pool[testString] |
|
|
|
|
interner.mtx.RUnlock() |
|
|
|
|
require.True(t, ok) |
|
|
|
|
require.Equal(t, int64(1), interned.refs.Load(), fmt.Sprintf("expected refs to be 1 but it was %d", interned.refs.Load())) |
|
|
|
|
require.Equalf(t, int64(1), interned.refs.Load(), "expected refs to be 1 but it was %d", interned.refs.Load()) |
|
|
|
|
} |
|
|
|
|