c# - Assert.AreEqual fails for int and ulong but not long and uint -


well, hope processor not burned, because:

    [testmethod]     public void tenequalten()     {         int64 = 10;         uint32 b = 10;         assert.areequal(a, b);     } 

works fine, this:

    [testmethod]     public void tennotequalten()     {         int32 = 10;         uint64 b = 10;         assert.areequal(a, b);     } 

fails miserably.

have got same results, or me? if yes, ideas, why? if known issue .net 4.5 sorry spam, not find bug.

edit: found duplicate here , explanation here

in first method calling assert.areequal<t>(t expected, t actual) t of type int64, because uint32 implicitly castable int64. same effect if did

    [testmethod]     public void tenequalten()     {         int64 = 10;         uint32 b = 10;         assert.areequal(a, (int64)b);     } 

that why first version passes.

in second version calling assert.areequal(object expected, object actual) fails because different types , therefor not "equal".

you make first version act second version putting 2 numbers inside object let use same overload of assert.

    [testmethod]     public void tenequalten()     {         int64 = 10;         uint32 b = 10;         object c = a;         object d = b;         assert.areequal(c, d);     } 

this method fail same way tennotequalten method fail.


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -