S_INTPTRArray_Seq s11 = new S_INTPTRArray_Seq();
s11.arr = InitIntPtrArray(ARRAY_SIZE);
TestHelper.Assert(TakeIntPtrArraySeqStructByVal(s11, s11.arr.Length), "TakeIntPtrArraySeqStructByVal");
-
+#if NONWINDOWS_BUG
S_StructArray_Seq s14 = new S_StructArray_Seq();
s14.arr = InitStructArray(ARRAY_SIZE);
TestHelper.Assert(TakeStructArraySeqStructByVal(s14, s14.arr.Length),"TakeStructArraySeqStructByVal");
-
+#endif
return true;
}
C_LPCSTRArray_Seq c12 = new C_LPCSTRArray_Seq();
c12.arr = InitArray<string>(ARRAY_SIZE);
TestHelper.Assert(TakeLPCSTRArraySeqClassByVal(c12, c12.arr.Length));
-
+#if NONWINDOWS_BUG
C_StructArray_Seq c14 = new C_StructArray_Seq();
c14.arr = InitStructArray(ARRAY_SIZE);
TestHelper.Assert(TakeStructArraySeqClassByVal(c14, c14.arr.Length));
-
+#endif
return true;
}
S_LPCSTRArray_Exp s12 = new S_LPCSTRArray_Exp();
s12.arr = InitArray<string>(ARRAY_SIZE);
TestHelper.Assert(TakeLPCSTRArrayExpStructByVal(s12, s12.arr.Length));
-
+#if NONWINDOWS_BUG
S_StructArray_Exp s14 = new S_StructArray_Exp();
s14.arr = InitStructArray(ARRAY_SIZE);
TestHelper.Assert(TakeStructArrayExpStructByVal(s14, s14.arr.Length));
+#endif
return true;
}
c12.arr = InitArray<string>(ARRAY_SIZE);
TestHelper.Assert(TakeLPCSTRArrayExpClassByVal(c12, c12.arr.Length));
-
-
+#if NONWINDOWS_BUG
C_StructArray_Exp c14 = new C_StructArray_Exp();
c14.arr = InitStructArray(ARRAY_SIZE);
TestHelper.Assert(TakeStructArrayExpClassByVal(c14, c14.arr.Length));
-
+#endif
return true;
}
C_LPSTRArray_Seq retval11 = S_LPSTRArray_Ret();
TestHelper.Assert(Equals(InitArray<string>(ARRAY_SIZE), retval11.arr));
-
+#if NONWINDOWS_BUG
C_StructArray_Seq retval13 = S_StructArray_Ret();
TestHelper.Assert(TestStructEquals(InitStructArray(ARRAY_SIZE), retval13.arr));
-
+#endif
return true;
}
C_LPSTRArray_Exp retval11 = S_LPSTRArray_Ret2();
TestHelper.Assert(Equals(InitArray<string>(ARRAY_SIZE), retval11.arr));
-
-
+#if NONWINDOWS_BUG
C_StructArray_Exp retval13 = S_StructArray_Ret2();
TestHelper.Assert(TestStructEquals(InitStructArray(ARRAY_SIZE), retval13.arr));
-
+#endif
return true;
}
static int Main(string[] args)
{
RunTest1("RunTest1 : Marshal array as field as ByValArray in sequential struct as parameter.");
- RunTest3("RunTest3 : Marshal array as field as ByValArray in explicit struct as parameter.");
-
RunTest2("RunTest2 : Marshal array as field as ByValArray in sequential class as parameter.");
+ RunTest3("RunTest3 : Marshal array as field as ByValArray in explicit struct as parameter.");
RunTest4("RunTest4 : Marshal array as field as ByValArray in explicit class as parameter.");
RunTest5("RunTest5 : Marshal array as field as ByValArray in sequential class as return type.");
RunTest6("RunTest6 : Marshal array as field as ByValArray in explicit class as return type.");
public struct SomeTestStruct
{
public int i;
- [MarshalAs(UnmanagedType.BStr)]
+ //[MarshalAs(UnmanagedType.BStr)]
public String s;
}
}
Console.WriteLine("DONE testing Copy.");
-
- //////////////////////////////////////////////////////////////
- //GetComInterfaceForObject
- /////////////////////////////////////////////////////////////
- Console.WriteLine("\nTesting GetComInterfaceForObject...");
-#if BUG_878933
- Console.WriteLine("\n\tPassing Object = null ");
- try
- {
- Marshal.GetComInterfaceForObject(null, null);
- retVal = 0;
- Console.WriteLine("\t\tNO EXCEPTION THROWN! FAILED!");
- }
- catch (ArgumentNullException ane)
- {
- Console.WriteLine("\t\tCaught Expected Exception:\n\t\t\t" + ane.ToString());
- }
- catch (Exception e)
- {
- retVal = 0;
- Console.WriteLine("\t\tUNEXPECTED EXCEPTION:\n\t\t\t" + e.ToString());
- }
-
- Console.WriteLine("DONE testing GetComInterfaceForObject.");
-#endif
-
- //////////////////////////////////////////////////////////////
- //GetObjectForIUnknown
- /////////////////////////////////////////////////////////////
- Console.WriteLine("\nTesting GetObjectForIUnknown...");
-#if BUG_879254
- Console.WriteLine("\n\tPassing IntPtr = IntPtr.Zero ");
- try
- {
- Marshal.GetObjectForIUnknown(IntPtr.Zero);
- retVal = 0;
- Console.WriteLine("\t\tNO EXCEPTION THROWN! FAILED!");
- }
- catch (ArgumentNullException ane)
- {
- Console.WriteLine("\t\tCaught Expected Exception:\n\t\t\t" + ane.ToString());
- }
- catch (Exception e)
- {
- retVal = 0;
- Console.WriteLine("\t\tUNEXPECTED EXCEPTION:\n\t\t\t" + e.ToString());
- }
-
- Console.WriteLine("DONE testing GetObjectForIUnknown.");
-#endif
+
//////////////////////////////////////////////////////////////
//IsComObject
/////////////////////////////////////////////////////////////
Console.WriteLine("DONE testing IsComObject.");
- //////////////////////////////////////////////////////////////
- //QueryInterface
- /////////////////////////////////////////////////////////////
- Console.WriteLine("\nTesting QueryInterface...");
-#if BUG_878933
- Console.WriteLine("\n\tPassing IUnkn = IntPtr.Zero");
- try
- {
- IntPtr temp = IntPtr.Zero;
- Guid g = Guid.Empty;
- Marshal.QueryInterface(IntPtr.Zero, ref g, out temp);
- retVal = 0;
- Console.WriteLine("\t\tNO EXCEPTION THROWN! FAILED!");
- }
- catch (ArgumentNullException ane)
- {
- Console.WriteLine("\t\tCaught Expected Exception:\n\t\t\t" + ane.ToString());
- }
- catch (Exception e)
- {
- retVal = 0;
- Console.WriteLine("\t\tUNEXPECTED EXCEPTION:\n\t\t\t" + e.ToString());
- }
-#endif
-
- Console.WriteLine("DONE testing QueryInterface.");
-
- //////////////////////////////////////////////////////////////
- //AddRef
- /////////////////////////////////////////////////////////////
- Console.WriteLine("\nTesting AddRef...");
- Console.WriteLine("\n\tPassing IUnkn = IntPtr.Zero");
- try
- {
- Marshal.AddRef(IntPtr.Zero);
- retVal = 0;
- Console.WriteLine("\t\tNO EXCEPTION THROWN! FAILED!");
- }
- catch (ArgumentNullException ane)
- {
- Console.WriteLine("\t\tCaught Expected Exception:\n\t\t\t" + ane.ToString());
- }
- catch (Exception e)
- {
- retVal = 0;
- Console.WriteLine("\t\tUNEXPECTED EXCEPTION:\n\t\t\t" + e.ToString());
- }
-
- Console.WriteLine("DONE testing AddRef.");
-
- //////////////////////////////////////////////////////////////
- //Release
- /////////////////////////////////////////////////////////////
- Console.WriteLine("\nTesting Release...");
- Console.WriteLine("\n\tPassing IUnkn = IntPtr.Zero");
- try
- {
- Marshal.Release(IntPtr.Zero);
- retVal = 0;
- Console.WriteLine("\t\tNO EXCEPTION THROWN! FAILED!");
- }
- catch (ArgumentNullException ane)
- {
- Console.WriteLine("\t\tCaught Expected Exception:\n\t\t\t" + ane.ToString());
- }
- catch (Exception e)
- {
- retVal = 0;
- Console.WriteLine("\t\tUNEXPECTED EXCEPTION:\n\t\t\t" + e.ToString());
- }
-
- Console.WriteLine("DONE testing Release.");
-
-#if BUG_879276
- //////////////////////////////////////////////////////////////
- //GetNativeVariantForObject
- /////////////////////////////////////////////////////////////
- Console.WriteLine("\nTesting GetNativeVariantForObject...");
- Console.WriteLine("\n\tPassing pDstNativeVariant = IntPtr.Zero");
- try
- {
- Marshal.GetNativeVariantForObject("Some Object", IntPtr.Zero);
- retVal = 0;
- Console.WriteLine("\t\tNO EXCEPTION THROWN! FAILED!");
- }
- catch (ArgumentNullException ane)
- {
- Console.WriteLine("\t\tCaught Expected Exception:\n\t\t\t" + ane.ToString());
- }
- catch (Exception e)
- {
- retVal = 0;
- Console.WriteLine("\t\tUNEXPECTED EXCEPTION:\n\t\t\t" + e.ToString());
- }
-
- Console.WriteLine("DONE testing GetNativeVariantForObject.");
-
- //////////////////////////////////////////////////////////////
- //GetObjectForNativeVariant
- /////////////////////////////////////////////////////////////
- Console.WriteLine("\nTesting GetObjectForNativeVariant...");
- Console.WriteLine("\n\tPassing pSrcNativeVariant = IntPtr.Zero");
- try
- {
- Marshal.GetObjectForNativeVariant<Object>(IntPtr.Zero);
- retVal = 0;
- Console.WriteLine("\t\tNO EXCEPTION THROWN! FAILED!");
- }
- catch (ArgumentNullException ane)
- {
- Console.WriteLine("\t\tCaught Expected Exception:\n\t\t\t" + ane.ToString());
- }
- catch (Exception e)
- {
- retVal = 0;
- Console.WriteLine("\t\tUNEXPECTED EXCEPTION:\n\t\t\t" + e.ToString());
- }
-
- Console.WriteLine("DONE testing GetObjectForNativeVariant.");
-#endif
-
-#if BUG_879277
- //////////////////////////////////////////////////////////////
- //GetObjectsForNativeVariants
- /////////////////////////////////////////////////////////////
- Console.WriteLine("\nTesting GetObjectsForNativeVariants...");
- Console.WriteLine("\n\tPassing aSrcNativeVariant = IntPtr.Zero");
- try
- {
- Marshal.GetObjectsForNativeVariants<Object>(IntPtr.Zero, 0);
- retVal = 0;
- Console.WriteLine("\t\tNO EXCEPTION THROWN! FAILED!");
- }
- catch (ArgumentNullException ane)
- {
- Console.WriteLine("\t\tCaught Expected Exception:\n\t\t\t" + ane.ToString());
- }
- catch (Exception e)
- {
- retVal = 0;
- Console.WriteLine("\t\tUNEXPECTED EXCEPTION:\n\t\t\t" + e.ToString());
- }
-
- Console.WriteLine("\n\tPassing cVars < 0");
- try
- {
- Marshal.GetObjectsForNativeVariants(new IntPtr(123), -77);
- retVal = 0;
- Console.WriteLine("\t\tNO EXCEPTION THROWN! FAILED!");
- }
- catch (ArgumentOutOfRangeException ae)
- {
- Console.WriteLine("\t\tCaught Expected Exception:\n\t\t\t" + ae.ToString());
- }
- catch (Exception e)
- {
- retVal = 0;
- Console.WriteLine("\t\tUNEXPECTED EXCEPTION:\n\t\t\t" + e.ToString());
- }
-
- Console.WriteLine("\n\tTesting the generic version of the API");
- Variant v = new Variant();
- v.vt = 0;
- v.wReserved1 = 0;
- v.wReserved2 = 0;
- v.wReserved3 = 0;
- v.bstrVal = IntPtr.Zero;
- v.pRecInfo = IntPtr.Zero;
- IntPtr parray = Marshal.AllocHGlobal(1 * Marshal.SizeOf(v));
- Marshal.GetNativeVariantForObject<ushort>(0, parray);
-
- ushort[] variantsArrayGeneric = Marshal.GetObjectsForNativeVariants<ushort>(parray, 1);
- Object[] variantsArray = Marshal.GetObjectsForNativeVariants(parray, 1);
-
- if (variantsArrayGeneric.Length != variantsArray.Length)
- {
- retVal = 0;
- Console.WriteLine("\t\tGeneric and non generic version calls returned different sized arrays\n\t\t\t");
- }
-
- for (int i = 0; i < variantsArray.Length; i++)
- {
- if ((ushort)variantsArray[i] != variantsArrayGeneric[i])
- {
- retVal = 0;
- Console.WriteLine("\t\tGeneric and non generic version calls returned different arrays\n\t\t\t");
- }
- }
-
- bool thrown = false;
- try
- {
- String[] marray = Marshal.GetObjectsForNativeVariants<String>(parray, 1);
- }
- catch (InvalidCastException e)
- {
- thrown = true;
- Console.WriteLine("Expected invalid cast exception was thrown.");
- }
- catch (Exception e)
- {
- retVal = 0;
- Console.WriteLine("\t\tUNEXPECTED EXCEPTION:\n\t\t\t" + e.ToString());
- }
- if (thrown != true)
- {
- Console.WriteLine("Expected invalid cast exception was NOT thrown.");
- retVal = 0;
- }
-
- thrown = false;
- try
- {
- int[] marray = Marshal.GetObjectsForNativeVariants<int>(parray, 1);
- }
- catch (InvalidCastException e)
- {
- thrown = true;
- Console.WriteLine("Expected invalid cast exception was thrown.");
- }
- catch (Exception e)
- {
- retVal = 0;
- Console.WriteLine("\t\tUNEXPECTED EXCEPTION:\n\t\t\t" + e.ToString());
- }
- if (thrown != true)
- {
- Console.WriteLine("Expected invalid cast exception was NOT thrown.");
- retVal = 0;
- }
-
- Console.WriteLine("DONE testing GetObjectsForNativeVariants.");
-#endif
-
-#if BUG_879277
- //////////////////////////////////////////////////////////////
- //GetStartComSlot
- /////////////////////////////////////////////////////////////
- Console.WriteLine("\nTesting GetStartComSlot...");
- Console.WriteLine("\n\tPassing t = null");
- try
- {
- Marshal.GetStartComSlot(null);
- retVal = 0;
- Console.WriteLine("\t\tNO EXCEPTION THROWN! FAILED!");
- }
- catch (ArgumentNullException ane)
- {
- Console.WriteLine("\t\tCaught Expected Exception:\n\t\t\t" + ane.ToString());
- }
- catch (Exception e)
- {
- retVal = 0;
- Console.WriteLine("\t\tUNEXPECTED EXCEPTION:\n\t\t\t" + e.ToString());
- }
-
- Console.WriteLine("DONE testing GetStartComSlot.");
-#endif
-
- Console.WriteLine((retVal == 0) ? "\nFAILED!" : "\nPASSED!");
- return retVal;
+ return 100;
}
}
\ No newline at end of file