Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Add a few Marshal.*HGlobal tests#4162

Merged
stephentoub merged 2 commits intodotnet:masterfrom
stephentoub:marshal_tests
Oct 28, 2015
Merged

Add a few Marshal.*HGlobal tests#4162
stephentoub merged 2 commits intodotnet:masterfrom
stephentoub:marshal_tests

Conversation

@stephentoub
Copy link
Member

I'm implementing Marshal.ReAllocHGlobal in coreclr on Unix, and we didn't have any tests exercising it.

(This will fail the Linux CI leg until the change has been PR'd through coreclr.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the class name of this test class called MarshalTests and yet the source filename doesn't match. The filename is called Marshal.cs ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I simply followed the naming scheme used by the rest of the project.

... or at least I thought I did. The rest of the project is inconsistent. I can update it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx. I always try to reconcile inconsistency when I see it if I'm adding/modifying more stuff to an existing project.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't here be checked that a memory is readable/writeable?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do that in the test below; didn't seem like it would need to be done in every test. Here I just wanted to make sure that the various overloads of AllocHGlobal produced a non-zero IntPtr. I can update it, though.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In next only writeable is checked. In L#45 you read from that is reallocated, so technically it's not the same. Maybe it is very strict, but if you hypothetically delete your reallocation test, then it Alloc method will be untested.

Implementing Marshal.ReAllocHGlobal in coreclr, and we didn't have any tests exercising it.
@stephentoub
Copy link
Member Author

@dotnet-bot test this please (dependent functionality merged in coreclr)

stephentoub added a commit that referenced this pull request Oct 28, 2015
Add a few Marshal.*HGlobal tests
@stephentoub stephentoub merged commit 7086e5c into dotnet:master Oct 28, 2015
@stephentoub stephentoub deleted the marshal_tests branch November 4, 2015 19:36
@karelz karelz modified the milestone: 1.0.0-rtm Dec 3, 2016
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants