dlib icon indicating copy to clipboard operation
dlib copied to clipboard

Ensure that successive calls to HardContext return the same object.

Open josecv opened this issue 4 years ago • 1 comments

Signed-off-by: Jose Cortes [email protected]

josecv avatar Sep 10 '21 14:09 josecv

I agree with the semantics you're going for. But I think your implementation is buggy.

If I make the change to your test:

diff --git a/dcontext/hardsoft_test.go b/dcontext/hardsoft_test.go
index 90ba569..2ad9d4f 100644
--- a/dcontext/hardsoft_test.go
+++ b/dcontext/hardsoft_test.go
@@ -23,6 +23,7 @@ func TestContextIdentity(t *testing.T) {
 	if ctx == hardCtx {
 		t.Fatalf("soft context %+v treated same as hard context %+v", ctx, hardCtx)
 	}
+	hardCtx = context.WithValue(hardCtx, valkey{}, 0)
 	if hardCtx != dcontext.HardContext(hardCtx) {
 		t.Fatalf("hard context %+v treated differently than hard context %+v", hardCtx, dcontext.HardContext(hardCtx))
 	}

then the test fails, and it should not fail.

LukeShu avatar Sep 13 '21 18:09 LukeShu