public static void set_callback_inherited_called_from_c() { setup(); WithOverride obj = new WithOverride(); free_called_set(false); obj.CallSetCallback(); Test.Assert(obj.set_called, "set_callback override must have been called"); Test.Assert(!obj.invoke_called, "invoke_callback must not have been called"); Test.Assert(!free_called_get(), "call_set_callback must not call the free callback"); obj.set_called = false; int x = obj.CallCallback(42); Test.Assert(!obj.set_called, "set_callback override must not have been called"); Test.Assert(obj.invoke_called, "set_callback in virtual should not call the callback"); Test.Assert(!free_called_get(), "call_callback must not call the free callback"); Test.AssertEquals(42 * 3, x); setup(); obj.set_called = false; obj.invoke_called = false; free_called_set(false); // Should release the handle to the wrapper allocated when calling set_callback from C. obj.SetCallback(twice); Test.CollectAndIterate(300, 10); Test.Assert(obj.set_called, "set_callback override must have been called"); Test.Assert(!obj.invoke_called, "invoke_callback must not have been called"); Test.Assert(free_called_get(), "free callback must have been called"); obj.set_called = false; free_called_set(false); x = obj.CallCallback(42); Test.Assert(!obj.set_called, "set_callback override must not have been called"); Test.Assert(obj.invoke_called, "set_callback in virtual should not call the callback"); Test.Assert(!free_called_get(), "must not call old free_callback on new callback"); Test.Assert(called, "call_callback must call a callback"); Test.AssertEquals(42 * 2, x); obj.Dispose(); }
public static void set_callback_inherited_with_override() { setup(); WithOverride obj = new WithOverride(); obj.SetCallback(thrice); Test.Assert(obj.set_called, "set_callback override must have been called"); Test.Assert(!obj.invoke_called, "invoke_callback must not have been called"); obj.set_called = false; int x = obj.CallCallback(42); Test.Assert(!obj.set_called, "set_callback override must not have been called"); Test.Assert(obj.invoke_called, "set_callback in virtual should not call the callback"); Test.Assert(called, "call_callback must call a callback"); Test.AssertEquals(42 * 3, x); obj.Dispose(); }