|
|
|
@ -33,7 +33,7 @@ func TestIntern(t *testing.T) {
|
|
|
|
|
interned, ok := interner.pool[testString]
|
|
|
|
|
|
|
|
|
|
testutil.Equals(t, true, ok)
|
|
|
|
|
testutil.Assert(t, interned.refs.Load() == 1, fmt.Sprintf("expected refs to be 1 but it was %d", interned.refs))
|
|
|
|
|
testutil.Assert(t, interned.refs.Load() == 1, fmt.Sprintf("expected refs to be 1 but it was %d", interned.refs.Load()))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestIntern_MultiRef(t *testing.T) {
|
|
|
|
@ -44,13 +44,13 @@ func TestIntern_MultiRef(t *testing.T) {
|
|
|
|
|
interned, ok := interner.pool[testString]
|
|
|
|
|
|
|
|
|
|
testutil.Equals(t, true, ok)
|
|
|
|
|
testutil.Assert(t, interned.refs.Load() == 1, fmt.Sprintf("expected refs to be 1 but it was %d", interned.refs))
|
|
|
|
|
testutil.Assert(t, interned.refs.Load() == 1, fmt.Sprintf("expected refs to be 1 but it was %d", interned.refs.Load()))
|
|
|
|
|
|
|
|
|
|
interner.intern(testString)
|
|
|
|
|
interned, ok = interner.pool[testString]
|
|
|
|
|
|
|
|
|
|
testutil.Equals(t, true, ok)
|
|
|
|
|
testutil.Assert(t, interned.refs.Load() == 2, fmt.Sprintf("expected refs to be 2 but it was %d", interned.refs))
|
|
|
|
|
testutil.Assert(t, interned.refs.Load() == 2, fmt.Sprintf("expected refs to be 2 but it was %d", interned.refs.Load()))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestIntern_DeleteRef(t *testing.T) {
|
|
|
|
@ -61,7 +61,7 @@ func TestIntern_DeleteRef(t *testing.T) {
|
|
|
|
|
interned, ok := interner.pool[testString]
|
|
|
|
|
|
|
|
|
|
testutil.Equals(t, true, ok)
|
|
|
|
|
testutil.Assert(t, interned.refs.Load() == 1, fmt.Sprintf("expected refs to be 1 but it was %d", interned.refs))
|
|
|
|
|
testutil.Assert(t, interned.refs.Load() == 1, fmt.Sprintf("expected refs to be 1 but it was %d", interned.refs.Load()))
|
|
|
|
|
|
|
|
|
|
interner.release(testString)
|
|
|
|
|
_, ok = interner.pool[testString]
|
|
|
|
@ -75,7 +75,7 @@ func TestIntern_MultiRef_Concurrent(t *testing.T) {
|
|
|
|
|
interner.intern(testString)
|
|
|
|
|
interned, ok := interner.pool[testString]
|
|
|
|
|
testutil.Equals(t, true, ok)
|
|
|
|
|
testutil.Assert(t, interned.refs.Load() == 1, fmt.Sprintf("expected refs to be 1 but it was %d", interned.refs))
|
|
|
|
|
testutil.Assert(t, interned.refs.Load() == 1, fmt.Sprintf("expected refs to be 1 but it was %d", interned.refs.Load()))
|
|
|
|
|
|
|
|
|
|
go interner.release(testString)
|
|
|
|
|
|
|
|
|
@ -87,5 +87,5 @@ func TestIntern_MultiRef_Concurrent(t *testing.T) {
|
|
|
|
|
interned, ok = interner.pool[testString]
|
|
|
|
|
interner.mtx.RUnlock()
|
|
|
|
|
testutil.Equals(t, true, ok)
|
|
|
|
|
testutil.Assert(t, interned.refs.Load() == 1, fmt.Sprintf("expected refs to be 1 but it was %d", interned.refs))
|
|
|
|
|
testutil.Assert(t, interned.refs.Load() == 1, fmt.Sprintf("expected refs to be 1 but it was %d", interned.refs.Load()))
|
|
|
|
|
}
|
|
|
|
|