[Description("Tizen.MachineLearning.Inference.SingleShot Tests")]
public class TSSingleShot
{
- private readonly string TAG = "Tizen.MachineLearning.Inference TCT";
+ private readonly string TAG = "Tizen.MachineLearning.Inference.Tests";
private readonly string _modelPath = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "mobilenet_v1_1.0_224_quant.tflite";
+ private readonly string _dynamicModelPath = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "add.tflite";
private TensorsInfo _in_info;
private TensorsInfo _out_info;
[SetUp]
public void Init()
{
- LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Preconditions for Tizen.MachineLearning.Inference TEST");
+ LogUtils.Write(LogUtils.DEBUG, TAG, "Preconditions for Tizen.MachineLearning.Inference TEST");
Information.TryGetValue(FeatureKey, out _isMachineLeanringInferenceSupported);
[TearDown]
public void Destroy()
{
- LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Postconditions for Tizen.MachineLearning.Inference TEST");
+ LogUtils.Write(LogUtils.DEBUG, TAG, "Postconditions for Tizen.MachineLearning.Inference TEST");
if (_isMachineLeanringInferenceSupported)
{
[Property("SPEC", "Tizen.MachineLearning.Inference.SingleShot.SingleShot C")]
[Property("SPEC_URL", "-")]
[Property("CRITERIA", "CONSTR")]
+ [Property("COVPARAM", "string, TensorsInfo, TensorsInfo")]
[Property("AUTHOR", "Sangjung Woo, sangjung.woo@samsung.com")]
public void SingleShot_INIT()
{
[Test]
[Category("P2")]
- [Description("Check ArgumentException when creating SingleShot Instance")]
+ [Description("Check model path ArgumentException when creating SingleShot Instance")]
[Property("SPEC", "Tizen.MachineLearning.Inference.SingleShot.SingleShot C")]
[Property("SPEC_URL", "-")]
[Property("CRITERIA", "CONSTX")]
+ [Property("COVPARAM", "string, TensorsInfo, TensorsInfo")]
[Property("AUTHOR", "Sangjung Woo, sangjung.woo@samsung.com")]
- public void SingleShot_CHECK_ArgumentException()
+ public void SingleShot_INIT_CHECK_Model_Path_ArgumentException()
{
try
{
/* TEST CODE */
var single = new SingleShot("Unknown_Path", _in_info, _out_info);
+
+ Assert.True(false, "DO NOT COME HERE!");
+ }
+ catch (Exception e)
+ {
+ if (e is NotSupportedException)
+ {
+ LogUtils.Write(LogUtils.DEBUG, TAG, "NotSupportedException occurs");
+ Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException");
+ }
+ else if (e is ArgumentException)
+ {
+ Assert.Pass("ArgumentException: passed!");
+ }
+ else
+ {
+ Assert.Fail("Unexpected Exception: failed");
+ }
+ }
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check TensorsInfo ArgumentException when creating SingleShot Instance")]
+ [Property("SPEC", "Tizen.MachineLearning.Inference.SingleShot.SingleShot C")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "CONSTX")]
+ [Property("COVPARAM", "string, TensorsInfo, TensorsInfo")]
+ [Property("AUTHOR", "Sangjung Woo, sangjung.woo@samsung.com")]
+ public void SingleShot_INIT_CHECK_TensorsInfo_ArgumentException()
+ {
+ Assert.IsTrue(File.Exists(_modelPath), "Cannot find the mobilenet_v1_1.0_224_quant.tflite file");
+
+ try
+ {
+ /* TEST CODE */
+ var single = new SingleShot(_modelPath, null, null);
+
+ Assert.True(false, "DO NOT COME HERE!");
+ }
+ catch (Exception e)
+ {
+ if (e is NotSupportedException)
+ {
+ LogUtils.Write(LogUtils.DEBUG, TAG, "NotSupportedException occurs");
+ Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException");
+ }
+ else if (e is ArgumentException)
+ {
+ Assert.Pass("ArgumentException: passed!");
+ }
+ else
+ {
+ Assert.Fail("Unexpected Exception: failed");
+ }
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Create SingleShot Instance without TensorsInfo")]
+ [Property("SPEC", "Tizen.MachineLearning.Inference.SingleShot.SingleShot C")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "CONSTR")]
+ [Property("COVPARAM", "string, Tizen.MachineLearning.Inference.NNFWType, Tizen.MachineLearning.Inference.HWType, bool")]
+ [Property("AUTHOR", "Sangjung Woo, sangjung.woo@samsung.com")]
+ public void SingleShot_INIT_Without_TensorsInfo()
+ {
+ Assert.IsTrue(File.Exists(_modelPath), "Cannot find the mobilenet_v1_1.0_224_quant.tflite file");
+
+ try
+ {
+ /* TEST CODE */
+ var single = new SingleShot(_modelPath);
+ Assert.IsInstanceOf<SingleShot>(single, "Should return SingleShot instance");
+ Assert.IsNotNull(single, "Failed to create SingleShot instance");
+
+ single.Dispose();
+ }
+ catch (Exception e)
+ {
+ if (e is NotSupportedException)
+ {
+ LogUtils.Write(LogUtils.DEBUG, TAG, "NotSupportedException occurs");
+ Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException");
+ }
+ else
+ {
+ Assert.True(false, e.Message);
+ }
+ }
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check ArgumentException when creating SingleShot Instance without TensorsInfo")]
+ [Property("SPEC", "Tizen.MachineLearning.Inference.SingleShot.SingleShot C")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "CONSTX")]
+ [Property("COVPARAM", "string, Tizen.MachineLearning.Inference.NNFWType, Tizen.MachineLearning.Inference.HWType, bool")]
+ [Property("AUTHOR", "Sangjung Woo, sangjung.woo@samsung.com")]
+ public void SingleShot_INIT_CHECK_ModelPath_ArgumentException_Without_TensorsInfo()
+ {
+ try
+ {
+ /* TEST CODE */
+ var single = new SingleShot("Unknown_Path");
+
+ Assert.True(false, "DO NOT COME HERE!");
+ }
+ catch (Exception e)
+ {
+ if (e is NotSupportedException)
+ {
+ LogUtils.Write(LogUtils.DEBUG, TAG, "NotSupportedException occurs");
+ Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException");
+ }
+ else if (e is ArgumentException)
+ {
+ Assert.Pass("ArgumentException: passed!");
+ }
+ else
+ {
+ Assert.True(false, e.Message);
+ }
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Create SingleShot Instance with options")]
+ [Property("SPEC", "Tizen.MachineLearning.Inference.SingleShot.SingleShot C")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "CONSTR")]
+ [Property("COVPARAM", "string, TensorsInfo, TensorsInfo, Tizen.MachineLearning.Inference.NNFWType, Tizen.MachineLearning.Inference.HWType, bool")]
+ [Property("AUTHOR", "Sangjung Woo, sangjung.woo@samsung.com")]
+ public void SingleShot_INIT_With_Options()
+ {
+ Assert.IsTrue(File.Exists(_modelPath), "Cannot find the mobilenet_v1_1.0_224_quant.tflite file");
+
+ try
+ {
+ /* TEST CODE */
+ var single = new SingleShot(_modelPath, _in_info, _out_info, NNFWType.TensorflowLite, HWType.CPU, false);
+ Assert.IsInstanceOf<SingleShot>(single, "Should return SingleShot instance");
+ Assert.IsNotNull(single, "Failed to create SingleShot instance");
+
+ single.Dispose();
+ }
+ catch (Exception e)
+ {
+ if (e is NotSupportedException)
+ {
+ LogUtils.Write(LogUtils.DEBUG, TAG, "NotSupportedException occurs");
+ Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException");
+ }
+ else
+ {
+ Assert.True(false, e.Message);
+ }
+ }
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check ArgumentException due to the invalid file extension when creating SingleShot Instance with options")]
+ [Property("SPEC", "Tizen.MachineLearning.Inference.SingleShot.SingleShot C")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "CONSTX")]
+ [Property("COVPARAM", "string, TensorsInfo, TensorsInfo, Tizen.MachineLearning.Inference.NNFWType, Tizen.MachineLearning.Inference.HWType, bool")]
+ [Property("AUTHOR", "Sangjung Woo, sangjung.woo@samsung.com")]
+ public void SingleShot_INIT_CHECK_NNFWType_ArgumentException_With_Options()
+ {
+ Assert.IsTrue(File.Exists(_modelPath), "Cannot find the mobilenet_v1_1.0_224_quant.tflite file");
+
+ try
+ {
+ /* TEST CODE */
+ /* tensorflow requires pb file */
+ var single = new SingleShot(_modelPath, _in_info, _out_info, NNFWType.Tensorflow, HWType.CPU, false);
+
+ Assert.True(false, "DO NOT COME HERE!");
+ }
+ catch (Exception e)
+ {
+ if (e is NotSupportedException)
+ {
+ LogUtils.Write(LogUtils.DEBUG, TAG, "NotSupportedException occurs");
+ Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException");
+ }
+ else if (e is ArgumentException)
+ {
+ Assert.Pass("ArgumentException: passed!");
+ }
+ else
+ {
+ Assert.True(false, e.Message);
+ }
+ }
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check TensorsInfo ArgumentException when creating SingleShot Instance with options")]
+ [Property("SPEC", "Tizen.MachineLearning.Inference.SingleShot.SingleShot C")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "CONSTX")]
+ [Property("COVPARAM", "string, TensorsInfo, TensorsInfo, Tizen.MachineLearning.Inference.NNFWType, Tizen.MachineLearning.Inference.HWType, bool")]
+ [Property("AUTHOR", "Sangjung Woo, sangjung.woo@samsung.com")]
+ public void SingleShot_INIT_CHECK_TensorsInfo_ArgumentException_With_Options()
+ {
+ Assert.IsTrue(File.Exists(_modelPath), "Cannot find the mobilenet_v1_1.0_224_quant.tflite file");
+
+ try
+ {
+ /* TEST CODE */
+ var single = new SingleShot(_modelPath, null, null, NNFWType.TensorflowLite, HWType.CPU, false);
+
+ Assert.True(false, "DO NOT COME HERE!");
+ }
+ catch (Exception e)
+ {
+ if (e is NotSupportedException)
+ {
+ LogUtils.Write(LogUtils.DEBUG, TAG, "NotSupportedException occurs");
+ Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException");
+ }
+ else if (e is ArgumentException)
+ {
+ Assert.Pass("ArgumentException: passed!");
+ }
+ else
+ {
+ Assert.Fail("Unexpected Exception: failed");
+ }
+ }
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check Model path ArgumentException when creating SingleShot Instance with options")]
+ [Property("SPEC", "Tizen.MachineLearning.Inference.SingleShot.SingleShot C")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "CONSTX")]
+ [Property("COVPARAM", "string, TensorsInfo, TensorsInfo, Tizen.MachineLearning.Inference.NNFWType, Tizen.MachineLearning.Inference.HWType, bool")]
+ [Property("AUTHOR", "Sangjung Woo, sangjung.woo@samsung.com")]
+ public void SingleShot_INIT_CHECK_ModelPath_ArgumentException_With_Options()
+ {
+ try
+ {
+ /* TEST CODE */
+ var single = new SingleShot("Unknown_PATH", _in_info, _out_info, NNFWType.TensorflowLite, HWType.CPU, false);
+
+ Assert.True(false, "DO NOT COME HERE!");
+ }
+ catch (Exception e)
+ {
+ if (e is NotSupportedException)
+ {
+ LogUtils.Write(LogUtils.DEBUG, TAG, "NotSupportedException occurs");
+ Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException");
+ }
+ else if (e is ArgumentException)
+ {
+ Assert.Pass("ArgumentException: passed!");
+ }
+ else
+ {
+ Assert.True(false, e.Message);
+ }
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Create SingleShot Instance with Dynamic Mode")]
+ [Property("SPEC", "Tizen.MachineLearning.Inference.SingleShot.SingleShot C")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "CONSTR")]
+ [Property("COVPARAM", "string, Tizen.MachineLearning.Inference.NNFWType, Tizen.MachineLearning.Inference.HWType, bool")]
+ [Property("AUTHOR", "Sangjung Woo, sangjung.woo@samsung.com")]
+ public void SingleShot_INIT_DynamicMode()
+ {
+ Assert.IsTrue(File.Exists(_dynamicModelPath), "Cannot find the add.tflite file");
+
+ try
+ {
+ /* TEST CODE */
+ var single = new SingleShot(_dynamicModelPath, NNFWType.Any, HWType.Any, true);
+ Assert.IsInstanceOf<SingleShot>(single, "Should return SingleShot instance");
+ Assert.IsNotNull(single, "Failed to create SingleShot instance");
+
+ var in_res = single.Input;
+ Assert.IsInstanceOf<TensorsInfo>(in_res, "Should return TensorsInfo instance");
+ Assert.IsNotNull(in_res, "Failed to create tensorsInfo instance");
+
+ var dim = string.Join(":", in_res.GetDimension(0));
+ Assert.IsTrue(string.Equals(dim, "1:1:1:1"), "The type of TensorsInfo is different from the origin");
+
+ in_res.Dispose();
+ single.Dispose();
+ }
+ catch (Exception e)
+ {
+ if (e is NotSupportedException)
+ {
+ LogUtils.Write(LogUtils.DEBUG, TAG, "NotSupportedException occurs");
+ Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException");
+ }
+ else
+ {
+ Assert.True(false, e.Message);
+ }
+ }
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check ArgumentException when creating SingleShot Instance with Dynamic Mode")]
+ [Property("SPEC", "Tizen.MachineLearning.Inference.SingleShot.SingleShot C")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "CONSTX")]
+ [Property("COVPARAM", "string, Tizen.MachineLearning.Inference.NNFWType, Tizen.MachineLearning.Inference.HWType, bool")]
+ [Property("AUTHOR", "Sangjung Woo, sangjung.woo@samsung.com")]
+ public void SingleShot_INIT_DynamicMode_CHECK_ArgumentException()
+ {
+ try
+ {
+ /* TEST CODE */
+ var single = new SingleShot("Unknown_PATH", NNFWType.Any, HWType.Any, true);
+ Assert.IsInstanceOf<SingleShot>(single, "Should return SingleShot instance");
+ Assert.IsNotNull(single, "Failed to create SingleShot instance");
+
+ Assert.True(false, "DO NOT COME HERE!");
+ }
+ catch (Exception e)
+ {
+ if (e is NotSupportedException)
+ {
+ LogUtils.Write(LogUtils.DEBUG, TAG, "NotSupportedException occurs");
+ Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException");
+ }
+ else if (e is ArgumentException)
+ {
+ Assert.Pass("ArgumentException: passed!");
+ }
+ else
+ {
+ Assert.True(false, e.Message);
+ }
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Sets the maximum amount of time to wait and check normal operation")]
+ [Property("SPEC", "Tizen.MachineLearning.Inference.SingleShot.SetTimeout M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Sangjung Woo, sangjung.woo@samsung.com")]
+ public void SetTimeout_NO_EXCEPTION()
+ {
+ Assert.IsTrue(File.Exists(_modelPath), "Cannot find the mobilenet_v1_1.0_224_quant.tflite file");
+
+ var in_buffer = new byte[3 * 224 * 224 * 1];
+ Assert.IsInstanceOf<byte[]>(in_buffer, "in_buffer payload is not of the of the type byte[]");
+ Assert.IsNotNull(in_buffer, "Fail to create the in_buffer the type byte[] ");
+
+ try
+ {
+ var single = new SingleShot(_modelPath, _in_info, _out_info);
+ Assert.IsInstanceOf<SingleShot>(single, "Should return SingleShot instance");
+ Assert.IsNotNull(single, "Failed to create SingleShot instance");
+
+ var in_data = _in_info.GetTensorsData();
+ Assert.IsInstanceOf<TensorsData>(in_data, "Should return TensorsData instance");
+ Assert.IsNotNull(in_data, "Failed to create TensorsData instance");
+
+ in_data.SetTensorData(0, in_buffer);
+
+ /* TEST CODE */
+ single.SetTimeout(10 * 1000); /* 10 sec */
+
+ var out_data = single.Invoke(in_data);
+ Assert.IsInstanceOf<TensorsData>(out_data, "Should return TensorsData instance");
+ Assert.IsNotNull(out_data, "Failed to create TensorsData instance");
+
+ in_data.Dispose();
+ single.Dispose();
+ }
+ catch (Exception e)
+ {
+ if (e is NotSupportedException)
+ {
+ LogUtils.Write(LogUtils.DEBUG, TAG, "NotSupportedException occurs");
+ Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException");
+ }
+ else
+ {
+ Assert.True(false, e.Message);
+ }
+ }
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Sets the maximum amount of time to wait and check Argument exception")]
+ [Property("SPEC", "Tizen.MachineLearning.Inference.SingleShot.SetTimeout M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("AUTHOR", "Sangjung Woo, sangjung.woo@samsung.com")]
+ public void SetTimeout_CHECK_ArgumentException()
+ {
+ Assert.IsTrue(File.Exists(_modelPath), "Cannot find the mobilenet_v1_1.0_224_quant.tflite file");
+
+ try
+ {
+ var single = new SingleShot(_modelPath, _in_info, _out_info);
+ Assert.IsInstanceOf<SingleShot>(single, "Should return SingleShot instance");
+ Assert.IsNotNull(single, "Failed to create SingleShot instance");
+
+ /* TEST CODE */
+ single.SetTimeout(-100);
+
+ Assert.True(false, "DO NOT COME HERE!");
}
catch (Exception e)
{
if (e is NotSupportedException)
{
- LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs");
+ LogUtils.Write(LogUtils.DEBUG, TAG, "NotSupportedException occurs");
Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException");
}
else if (e is ArgumentException)
}
else
{
- Assert.Fail("Unexpected Exception: failed");
+ Assert.True(false, e.Message);
+ }
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Sets and Gets the information of input tensors and check normal operation")]
+ [Property("SPEC", "Tizen.MachineLearning.Inference.SingleShot.Input A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRW")]
+ [Property("AUTHOR", "Sangjung Woo, sangjung.woo@samsung.com")]
+ public void Input_Property_NO_EXCEPTION()
+ {
+ Assert.IsTrue(File.Exists(_dynamicModelPath), "Cannot find the add.tflite file");
+
+ try
+ {
+ var single = new SingleShot(_dynamicModelPath, NNFWType.Any, HWType.Any);
+ Assert.IsInstanceOf<SingleShot>(single, "Should return SingleShot instance");
+ Assert.IsNotNull(single, "Failed to create SingleShot instance");
+
+ TensorsInfo in_info = new TensorsInfo();
+ in_info.AddTensorInfo(TensorType.Float32, new int[4] { 5, 1, 1, 1 });
+ Assert.IsInstanceOf<TensorsInfo>(in_info, "Should return TensorsInfo instance");
+ Assert.IsNotNull(in_info, "Failed to create tensorsInfo instance");
+
+ /* TEST CODE */
+ single.Input = in_info;
+ var in_res = single.Input;
+ Assert.IsInstanceOf<TensorsInfo>(in_res, "Should return TensorsInfo instance");
+ Assert.IsNotNull(in_res, "Failed to create tensorsInfo instance");
+
+ /* Check Input TensorsInfo */
+ Assert.IsTrue(in_res.Equals(in_info), "The TensorType is different from the origin");
+
+ single.Dispose();
+ }
+ catch (Exception e)
+ {
+ if (e is NotSupportedException)
+ {
+ LogUtils.Write(LogUtils.DEBUG, TAG, "NotSupportedException occurs");
+ Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException");
+ }
+ else
+ {
+ Assert.True(false, e.Message);
+ }
+ }
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check Null ArgumentException when setting the information of input tensors")]
+ [Property("SPEC", "Tizen.MachineLearning.Inference.SingleShot.Input A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PEX")]
+ [Property("AUTHOR", "Sangjung Woo, sangjung.woo@samsung.com")]
+ public void Input_Property_CHECK_Null_ArgumentException()
+ {
+ Assert.IsTrue(File.Exists(_dynamicModelPath), "Cannot find the add.tflite file");
+
+ try
+ {
+ var single = new SingleShot(_dynamicModelPath, NNFWType.Any, HWType.Any);
+ Assert.IsInstanceOf<SingleShot>(single, "Should return SingleShot instance");
+ Assert.IsNotNull(single, "Failed to create SingleShot instance");
+
+ /* TEST CODE */
+ single.Input = null;
+
+ Assert.True(false, "DO NOT COME HERE!");
+ }
+ catch (Exception e)
+ {
+ if (e is NotSupportedException)
+ {
+ LogUtils.Write(LogUtils.DEBUG, TAG, "NotSupportedException occurs");
+ Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException");
+ }
+ else if (e is ArgumentException)
+ {
+ Assert.Pass("ArgumentException: passed!");
+ }
+ else
+ {
+ Assert.True(false, e.Message);
+ }
+ }
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check ArgumentException when setting the information of input tensors")]
+ [Property("SPEC", "Tizen.MachineLearning.Inference.SingleShot.Input A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PEX")]
+ [Property("AUTHOR", "Sangjung Woo, sangjung.woo@samsung.com")]
+ public void Input_Property_CHECK_ArgumentException()
+ {
+ /* the model does not support dynamic mode */
+ Assert.IsTrue(File.Exists(_modelPath), "Cannot find the mobilenet_v1_1.0_224_quant.tflite file");
+
+ try
+ {
+ var single = new SingleShot(_modelPath, NNFWType.Any, HWType.Any);
+ Assert.IsInstanceOf<SingleShot>(single, "Should return SingleShot instance");
+ Assert.IsNotNull(single, "Failed to create SingleShot instance");
+
+ var tensorInfo = new TensorsInfo();
+ Assert.IsInstanceOf<TensorsInfo>(tensorInfo, "Should return TensorsInfo instance");
+ Assert.IsNotNull(tensorInfo, "Failed to create TensorsInfo instance");
+
+ tensorInfo.AddTensorInfo(TensorType.UInt8, new int[4] { 10, 1, 1, 1 });
+
+ /* TEST CODE */
+ single.Input = tensorInfo;
+
+ Assert.True(false, "DO NOT COME HERE!");
+ }
+ catch (Exception e)
+ {
+ if (e is NotSupportedException)
+ {
+ LogUtils.Write(LogUtils.DEBUG, TAG, "NotSupportedException occurs");
+ Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException");
+ }
+ else if (e is ArgumentException)
+ {
+ Assert.Pass("ArgumentException: passed!");
+ }
+ else
+ {
+ Assert.True(false, e.Message);
+ }
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Gets the information of output tensors and check normal operation")]
+ [Property("SPEC", "Tizen.MachineLearning.Inference.SingleShot.Output A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRO")]
+ [Property("AUTHOR", "Sangjung Woo, sangjung.woo@samsung.com")]
+ public void Output_Property_NO_EXCEPTION()
+ {
+ Assert.IsTrue(File.Exists(_modelPath), "Cannot find the mobilenet_v1_1.0_224_quant.tflite file");
+
+ try
+ {
+ var single = new SingleShot(_modelPath, _in_info, _out_info);
+ Assert.IsInstanceOf<SingleShot>(single, "Should return SingleShot instance");
+ Assert.IsNotNull(single, "Failed to create SingleShot instance");
+
+ /* TEST CODE */
+ var output_info = single.Output;
+ Assert.IsInstanceOf<TensorsInfo>(output_info, "Should return TensorsInfo instance");
+ Assert.IsNotNull(output_info, "Failed to create TensorsInfo instance");
+
+ Assert.IsTrue(output_info.Equals(_out_info), "TensorsInfo is different from the origin.");
+
+ single.Dispose();
+ }
+ catch (Exception e)
+ {
+ if (e is NotSupportedException)
+ {
+ LogUtils.Write(LogUtils.DEBUG, TAG, "NotSupportedException occurs");
+ Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException");
+ }
+ else
+ {
+ Assert.True(false, e.Message);
}
}
}
Assert.IsInstanceOf<byte[]>(out_buffer, "Should return byte[] instance");
Assert.IsNotNull(out_buffer, "Failed to create byte[] instance");
+ in_data.Dispose();
+ out_data.Dispose();
single.Dispose();
}
catch (Exception e)
{
if (e is NotSupportedException)
{
- LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs");
+ LogUtils.Write(LogUtils.DEBUG, TAG, "NotSupportedException occurs");
Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException");
}
else
[Test]
[Category("P2")]
- [Description("Check IOException when calling Invoke() of Single class")]
+ [Description("Check ArgumentException when calling Invoke() of Single class")]
[Property("SPEC", "Tizen.MachineLearning.Inference.SingleShot.Invoke M")]
[Property("SPEC_URL", "-")]
[Property("CRITERIA", "MEX")]
[Property("AUTHOR", "Sangjung Woo, sangjung.woo@samsung.com")]
- public void Invoke_CHECK_IOException()
+ public void Invoke_CHECK_ArgumentException()
{
Assert.IsTrue(File.Exists(_modelPath), "Cannot find the mobilenet_v1_1.0_224_quant.tflite file");
try
{
- var in_info = new TensorsInfo();
- Assert.IsInstanceOf<TensorsInfo>(in_info, "Should return TensorsInfo instance");
- Assert.IsNotNull(in_info, "Failed to create TensorsInfo instance");
+ var wrong_in_info = new TensorsInfo();
+ Assert.IsInstanceOf<TensorsInfo>(wrong_in_info, "Should return TensorsInfo instance");
+ Assert.IsNotNull(wrong_in_info, "Failed to create TensorsInfo instance");
+
+ wrong_in_info.AddTensorInfo(TensorType.UInt8, new int[4] { 10, 1, 1, 1 });
+
+ var wrong_in_data = wrong_in_info.GetTensorsData();
+ Assert.IsInstanceOf<TensorsData>(wrong_in_data, "Should return TensorsData instance");
+ Assert.IsNotNull(wrong_in_data, "Failed to create TensorsData instance");
+
+ var single = new SingleShot(_modelPath, _in_info, _out_info);
+ Assert.IsInstanceOf<SingleShot>(single, "Should return SingleShot instance");
+ Assert.IsNotNull(single, "Failed to create SingleShot instance");
+
+ /* TEST CODE */
+ var out_data = single.Invoke(wrong_in_data);
+
+ Assert.True(false, "DO NOT COME HERE!");
+ }
+ catch (Exception e)
+ {
+ if (e is NotSupportedException)
+ {
+ LogUtils.Write(LogUtils.DEBUG, TAG, "NotSupportedException occurs");
+ Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException");
+ }
+ else if (e is ArgumentException)
+ {
+ Assert.Pass("ArgumentException: passed!");
+ }
+ else
+ {
+ Assert.True(false, e.Message);
+ }
+ }
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check TimeoutException when calling Invoke() of Single class")]
+ [Property("SPEC", "Tizen.MachineLearning.Inference.SingleShot.Invoke M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("AUTHOR", "Sangjung Woo, sangjung.woo@samsung.com")]
+ public void Invoke_CHECK_TimeoutException()
+ {
+ Assert.IsTrue(File.Exists(_modelPath), "Cannot find the mobilenet_v1_1.0_224_quant.tflite file");
- var in_buffer = new byte[10 * 1 * 1 * 1];
- Assert.IsInstanceOf<byte[]>(in_buffer, "in_buffer payload is not of the of the type byte[]");
- Assert.IsNotNull(in_buffer, "Fail to create the in_buffer the type byte[] ");
+ var in_buffer = new byte[3 * 224 * 224 * 1];
+ Assert.IsInstanceOf<byte[]>(in_buffer, "in_buffer payload is not of the of the type byte[]");
+ Assert.IsNotNull(in_buffer, "Fail to create the in_buffer the type byte[] ");
- in_info.AddTensorInfo(TensorType.UInt8, new int[4] { 10, 1, 1, 1 });
+ try
+ {
+ var single = new SingleShot(_modelPath, _in_info, _out_info);
+ Assert.IsInstanceOf<SingleShot>(single, "Should return SingleShot instance");
+ Assert.IsNotNull(single, "Failed to create SingleShot instance");
var in_data = _in_info.GetTensorsData();
Assert.IsInstanceOf<TensorsData>(in_data, "Should return TensorsData instance");
- Assert.IsNotNull(in_data, "Fail to create the TensorsData instance");
+ Assert.IsNotNull(in_data, "Failed to create TensorsData instance");
in_data.SetTensorData(0, in_buffer);
- var single = new SingleShot(_modelPath, _in_info, _out_info);
+ /* 10 msec, Timeout occurs */
+ single.SetTimeout(10);
+
+ /* TEST CODE */
+ var out_data = single.Invoke(in_data);
+ Assert.IsInstanceOf<TensorsData>(out_data, "Should return TensorsData instance");
+ Assert.IsNotNull(out_data, "Failed to create TensorsData instance");
+
+ Assert.True(false, "DO NOT COME HERE!");
+ }
+ catch (Exception e)
+ {
+ if (e is NotSupportedException)
+ {
+ LogUtils.Write(LogUtils.DEBUG, TAG, "NotSupportedException occurs");
+ Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException");
+ }
+ else if (e is TimeoutException)
+ {
+ Assert.Pass("TimeoutException: passed!");
+ }
+ else
+ {
+ Assert.True(false, e.Message);
+ }
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Invokes the dynamic model with the given input data and check exceptions")]
+ [Property("SPEC", "Tizen.MachineLearning.Inference.SingleShot.Invoke M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Sangjung Woo, sangjung.woo@samsung.com")]
+ public void Invoke_dynamic_CHECK_NO_EXCEPTION()
+ {
+ Assert.IsTrue(File.Exists(_dynamicModelPath), "Cannot find the add.tflite file");
+
+ try
+ {
+ var single = new SingleShot(_dynamicModelPath, NNFWType.Any, HWType.Any, true);
Assert.IsInstanceOf<SingleShot>(single, "Should return SingleShot instance");
Assert.IsNotNull(single, "Failed to create SingleShot instance");
+ /* In case of 5 : 1 : 1 : 1 */
+ TensorsInfo in_info = new TensorsInfo();
+ in_info.AddTensorInfo(TensorType.Float32, new int[4] { 5, 1, 1, 1 });
+ Assert.IsInstanceOf<TensorsInfo>(in_info, "Should return TensorsInfo instance");
+ Assert.IsNotNull(in_info, "Failed to create tensorsInfo instance");
+
+ /* Input data */
+ var in_data = new float[] { 0, 1, 2, 3, 4 };
+ var buf_in = new byte[sizeof(float) * in_data.Length];
+ Buffer.BlockCopy(in_data, 0, buf_in, 0, buf_in.Length);
+
+ /* Input TensorsData */
+ var in_tensorsData = in_info.GetTensorsData();
+ Assert.IsInstanceOf<TensorsData>(in_tensorsData, "tensorsData payload is not of the of the TensorsData.");
+ Assert.IsNotNull(in_tensorsData, "Fail to create the tensorsData.");
+
+ /* Set Input Tensors Data */
+ in_tensorsData.SetTensorData(0, buf_in);
+
/* TEST CODE */
- var out_data = single.Invoke(in_data);
+ var out_tensorsData = single.Invoke(in_tensorsData);
+ Assert.IsInstanceOf<TensorsData>(out_tensorsData, "Should return TensorsData instance");
+ Assert.IsNotNull(out_tensorsData, "Failed to create TensorsData instance");
+
+ /* Check Output TensorsData */
+ var buf_out = out_tensorsData.GetTensorData(0);
+ Assert.IsInstanceOf<byte[]>(buf_out, "buf_out is not the type of byte[].");
+
+ var res_data = new float[buf_out.Length / sizeof(float)];
+ Buffer.BlockCopy(buf_out, 0, res_data, 0, buf_out.Length);
+
+ for (int i = 0; i < 5; ++i)
+ {
+ Assert.IsTrue(res_data[i] == i + 2, "Value is different");
+ }
+
+ in_tensorsData.Dispose();
+ out_tensorsData.Dispose();
+ single.Dispose();
}
catch (Exception e)
{
if (e is NotSupportedException)
{
- LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs");
+ LogUtils.Write(LogUtils.DEBUG, TAG, "NotSupportedException occurs");
+ Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException");
+ }
+ else
+ {
+ Assert.True(false, e.Message);
+ }
+ }
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check ArgumentException when calling Invoke() the dynamic model of Single class")]
+ [Property("SPEC", "Tizen.MachineLearning.Inference.SingleShot.Invoke M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("AUTHOR", "Sangjung Woo, sangjung.woo@samsung.com")]
+ public void Invoke_dynamic_CHECK_ArgumentException()
+ {
+ Assert.IsTrue(File.Exists(_dynamicModelPath), "Cannot find the add.tflite file");
+
+ try
+ {
+ var single = new SingleShot(_dynamicModelPath, NNFWType.Any, HWType.Any, true);
+ Assert.IsInstanceOf<SingleShot>(single, "Should return SingleShot instance");
+ Assert.IsNotNull(single, "Failed to create SingleShot instance");
+
+ /* TEST CODE */
+ var out_tensorsData = single.Invoke(null);
+
+ Assert.True(false, "DO NOT COME HERE!");
+ }
+ catch (Exception e)
+ {
+ if (e is NotSupportedException)
+ {
+ LogUtils.Write(LogUtils.DEBUG, TAG, "NotSupportedException occurs");
Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException");
}
- else if (e is IOException)
+ else if (e is ArgumentException)
{
- Assert.Pass("IOException: passed!");
+ Assert.Pass("ArgumentException: passed!");
}
else
{
- Assert.Fail("Unexpected Exception: failed");
+ Assert.True(false, e.Message);
}
}
}
[Description("Tizen.MachineLearning.Inference.TensorsData Tests")]
public class TensorsDataTests
{
- private readonly string TAG = "Tizen.MachineLearning.Inference TCT";
+ private readonly string TAG = "Tizen.MachineLearning.Inference.Tests";
private TensorsInfo _tensorsInfo = null;
private int[] _in_dim;
[SetUp]
public void Init()
{
- LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Preconditions for Tizen.MachineLearning.Inference TEST");
+ LogUtils.Write(LogUtils.DEBUG, TAG, "Preconditions for Tizen.MachineLearning.Inference TEST");
Information.TryGetValue(FeatureKey, out _isMachineLeanringInferenceSupported);
- LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "#### MachineLeanringInferenceSupported: " + _isMachineLeanringInferenceSupported.ToString());
if (_isMachineLeanringInferenceSupported)
{
try
{
- /* TEST CODE */
var tensorsData = _tensorsInfo.GetTensorsData();
Assert.IsInstanceOf<TensorsData>(tensorsData, "tensorsData payload is not of the of the TensorsData.");
Assert.IsNotNull(tensorsData, "Fail to create the tensorsData.");
+ /* TEST CODE */
tensorsData.SetTensorData(0, buffer_in);
tensorsData.Dispose();
}
try
{
- /* TEST CODE */
var tensorsData = _tensorsInfo.GetTensorsData();
Assert.IsInstanceOf<TensorsData>(tensorsData, "tensorsData payload is not of the of the TensorsData.");
Assert.IsNotNull(tensorsData, "Fail to create the tensorsData.");
+ /* TEST CODE */
tensorsData.SetTensorData(10, buffer_in);
+
+ Assert.True(false, "DO NOT COME HERE!");
}
catch (Exception e)
{
/* TEST CODE */
var buffer_out = tensorsData.GetTensorData(100);
+
+ Assert.True(false, "DO NOT COME HERE!");
}
catch (Exception e)
{
}
}
}
+
+ [Test]
+ [Category("P1")]
+ [Description("Allocate TensorsData object using TensorsInfo and check the exception")]
+ [Property("SPEC", "Tizen.MachineLearning.Inference.TensorsData.Allocate M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Sangjung Woo, sangjung.woo@samsung.com")]
+ public void Allocate_CHECK_NO_EXCEPTION()
+ {
+ try
+ {
+ /* TEST CODE */
+ var tensorsData = TensorsData.Allocate(_tensorsInfo);
+ Assert.IsInstanceOf<TensorsData>(tensorsData, "tensorsData is not the type of TensorsData.");
+ Assert.IsNotNull(tensorsData, "Fail to create tensorsData.");
+ }
+ catch (Exception e)
+ {
+ if ((e is NotSupportedException) || (e is NullReferenceException && _tensorsInfo == null))
+ {
+ LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs");
+ Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException");
+ }
+ else
+ {
+ Assert.True(false, e.Message);
+ }
+ }
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check ArgumentException when calling Allocate() of TensorsData class")]
+ [Property("SPEC", "Tizen.MachineLearning.Inference.TensorsData.Allocate M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("AUTHOR", "Sangjung Woo, sangjung.woo@samsung.com")]
+ public void Allocate_CHECK_ArgumentException()
+ {
+ try
+ {
+ /* TEST CODE */
+ var tensorsData = TensorsData.Allocate(null);
+
+ Assert.True(false, "DO NOT COME HERE!");
+ }
+ catch (Exception e)
+ {
+ if ((e is NotSupportedException) || (e is NullReferenceException && _tensorsInfo == null))
+ {
+ LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs");
+ Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException");
+ }
+ else if (e is ArgumentException)
+ {
+ Assert.Pass("ArgumentException: passed!");
+ }
+ else
+ {
+ Assert.True(false, e.Message);
+ }
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Gets the tensors information and check the result.")]
+ [Property("SPEC", "Tizen.MachineLearning.Inference.TensorsData.TensorsInfo A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRO")]
+ [Property("AUTHOR", "Sangjung Woo, sangjung.woo@samsung.com")]
+ public void TensorsInfo_CHECK_NO_EXCEPTION()
+ {
+ try
+ {
+ var tensorsData = _tensorsInfo.GetTensorsData();
+ Assert.IsInstanceOf<TensorsData>(tensorsData, "tensorsData is not the type of TensorsData.");
+ Assert.IsNotNull(tensorsData, "Fail to create tensorsData.");
+
+ /* TEST CODE */
+ var tensorsInfo = tensorsData.TensorsInfo;
+ Assert.IsInstanceOf<TensorsInfo>(tensorsInfo, "Should return TensorsInfo instance");
+ Assert.IsNotNull(tensorsInfo, "TensorsInfo should not null object");
+ Assert.IsTrue(tensorsInfo.Equals(_tensorsInfo), "The TensorsInfo is different from the origin");
+ }
+ catch (Exception e)
+ {
+ if ((e is NotSupportedException) || (e is NullReferenceException && _tensorsInfo == null))
+ {
+ LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs");
+ Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException");
+ }
+ else
+ {
+ Assert.True(false, e.Message);
+ }
+ }
+ }
}
}
using NUnit.Framework;
using NUnit.Framework.TUnit;
using System;
+using System.Linq;
using Tizen;
using Tizen.System;
using Tizen.MachineLearning.Inference;
[Description("Tizen.MachineLearning.Inference.TensorsInfo Tests")]
public class TensorsInfoTests
{
- private readonly string TAG = "Tizen.MachineLearning.Inference TCT";
+ private readonly string TAG = "Tizen.MachineLearning.Inference.Tests";
private const string FeatureKey = "http://tizen.org/feature/machine_learning.inference";
private bool _isMachineLeanringInferenceSupported = false;
[SetUp]
public void Init()
{
- LogUtils.Write(LogUtils.DEBUG , LogUtils.TAG , "Preconditions for Tizen.MachineLearning.Inference TEST");
+ LogUtils.Write(LogUtils.DEBUG, TAG, "Preconditions for Tizen.MachineLearning.Inference TEST");
Information.TryGetValue(FeatureKey, out _isMachineLeanringInferenceSupported);
}
[TearDown]
public void Destroy()
{
- LogUtils.Write(LogUtils.DEBUG , LogUtils.TAG , "Postconditions for Tizen.MachineLearning.Inference TEST");
+ LogUtils.Write(LogUtils.DEBUG, TAG, "Postconditions for Tizen.MachineLearning.Inference TEST");
}
[Test]
}
}
-
[Test]
[Category("P1")]
[Description("Add TensorInfo into TensorsInfo with the input dimension information")]
}
[Test]
+ [Category("P2")]
+ [Description("Check ArgumentException when calling AddTensorInfo() of TensorsInfo class with name parameter")]
+ [Property("SPEC", "Tizen.MachineLearning.Inference.TensorsInfo.AddTensorInfo M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("AUTHOR", "Sangjung Woo, sangjung.woo@samsung.com")]
+ [Property("COVPARAM", "Tizen.MachineLearning.Inference.TensorType, int[]")]
+ public void AddTensorInfo_CHECK_ArgumentException()
+ {
+ try
+ {
+ var tensorsInfo = new TensorsInfo();
+ Assert.IsInstanceOf<TensorsInfo>(tensorsInfo, "Should return TensorsInfo instance");
+ Assert.IsNotNull(tensorsInfo, "Failed to create tensorsInfo instance");
+
+ /* TEST CODE */
+ tensorsInfo.AddTensorInfo(TensorType.UInt8, null);
+
+ Assert.True(false, "DO NOT COME HERE");
+ }
+ catch (Exception e)
+ {
+ if (e is NotSupportedException)
+ {
+ LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs");
+ Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException");
+ }
+ else if (e is ArgumentException)
+ {
+ Assert.Pass("ArgumentException: passed!");
+ }
+ else
+ {
+ Assert.True(false, e.Message);
+ }
+ }
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check ArgumentException when calling AddTensorInfo() of TensorsInfo class")]
+ [Property("SPEC", "Tizen.MachineLearning.Inference.TensorsInfo.AddTensorInfo M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("AUTHOR", "Sangjung Woo, sangjung.woo@samsung.com")]
+ [Property("COVPARAM", "string, Tizen.MachineLearning.Inference.TensorType, int[]")]
+ public void AddTensorInfo_CHECK_ArgumentException_WITH_NAME()
+ {
+ string TensorName = "InputTensorName";
+
+ try
+ {
+ var tensorsInfo = new TensorsInfo();
+ Assert.IsInstanceOf<TensorsInfo>(tensorsInfo, "Should return TensorsInfo instance");
+ Assert.IsNotNull(tensorsInfo, "Failed to create tensorsInfo instance");
+
+ /* TEST CODE */
+ tensorsInfo.AddTensorInfo(TensorName, TensorType.UInt8, null);
+
+ Assert.True(false, "DO NOT COME HERE");
+ }
+ catch (Exception e)
+ {
+ if (e is NotSupportedException)
+ {
+ LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs");
+ Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException");
+ }
+ else if (e is ArgumentException)
+ {
+ Assert.Pass("ArgumentException: passed!");
+ }
+ else
+ {
+ Assert.True(false, e.Message);
+ }
+ }
+ }
+
+ [Test]
[Category("P1")]
[Description("Get the name of TensorInfo and compare it with its origin")]
[Property("SPEC", "Tizen.MachineLearning.Inference.TensorsInfo.GetTensorName M")]
[Test]
[Category("P2")]
- [Description("Check IndexOutOfRangeException when calling GetTensorName() of TensorsInfo class")]
+ [Description("Check ArgumentException when calling GetTensorName() of TensorsInfo class")]
[Property("SPEC", "Tizen.MachineLearning.Inference.TensorsInfo.GetTensorName M")]
[Property("SPEC_URL", "-")]
[Property("CRITERIA", "MEX")]
[Property("AUTHOR", "Sangjung Woo, sangjung.woo@samsung.com")]
- public void GetTensorName_CHECK_IndexOutOfRangeException()
+ public void GetTensorName_CHECK_ArgumentException()
{
string inTensorName = "InputTensorName";
var in_dim = new int[4] { 3, 224, 224, 1 };
LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs");
Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException");
}
- else if (e is IndexOutOfRangeException)
+ else if (e is ArgumentException)
{
- Assert.Pass("IndexOutOfRangeException: passed!");
+ Assert.Pass("ArgumentException: passed!");
}
else
{
[Test]
[Category("P1")]
- [Description("Set the name of TensorInfo and check the result")]
+ [Description("Set the name of TensorInfo and check the result")]
[Property("SPEC", "Tizen.MachineLearning.Inference.TensorsInfo.SetTensorName M")]
[Property("SPEC_URL", "-")]
[Property("CRITERIA", "MR")]
[Test]
[Category("P2")]
- [Description("Check IndexOutOfRangeException when calling SetTensorName() of TensorsInfo class")]
+ [Description("Check ArgumentException when calling SetTensorName() of TensorsInfo class")]
[Property("SPEC", "Tizen.MachineLearning.Inference.TensorsInfo.SetTensorName M")]
[Property("SPEC_URL", "-")]
[Property("CRITERIA", "MEX")]
+ [Property("COVPARAM", "int, string")]
[Property("AUTHOR", "Sangjung Woo, sangjung.woo@samsung.com")]
- public void SetTensorName_CHECK_IndexOutOfRangeException()
+ public void SetTensorName_CHECK_Null_ArgumentException()
{
- string inTensorName = "InputTensorName";
var in_dim = new int[4] { 3, 224, 224, 1 };
Assert.IsInstanceOf<int[]>(in_dim, "Should return int[] instance");
Assert.IsNotNull(in_dim, "Failed to create in_dim instance");
tensorsInfo.AddTensorInfo(TensorType.UInt8, in_dim);
/* TEST CODE */
- tensorsInfo.SetTensorName(100, inTensorName);
+ tensorsInfo.SetTensorName(0, null);
}
catch (Exception e)
{
LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs");
Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException");
}
- else if (e is IndexOutOfRangeException)
+ else if (e is ArgumentException)
{
- Assert.Pass("IndexOutOfRangeException: passed!");
+ Assert.Pass("ArgumentException: passed!");
}
else
{
[Test]
[Category("P2")]
- [Description("Check ArgumentException when calling SetTensorName() of TensorsInfo class")]
+ [Description("Check wrong index ArgumentException when calling SetTensorName() of TensorsInfo class")]
[Property("SPEC", "Tizen.MachineLearning.Inference.TensorsInfo.SetTensorName M")]
[Property("SPEC_URL", "-")]
[Property("CRITERIA", "MEX")]
+ [Property("COVPARAM", "int, string")]
[Property("AUTHOR", "Sangjung Woo, sangjung.woo@samsung.com")]
- public void SetTensorName_CHECK_ArgumentException()
+ public void SetTensorName_CHECK_Wrong_Index_ArgumentException()
{
- var in_dim = new int[4] { 3, 224, 224, 1 };
- Assert.IsInstanceOf<int[]>(in_dim, "Should return int[] instance");
- Assert.IsNotNull(in_dim, "Failed to create in_dim instance");
-
try
{
var tensorsInfo = new TensorsInfo();
- Assert.IsInstanceOf<TensorsInfo>(tensorsInfo, "Should return TensorsInfo instance");
- Assert.IsNotNull(tensorsInfo, "Failed to create tensorsInfo instance");
-
- tensorsInfo.AddTensorInfo(TensorType.UInt8, in_dim);
/* TEST CODE */
- tensorsInfo.SetTensorName(0, null);
+ tensorsInfo.SetTensorName(100, "InputTensorName");
}
catch (Exception e)
{
[Test]
[Category("P2")]
- [Description("Check IndexOutOfRangeException when calling SetTensorType() of TensorsInfo class")]
+ [Description("Check ArgumentException when calling SetTensorType() of TensorsInfo class")]
[Property("SPEC", "Tizen.MachineLearning.Inference.TensorsInfo.SetTensorType M")]
[Property("SPEC_URL", "-")]
[Property("CRITERIA", "MEX")]
[Property("AUTHOR", "Sangjung Woo, sangjung.woo@samsung.com")]
- public void SetTensorType_CHECK_IndexOutOfRangeException()
+ public void SetTensorType_CHECK_ArgumentException()
{
var in_dim = new int[4] { 10, 1, 1, 1 };
Assert.IsInstanceOf<int[]>(in_dim, "Should return int[] instance");
LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs");
Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException");
}
- else if (e is IndexOutOfRangeException)
+ else if (e is ArgumentException)
{
- Assert.Pass("IndexOutOfRangeException: passed!");
+ Assert.Pass("ArgumentException: passed!");
}
else
{
[Test]
[Category("P2")]
- [Description("Check IndexOutOfRangeException when calling GetTensorType() of TensorsInfo class")]
+ [Description("Check ArgumentException when calling GetTensorType() of TensorsInfo class")]
[Property("SPEC", "Tizen.MachineLearning.Inference.TensorsInfo.GetTensorType M")]
[Property("SPEC_URL", "-")]
[Property("CRITERIA", "MEX")]
[Property("AUTHOR", "Sangjung Woo, sangjung.woo@samsung.com")]
- public void GetTensorType_CHECK_IndexOutOfRangeException()
+ public void GetTensorType_CHECK_ArgumentException()
{
var in_dim = new int[4] { 10, 1, 1, 1 };
Assert.IsInstanceOf<int[]>(in_dim, "Should return int[] instance");
LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs");
Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException");
}
- else if (e is IndexOutOfRangeException)
+ else if (e is ArgumentException)
{
- Assert.Pass("IndexOutOfRangeException: passed!");
+ Assert.Pass("ArgumentExceptio: passed!");
}
else
{
[Test]
[Category("P2")]
- [Description("Check IndexOutOfRangeException when calling SetDimension() of TensorsInfo class")]
+ [Description("Check Null ArgumentException when calling SetDimension() of TensorsInfo class")]
[Property("SPEC", "Tizen.MachineLearning.Inference.TensorsInfo.SetDimension M")]
[Property("SPEC_URL", "-")]
[Property("CRITERIA", "MEX")]
+ [Property("COVPARAM", "int, int[]")]
[Property("AUTHOR", "Sangjung Woo, sangjung.woo@samsung.com")]
- public void SetDimension_CHECK_IndexOutOfRangeException()
+ public void SetDimension_CHECK_Null_ArgumentException()
{
var in_dim = new int[4] { 10, 1, 1, 1 };
Assert.IsInstanceOf<int[]>(in_dim, "Should return int[] instance");
Assert.IsNotNull(in_dim, "Failed to create in_dim instance");
- var in_new_dim = new int[4] { 3, 224, 224, 1 };
- Assert.IsInstanceOf<int[]>(in_new_dim, "Should return int[] instance");
- Assert.IsNotNull(in_new_dim, "Failed to create in_dim instance");
-
try
{
var tensorsInfo = new TensorsInfo();
Assert.IsInstanceOf<TensorsInfo>(tensorsInfo, "Should return TensorsInfo instance");
Assert.IsNotNull(tensorsInfo, "Failed to create tensorsInfo instance");
-
tensorsInfo.AddTensorInfo(TensorType.UInt8, in_dim);
/* TEST CODE */
- tensorsInfo.SetDimension(100, in_new_dim);
+ tensorsInfo.SetDimension(0, null);
}
catch (Exception e)
{
LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs");
Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException");
}
- else if (e is IndexOutOfRangeException)
+ else if (e is ArgumentException)
{
- Assert.Pass("IndexOutOfRangeException: passed!");
+ Assert.Pass("ArgumentException: passed!");
}
else
{
[Test]
[Category("P2")]
- [Description("Check ArgumentException when calling SetDimension() of TensorsInfo class")]
+ [Description("Check wrong index ArgumentException when calling SetDimension() of TensorsInfo class")]
[Property("SPEC", "Tizen.MachineLearning.Inference.TensorsInfo.SetDimension M")]
[Property("SPEC_URL", "-")]
[Property("CRITERIA", "MEX")]
+ [Property("COVPARAM", "int, int[]")]
[Property("AUTHOR", "Sangjung Woo, sangjung.woo@samsung.com")]
- public void SetDimension_CHECK_ArgumentException()
+ public void SetDimension_CHECK_Wrong_Index_ArgumentException()
{
- var in_dim = new int[4] { 10, 1, 1, 1 };
- Assert.IsInstanceOf<int[]>(in_dim, "Should return int[] instance");
- Assert.IsNotNull(in_dim, "Failed to create in_dim instance");
-
try
{
var tensorsInfo = new TensorsInfo();
Assert.IsInstanceOf<TensorsInfo>(tensorsInfo, "Should return TensorsInfo instance");
Assert.IsNotNull(tensorsInfo, "Failed to create tensorsInfo instance");
- tensorsInfo.AddTensorInfo(TensorType.UInt8, in_dim);
+ var in_new_dim = new int[4] { 3, 224, 224, 1 };
+ Assert.IsInstanceOf<int[]>(in_new_dim, "Should return int[] instance");
+ Assert.IsNotNull(in_new_dim, "Failed to create in_dim instance");
/* TEST CODE */
- tensorsInfo.SetDimension(0, null);
+ tensorsInfo.SetDimension(100, in_new_dim);
}
catch (Exception e)
{
[Test]
[Category("P2")]
- [Description("Check IndexOutOfRangeException when calling GetDimension() of TensorsInfo class")]
+ [Description("Check ArgumentException when calling GetDimension() of TensorsInfo class")]
[Property("SPEC", "Tizen.MachineLearning.Inference.TensorsInfo.GetDimension M")]
[Property("SPEC_URL", "-")]
[Property("CRITERIA", "MEX")]
[Property("AUTHOR", "Sangjung Woo, sangjung.woo@samsung.com")]
- public void GetDimension_CHECK_IndexOutOfRangeException()
+ public void GetDimension_CHECK_ArgumentException()
{
var in_dim = new int[4] { 10, 1, 1, 1 };
Assert.IsInstanceOf<int[]>(in_dim, "Should return int[] instance");
LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs");
Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException");
}
- else if (e is IndexOutOfRangeException)
+ else if (e is ArgumentException)
{
- Assert.Pass("IndexOutOfRangeException: passed!");
+ Assert.Pass("ArgumentException: passed!");
}
else
{
}
[Test]
+ [Category("P2")]
+ [Description("Check ArgumentException when calling GetTensorsData() of TensorsInfo class")]
+ [Property("SPEC", "Tizen.MachineLearning.Inference.TensorsInfo.GetTensorsData M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("AUTHOR", "Sangjung Woo, sangjung.woo@samsung.com")]
+ public void GetTensorsData_CHECK_ArgumentException()
+ {
+ try
+ {
+ var in_info = new TensorsInfo();
+ Assert.IsInstanceOf<TensorsInfo>(in_info, "Should return TensorsInfo instance");
+ Assert.IsNotNull(in_info, "Failed to create TensorsInfo instance");
+
+ /* TEST CODE */
+ var in_data = in_info.GetTensorsData();
+
+ Assert.True(false, "DO NOT COME HERE!");
+ }
+ catch (Exception e)
+ {
+ if (e is NotSupportedException)
+ {
+ LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs");
+ Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException");
+ }
+ else if (e is ArgumentException)
+ {
+ Assert.Pass("ArgumentException: passed!");
+ }
+ else
+ {
+ Assert.True(false, e.Message);
+ }
+ }
+ }
+
+ [Test]
[Category("P1")]
[Description("Check the Count property.")]
[Property("SPEC", "Tizen.MachineLearning.Inference.TensorsInfo.Count A")]
}
}
}
+
+ [Test]
+ [Category("P1")]
+ [Description("Check the size of Tensor.")]
+ [Property("SPEC", "Tizen.MachineLearning.Inference.TensorsInfo.GetTensorSize M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Sangjung Woo, sangjung.woo@samsung.com")]
+ public void GetTensorSize_CHECK_NO_EXCEPTION()
+ {
+ var in_dim = new int[4] { 10, 1, 1, 1 };
+ Assert.IsInstanceOf<int[]>(in_dim, "Should return int[] instance");
+ Assert.IsNotNull(in_dim, "Failed to create in_dim instance");
+
+ try
+ {
+ var tensorsInfo = new TensorsInfo();
+ Assert.IsInstanceOf<TensorsInfo>(tensorsInfo, "Should return TensorsInfo instance");
+ Assert.IsNotNull(tensorsInfo, "Failed to create tensorsInfo instance");
+
+ int trueSize = 1;
+ foreach (int e in in_dim)
+ trueSize *= e;
+
+ tensorsInfo.AddTensorInfo(TensorType.UInt8, in_dim);
+
+ /* TEST CODE */
+ var size = tensorsInfo.GetTensorSize(0);
+ Assert.IsTrue(trueSize == size, "The size of TensorsInfo should be " + trueSize.ToString());
+ }
+ catch (Exception e)
+ {
+ if (e is NotSupportedException)
+ {
+ LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs");
+ Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException");
+ }
+ else
+ {
+ Assert.True(false, e.Message);
+ }
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Check the size of Tensor, which is wrong value.")]
+ [Property("SPEC", "Tizen.MachineLearning.Inference.TensorsInfo.GetTensorSize M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Sangjung Woo, sangjung.woo@samsung.com")]
+ public void GetTensorSize_CHECK_WRONG_VALUE()
+ {
+ var in_dim = new int[4] { 10, 1, 1, 1 };
+ Assert.IsInstanceOf<int[]>(in_dim, "Should return int[] instance");
+ Assert.IsNotNull(in_dim, "Failed to create in_dim instance");
+
+ try
+ {
+ var tensorsInfo = new TensorsInfo();
+ Assert.IsInstanceOf<TensorsInfo>(tensorsInfo, "Should return TensorsInfo instance");
+ Assert.IsNotNull(tensorsInfo, "Failed to create tensorsInfo instance");
+
+ int falseSize = 2;
+ foreach (int e in in_dim)
+ falseSize *= e;
+
+ tensorsInfo.AddTensorInfo(TensorType.UInt8, in_dim);
+
+ /* TEST CODE */
+ var size = tensorsInfo.GetTensorSize(0);
+ Assert.IsTrue(falseSize != size, "The size is different from the origin: Pass!");
+ }
+ catch (Exception e)
+ {
+ if (e is NotSupportedException)
+ {
+ LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs");
+ Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException");
+ }
+ else
+ {
+ Assert.True(false, e.Message);
+ }
+ }
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check ArgumentException when calling GetTensorSize() of TensorsInfo class")]
+ [Property("SPEC", "Tizen.MachineLearning.Inference.TensorsInfo.GetTensorSize M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("AUTHOR", "Sangjung Woo, sangjung.woo@samsung.com")]
+ public void GetTensorSize_CHECK_ArgumentException()
+ {
+ var in_dim = new int[4] { 10, 1, 1, 1 };
+ Assert.IsInstanceOf<int[]>(in_dim, "Should return int[] instance");
+ Assert.IsNotNull(in_dim, "Failed to create in_dim instance");
+
+ try
+ {
+ var tensorsInfo = new TensorsInfo();
+ Assert.IsInstanceOf<TensorsInfo>(tensorsInfo, "Should return TensorsInfo instance");
+ Assert.IsNotNull(tensorsInfo, "Failed to create tensorsInfo instance");
+
+ tensorsInfo.AddTensorInfo(TensorType.UInt8, in_dim);
+
+ /* TEST CODE */
+ var size = tensorsInfo.GetTensorSize(100);
+
+ Assert.True(false, "DO NOT COME HERE!");
+ }
+ catch (Exception e)
+ {
+ if (e is NotSupportedException)
+ {
+ LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs");
+ Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException");
+ }
+ else if (e is ArgumentException)
+ {
+ Assert.Pass("ArgumentException: passed!");
+ }
+ else
+ {
+ Assert.True(false, e.Message);
+ }
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Get the hash code of TensorsInfo object and compare the hash code")]
+ [Property("SPEC", "Tizen.MachineLearning.Inference.TensorsInfo.GetHashCode M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Sangjung Woo, sangjung.woo@samsung.com")]
+ public void GetHashCode_CHECK_NO_EXCEPTION()
+ {
+ var in_dim = new int[4] { 10, 1, 1, 1 };
+ Assert.IsInstanceOf<int[]>(in_dim, "Should return int[] instance");
+ Assert.IsNotNull(in_dim, "Failed to create in_dim instance");
+
+ try
+ {
+ var tensorsInfo1 = new TensorsInfo();
+ Assert.IsInstanceOf<TensorsInfo>(tensorsInfo1, "Should return TensorsInfo instance");
+ Assert.IsNotNull(tensorsInfo1, "Failed to create tensorsInfo instance");
+ tensorsInfo1.AddTensorInfo(TensorType.UInt8, in_dim);
+
+ var tensorsInfo2 = new TensorsInfo();
+ Assert.IsInstanceOf<TensorsInfo>(tensorsInfo2, "Should return TensorsInfo instance");
+ Assert.IsNotNull(tensorsInfo2, "Failed to create tensorsInfo instance");
+ tensorsInfo2.AddTensorInfo(TensorType.UInt32, in_dim);
+
+ /* TEST CODE */
+ int hash1 = tensorsInfo1.GetHashCode();
+ int hash2 = tensorsInfo2.GetHashCode();
+ Assert.IsTrue(hash1 != hash2, "GetHashCode of two TensorsInfo objects should be not equal.");
+ }
+ catch (Exception e)
+ {
+ if (e is NotSupportedException)
+ {
+ LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs");
+ Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException");
+ }
+ else
+ {
+ Assert.True(false, e.Message);
+ }
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Compare the TensorsInfo object and check the result")]
+ [Property("SPEC", "Tizen.MachineLearning.Inference.TensorsInfo.Equals M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("COVPARAM", "TensorsInfo")]
+ [Property("AUTHOR", "Sangjung Woo, sangjung.woo@samsung.com")]
+ public void Equals_CHECK_NO_EXCEPTION()
+ {
+ var in_dim = new int[4] { 10, 1, 1, 1 };
+ Assert.IsInstanceOf<int[]>(in_dim, "Should return int[] instance");
+ Assert.IsNotNull(in_dim, "Failed to create in_dim instance");
+
+ try
+ {
+ var tensorsInfo = new TensorsInfo();
+ Assert.IsInstanceOf<TensorsInfo>(tensorsInfo, "Should return TensorsInfo instance");
+ Assert.IsNotNull(tensorsInfo, "Failed to create tensorsInfo instance");
+ tensorsInfo.AddTensorInfo(TensorType.UInt8, in_dim);
+
+ var tensorsInfo2 = new TensorsInfo();
+ Assert.IsInstanceOf<TensorsInfo>(tensorsInfo2, "Should return TensorsInfo instance");
+ Assert.IsNotNull(tensorsInfo2, "Failed to create tensorsInfo instance");
+ tensorsInfo2.AddTensorInfo(TensorType.UInt8, in_dim);
+
+ /* TEST CODE */
+ Assert.IsTrue(tensorsInfo.Equals(tensorsInfo2), "Both of two TensorsInfo should be equal");
+ }
+ catch (Exception e)
+ {
+ if (e is NotSupportedException)
+ {
+ LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs");
+ Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException");
+ }
+ else
+ {
+ Assert.True(false, e.Message);
+ }
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Compare the TensorsInfo object with different count and check the result")]
+ [Property("SPEC", "Tizen.MachineLearning.Inference.TensorsInfo.Equals M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("COVPARAM", "TensorsInfo")]
+ [Property("AUTHOR", "Sangjung Woo, sangjung.woo@samsung.com")]
+ public void Equals_CHECK_Different_Count()
+ {
+ var in_dim = new int[4] { 10, 1, 1, 1 };
+ Assert.IsInstanceOf<int[]>(in_dim, "Should return int[] instance");
+ Assert.IsNotNull(in_dim, "Failed to create in_dim instance");
+
+ try
+ {
+ var tensorsInfo = new TensorsInfo();
+ Assert.IsInstanceOf<TensorsInfo>(tensorsInfo, "Should return TensorsInfo instance");
+ Assert.IsNotNull(tensorsInfo, "Failed to create tensorsInfo instance");
+ tensorsInfo.AddTensorInfo(TensorType.UInt8, in_dim);
+
+ var tensorsInfo2 = new TensorsInfo();
+ Assert.IsInstanceOf<TensorsInfo>(tensorsInfo2, "Should return TensorsInfo instance");
+ Assert.IsNotNull(tensorsInfo2, "Failed to create tensorsInfo instance");
+ tensorsInfo2.AddTensorInfo(TensorType.UInt8, in_dim);
+ tensorsInfo2.AddTensorInfo(TensorType.UInt8, in_dim);
+
+ /* TEST CODE */
+ Assert.IsFalse(tensorsInfo.Equals(tensorsInfo2), "Two TensorsInfo should be different");
+ }
+ catch (Exception e)
+ {
+ if (e is NotSupportedException)
+ {
+ LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs");
+ Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException");
+ }
+ else
+ {
+ Assert.True(false, e.Message);
+ }
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Compare the TensorsInfo object with different name and check the result")]
+ [Property("SPEC", "Tizen.MachineLearning.Inference.TensorsInfo.Equals M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("COVPARAM", "TensorsInfo")]
+ [Property("AUTHOR", "Sangjung Woo, sangjung.woo@samsung.com")]
+ public void Equals_CHECK_Different_Name()
+ {
+ var in_dim = new int[4] { 10, 1, 1, 1 };
+ Assert.IsInstanceOf<int[]>(in_dim, "Should return int[] instance");
+ Assert.IsNotNull(in_dim, "Failed to create in_dim instance");
+
+ try
+ {
+ var tensorsInfo = new TensorsInfo();
+ Assert.IsInstanceOf<TensorsInfo>(tensorsInfo, "Should return TensorsInfo instance");
+ Assert.IsNotNull(tensorsInfo, "Failed to create tensorsInfo instance");
+ tensorsInfo.AddTensorInfo("test1", TensorType.UInt8, in_dim);
+
+ var tensorsInfo2 = new TensorsInfo();
+ Assert.IsInstanceOf<TensorsInfo>(tensorsInfo2, "Should return TensorsInfo instance");
+ Assert.IsNotNull(tensorsInfo2, "Failed to create tensorsInfo instance");
+ tensorsInfo2.AddTensorInfo("test2", TensorType.UInt8, in_dim);
+
+ /* TEST CODE */
+ Assert.IsFalse(tensorsInfo.Equals(tensorsInfo2), "Two TensorsInfo should be different");
+ }
+ catch (Exception e)
+ {
+ if (e is NotSupportedException)
+ {
+ LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs");
+ Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException");
+ }
+ else
+ {
+ Assert.True(false, e.Message);
+ }
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Compare the TensorsInfo object with different type and check the result")]
+ [Property("SPEC", "Tizen.MachineLearning.Inference.TensorsInfo.Equals M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("COVPARAM", "TensorsInfo")]
+ [Property("AUTHOR", "Sangjung Woo, sangjung.woo@samsung.com")]
+ public void Equals_CHECK_Different_Type()
+ {
+ var in_dim = new int[4] { 10, 1, 1, 1 };
+ Assert.IsInstanceOf<int[]>(in_dim, "Should return int[] instance");
+ Assert.IsNotNull(in_dim, "Failed to create in_dim instance");
+
+ try
+ {
+ var tensorsInfo = new TensorsInfo();
+ Assert.IsInstanceOf<TensorsInfo>(tensorsInfo, "Should return TensorsInfo instance");
+ Assert.IsNotNull(tensorsInfo, "Failed to create tensorsInfo instance");
+ tensorsInfo.AddTensorInfo(TensorType.UInt8, in_dim);
+
+ var tensorsInfo2 = new TensorsInfo();
+ Assert.IsInstanceOf<TensorsInfo>(tensorsInfo2, "Should return TensorsInfo instance");
+ Assert.IsNotNull(tensorsInfo2, "Failed to create tensorsInfo instance");
+ tensorsInfo2.AddTensorInfo(TensorType.UInt32, in_dim);
+
+ /* TEST CODE */
+ Assert.IsFalse(tensorsInfo.Equals(tensorsInfo2), "Two TensorsInfo should be different");
+ }
+ catch (Exception e)
+ {
+ if (e is NotSupportedException)
+ {
+ LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs");
+ Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException");
+ }
+ else
+ {
+ Assert.True(false, e.Message);
+ }
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Compare the TensorsInfo object with different dimension and check the result")]
+ [Property("SPEC", "Tizen.MachineLearning.Inference.TensorsInfo.Equals M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("COVPARAM", "TensorsInfo")]
+ [Property("AUTHOR", "Sangjung Woo, sangjung.woo@samsung.com")]
+ public void Equals_CHECK_Different_Dimension()
+ {
+ var in_dim1= new int[4] { 10, 1, 1, 1 };
+ Assert.IsInstanceOf<int[]>(in_dim1, "Should return int[] instance");
+ Assert.IsNotNull(in_dim1, "Failed to create in_dim instance");
+
+ var in_dim2= new int[4] { 5, 1, 1, 1 };
+ Assert.IsInstanceOf<int[]>(in_dim2, "Should return int[] instance");
+ Assert.IsNotNull(in_dim2, "Failed to create in_dim instance");
+
+ try
+ {
+ var tensorsInfo = new TensorsInfo();
+ Assert.IsInstanceOf<TensorsInfo>(tensorsInfo, "Should return TensorsInfo instance");
+ Assert.IsNotNull(tensorsInfo, "Failed to create tensorsInfo instance");
+ tensorsInfo.AddTensorInfo(TensorType.UInt8, in_dim1);
+
+ var tensorsInfo2 = new TensorsInfo();
+ Assert.IsInstanceOf<TensorsInfo>(tensorsInfo2, "Should return TensorsInfo instance");
+ Assert.IsNotNull(tensorsInfo2, "Failed to create tensorsInfo instance");
+ tensorsInfo2.AddTensorInfo(TensorType.UInt8, in_dim2);
+
+ /* TEST CODE */
+ Assert.IsFalse(tensorsInfo.Equals(tensorsInfo2), "Two TensorsInfo should be different");
+ }
+ catch (Exception e)
+ {
+ if (e is NotSupportedException)
+ {
+ LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs");
+ Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException");
+ }
+ else
+ {
+ Assert.True(false, e.Message);
+ }
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Compare null TensorsInfo object and check the result")]
+ [Property("SPEC", "Tizen.MachineLearning.Inference.TensorsInfo.Equals M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("COVPARAM", "TensorsInfo")]
+ [Property("AUTHOR", "Sangjung Woo, sangjung.woo@samsung.com")]
+ public void Equals_CHECK_Null_Object()
+ {
+ var in_dim = new int[4] { 10, 1, 1, 1 };
+ Assert.IsInstanceOf<int[]>(in_dim, "Should return int[] instance");
+ Assert.IsNotNull(in_dim, "Failed to create in_dim instance");
+
+ try
+ {
+ var tensorsInfo = new TensorsInfo();
+ Assert.IsInstanceOf<TensorsInfo>(tensorsInfo, "Should return TensorsInfo instance");
+ Assert.IsNotNull(tensorsInfo, "Failed to create tensorsInfo instance");
+ tensorsInfo.AddTensorInfo(TensorType.UInt8, in_dim);
+
+ /* TEST CODE */
+ Assert.IsFalse(tensorsInfo.Equals(null), "Null object should retun false");
+ }
+ catch (Exception e)
+ {
+ if (e is NotSupportedException)
+ {
+ LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs");
+ Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException");
+ }
+ else
+ {
+ Assert.True(false, e.Message);
+ }
+ }
+ }
}
}