dlib
dlib copied to clipboard
Ensure that successive calls to HardContext return the same object.
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.