typestest.cs

来自「SRI international 发布的OAA框架软件」· CS 代码 · 共 492 行 · 第 1/2 页

CS
492
字号
namespace com.sri.oaa2.tests.dotnet
{
	using System;
	using NUnit.Framework;
	using jnb.com.sri.test.javanetbridge.classes;

	/// <summary>
	/// Summary description for TypesTest.
	/// </summary>
	[TestFixture]
	public class TypesTest
	{
		[Test] public void testOneWay1() {
			TestTypesInterface iRemoteTypes = UnitTestFactory.getFactory().newTestTypesInterface();
			for (int i = 0; i < 1000; i++) {
				iRemoteTypes.doNothing();
			}
		}

		[Test] public void testOneWay2() {
			TestTypesInterface iRemoteTypes = UnitTestFactory.getFactory().newTestTypesInterface();
			for (int i = 0; i < 1000; i++) {
				iRemoteTypes.doNothing(-100, 5.0f,5,132.87,(byte)64,1807645);
			}
		}

		[Test] public void testBool() {
			TestTypesInterface iRemoteTypes = UnitTestFactory.getFactory().newTestTypesInterface();
			assert(iRemoteTypes.identity(true));
			assert(!iRemoteTypes.identity(false));
		}

		[Test] public void testByte() {
			TestTypesInterface iRemoteTypes = UnitTestFactory.getFactory().newTestTypesInterface();
			iRemoteTypes.getByte();
			assertByteIdentity(iRemoteTypes, 0);
			for (short i = byte.MinValue; i <= byte.MaxValue; i++) {
				assertByteIdentity(iRemoteTypes, (byte)i);
			}
		}

		[Test] public void testChar() {
			TestTypesInterface iRemoteTypes = UnitTestFactory.getFactory().newTestTypesInterface();
			iRemoteTypes.getChar();
			assertIntIdentity(iRemoteTypes, 0);
			for (char i = (char)0; i < 1000; i++) {
				assertCharIdentity(iRemoteTypes, i);
			}
			assertIntIdentity(iRemoteTypes, char.MinValue);
			assertIntIdentity(iRemoteTypes, char.MaxValue);
		}

		[Test] public void testShort() {
			TestTypesInterface iRemoteTypes = UnitTestFactory.getFactory().newTestTypesInterface();
			iRemoteTypes.getShort();
			assertShortIdentity(iRemoteTypes, 0);
			for (short i = -1000; i < 1000; i++) {
				assertShortIdentity(iRemoteTypes, i);
			}
			assertShortIdentity(iRemoteTypes, short.MaxValue);
			assertShortIdentity(iRemoteTypes, short.MaxValue);
		}

		[Test] public void testInt() {
			TestTypesInterface iRemoteTypes = UnitTestFactory.getFactory().newTestTypesInterface();
			iRemoteTypes.getInt1();
			iRemoteTypes.getInt2();
			assertIntIdentity(iRemoteTypes, 0);
			for (int i = -1000; i < 1000; i++) {
				assertIntIdentity(iRemoteTypes, i);
			}
			assertIntIdentity(iRemoteTypes, int.MinValue);
			assertIntIdentity(iRemoteTypes, int.MaxValue);
		}

		[Test] public void testLong() {
			TestTypesInterface iRemoteTypes = UnitTestFactory.getFactory().newTestTypesInterface();
			iRemoteTypes.getLong();
			assertIntIdentity(iRemoteTypes, 0);
			for (long i = -5000; i < 5000; i++) {
				assertLongIdentity(iRemoteTypes, i);
			}
			assertLongIdentity(iRemoteTypes, long.MinValue);
			assertLongIdentity(iRemoteTypes, long.MaxValue);
		}

		[Test] public void testFloat() {
			TestTypesInterface iRemoteTypes = UnitTestFactory.getFactory().newTestTypesInterface();
			iRemoteTypes.getFloat();
			assertFloatIdentity(iRemoteTypes, 0);
			for (float i = -500; i < 500; i+=0.25f) {
				assertFloatIdentity(iRemoteTypes, i);
			}
			assertFloatIdentity(iRemoteTypes, float.MinValue);
			assertFloatIdentity(iRemoteTypes, float.MaxValue);
			assertFloatIdentity(iRemoteTypes, float.Epsilon);
		}

		[Test] public void testDouble() {
			TestTypesInterface iRemoteTypes = UnitTestFactory.getFactory().newTestTypesInterface();
			iRemoteTypes.getDouble();
			assertDoubleIdentity(iRemoteTypes, 0);
			for (double i = -100; i < 100; i+=0.25) {
				assertDoubleIdentity(iRemoteTypes, i);
			}
			assertDoubleIdentity(iRemoteTypes, double.MinValue);
			assertDoubleIdentity(iRemoteTypes, double.MaxValue);
			assertDoubleIdentity(iRemoteTypes, double.Epsilon);
		}

		[Test] public void test1DBool() {
			TestTypesInterface iRemoteTypes = UnitTestFactory.getFactory().newTestTypesInterface();
			Random random = new Random();
			bool[] testData = new bool[100000];
			for (int i = 0; i < testData.Length; i++) {
				testData[i] = (random.Next(0,1) == 1);
			}
			bool[] copyData = iRemoteTypes.identity(testData);
			assert(copyData.Length == testData.Length);
			for (int i = 0; i < testData.Length; i++) {
				assert(testData[i] == copyData[i]);
			}
		}

		[Test] public void test1DByte() {
			TestTypesInterface iRemoteTypes = UnitTestFactory.getFactory().newTestTypesInterface();
			Random random = new Random();
			byte[] testData = new byte[100000];
			random.NextBytes(testData);
			byte[] copyData = iRemoteTypes.identity(testData);
			assert(copyData.Length == testData.Length);
			for (int i = 0; i < testData.Length; i++) {
				assert(testData[i] == copyData[i]);
			}
		}

		[Test] public void test1DChar() {
			TestTypesInterface iRemoteTypes = UnitTestFactory.getFactory().newTestTypesInterface();
			Random random = new Random();
			char[] testData = new char[50000];
			for (int i = 0; i < testData.Length; i++) {
				testData[i] = (char)random.Next(char.MinValue, char.MaxValue);
			}
			char[] copyData = iRemoteTypes.identity(testData);
			assert(copyData.Length == testData.Length);
			for (int i = 0; i < testData.Length; i++) {
				assert(testData[i] == copyData[i]);
			}
		}

		[Test] public void test1DShort() {
			TestTypesInterface iRemoteTypes = UnitTestFactory.getFactory().newTestTypesInterface();
			Random random = new Random();
			short[] testData = new short[50000];
			for (int i = 0; i < testData.Length; i++) {
				testData[i] = (short)random.Next(short.MinValue, short.MaxValue);
			}
			short[] copyData = iRemoteTypes.identity(testData);
			assert(copyData.Length == testData.Length);
			for (int i = 0; i < testData.Length; i++) {
				assert(testData[i] == copyData[i]);
			}
		}

		[Test] public void test1DInt() {
			TestTypesInterface iRemoteTypes = UnitTestFactory.getFactory().newTestTypesInterface();
			Random random = new Random();
			int[] testData = new int[50000];
			for (int i = 0; i < testData.Length; i++) {
				testData[i] = random.Next();
			}
			int[] copyData = iRemoteTypes.identity(testData);
			assert(copyData.Length == testData.Length);
			for (int i = 0; i < testData.Length; i++) {
				assert(testData[i] == copyData[i]);
			}
		}

		[Test] public void test1DLong() {
			TestTypesInterface iRemoteTypes = UnitTestFactory.getFactory().newTestTypesInterface();
			Random random = new Random();
			long[] testData = new long[50000];
			for (int i = 0; i < testData.Length; i++) {
				testData[i] = random.Next();
			}
			long[] copyData = iRemoteTypes.identity(testData);
			assert(copyData.Length == testData.Length);
			for (int i = 0; i < testData.Length; i++) {
				assert(testData[i] == copyData[i]);
			}
		}

		[Test] public void test1DFloat() {
			TestTypesInterface iRemoteTypes = UnitTestFactory.getFactory().newTestTypesInterface();
			Random random = new Random();
			float[] testData = new float[50000];
			for (int i = 0; i < testData.Length; i++) {
				testData[i] = (float)(float.MinValue + (float.MaxValue-float.MinValue)*random.NextDouble());
			}
			float[] copyData = iRemoteTypes.identity(testData);
			assert(copyData.Length == testData.Length);
			for (int i = 0; i < testData.Length; i++) {
				assert(testData[i] == copyData[i]);
			}
		}

		[Test] public void test1DDouble() {
			TestTypesInterface iRemoteTypes = UnitTestFactory.getFactory().newTestTypesInterface();
			Random random = new Random();
			double[] testData = new double[50000];
			for (int i = 0; i < testData.Length; i++) {
				testData[i] = (double.MinValue + (double.MaxValue-double.MinValue)*random.NextDouble());
			}
			double[] copyData = iRemoteTypes.identity(testData);
			assert(copyData.Length == testData.Length);
			for (int i = 0; i < testData.Length; i++) {
				assert(testData[i] == copyData[i]);
			}
		}

		[Test] public void test2DBool() {
			TestTypesInterface iRemoteTypes = UnitTestFactory.getFactory().newTestTypesInterface();
			Random random = new Random();
			bool[][] testData = new bool[100][];
			for (int i = 0; i < testData.Length; i++) {
				testData[i] = new bool[100];
			}
			for (int i = 0; i < testData.Length; i++) {
				for (int j = 0; j < testData[i].Length; j++) {
					testData[i][j] = (random.Next(0,1) == 1);
				}
			}
			bool[][] copyData = iRemoteTypes.identity(testData);
			assert(copyData.Length == testData.Length);
			for (int i = 0; i < testData.Length; i++) {
				assert(testData[i].Length == copyData[i].Length);
				for (int j = 0; j < testData[i].Length; j++) {
					assert(testData[i][j] == copyData[i][j]);
				}
			}
		}

		[Test] public void test2DByte() {
			TestTypesInterface iRemoteTypes = UnitTestFactory.getFactory().newTestTypesInterface();
			Random random = new Random();
			byte[][] testData = new byte[1000][];

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?