From 3ee2781b439bbbd0b735fbc4037313164d6d37d3 Mon Sep 17 00:00:00 2001 From: Sangjung Woo Date: Fri, 20 Dec 2019 13:20:54 +0900 Subject: [PATCH] [Tizen.MachineLearning.Inference][TCSACR-295] Add TCs for new functionality of the Singleshot mode Change-Id: Ic4d47885be67bae523974fe12be0d495595189c8 Signed-off-by: Sangjung Woo --- .../res/add.tflite | Bin 0 -> 460 bytes .../testcase/TSSingleShot.cs | 814 ++++++++++++++++++++- .../testcase/TSTensorsData.cs | 112 ++- .../testcase/TSTensorsInfo.cs | 650 ++++++++++++++-- 4 files changed, 1491 insertions(+), 85 deletions(-) create mode 100644 tct-suite-vs/Tizen.MachineLearning.Inference.Tests/res/add.tflite diff --git a/tct-suite-vs/Tizen.MachineLearning.Inference.Tests/res/add.tflite b/tct-suite-vs/Tizen.MachineLearning.Inference.Tests/res/add.tflite new file mode 100644 index 0000000000000000000000000000000000000000..e748b6843646a295dfe5e701cf22259bb93adc6e GIT binary patch literal 460 zcmXw$Jx&5q6orq9LgEA|D5kJ@C5160x&X}(E0dv^g2H4%0)-6{0z@l2SHMb)g@p@n zRX)E1^WNl}d*{A$|1!Cx>f!N5>MB=D9cAjN&zE!pzmP!>0vy2;TtHP8Whh=2+xcoe zpIwtJ4PgKQoF|=8v&CEcduup%Uw<)v!w+QiOP!swgc(f0diU&uXSDT(XA*dtv?Ict779{(|?j*7vrTjqh*Qz8{V1svMKyNBReGT`{2m literal 0 HcmV?d00001 diff --git a/tct-suite-vs/Tizen.MachineLearning.Inference.Tests/testcase/TSSingleShot.cs b/tct-suite-vs/Tizen.MachineLearning.Inference.Tests/testcase/TSSingleShot.cs index 724a7a5..72d177d 100755 --- a/tct-suite-vs/Tizen.MachineLearning.Inference.Tests/testcase/TSSingleShot.cs +++ b/tct-suite-vs/Tizen.MachineLearning.Inference.Tests/testcase/TSSingleShot.cs @@ -28,8 +28,9 @@ namespace Tizen.MachineLearning.Inference.Tests { [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; @@ -40,7 +41,7 @@ namespace Tizen.MachineLearning.Inference.Tests { [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); @@ -57,7 +58,7 @@ namespace Tizen.MachineLearning.Inference.Tests { [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) { @@ -72,6 +73,7 @@ namespace Tizen.MachineLearning.Inference.Tests { [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() { @@ -102,23 +104,449 @@ namespace Tizen.MachineLearning.Inference.Tests { [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(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(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(single, "Should return SingleShot instance"); + Assert.IsNotNull(single, "Failed to create SingleShot instance"); + + var in_res = single.Input; + Assert.IsInstanceOf(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(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(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(single, "Should return SingleShot instance"); + Assert.IsNotNull(single, "Failed to create SingleShot instance"); + + var in_data = _in_info.GetTensorsData(); + Assert.IsInstanceOf(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(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(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) @@ -127,7 +555,181 @@ namespace Tizen.MachineLearning.Inference.Tests { } 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(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(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(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(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(single, "Should return SingleShot instance"); + Assert.IsNotNull(single, "Failed to create SingleShot instance"); + + var tensorInfo = new TensorsInfo(); + Assert.IsInstanceOf(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(single, "Should return SingleShot instance"); + Assert.IsNotNull(single, "Failed to create SingleShot instance"); + + /* TEST CODE */ + var output_info = single.Output; + Assert.IsInstanceOf(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); } } } @@ -172,13 +774,15 @@ namespace Tizen.MachineLearning.Inference.Tests { Assert.IsInstanceOf(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 @@ -190,54 +794,216 @@ namespace Tizen.MachineLearning.Inference.Tests { [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(in_info, "Should return TensorsInfo instance"); - Assert.IsNotNull(in_info, "Failed to create TensorsInfo instance"); + var wrong_in_info = new TensorsInfo(); + Assert.IsInstanceOf(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(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(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(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(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(single, "Should return SingleShot instance"); + Assert.IsNotNull(single, "Failed to create SingleShot instance"); var in_data = _in_info.GetTensorsData(); Assert.IsInstanceOf(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(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(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(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(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(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(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(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); } } } diff --git a/tct-suite-vs/Tizen.MachineLearning.Inference.Tests/testcase/TSTensorsData.cs b/tct-suite-vs/Tizen.MachineLearning.Inference.Tests/testcase/TSTensorsData.cs index eb2f6c0..b8d96c3 100755 --- a/tct-suite-vs/Tizen.MachineLearning.Inference.Tests/testcase/TSTensorsData.cs +++ b/tct-suite-vs/Tizen.MachineLearning.Inference.Tests/testcase/TSTensorsData.cs @@ -26,7 +26,7 @@ namespace Tizen.MachineLearning.Inference.Tests { [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; @@ -36,10 +36,9 @@ namespace Tizen.MachineLearning.Inference.Tests { [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) { @@ -74,11 +73,11 @@ namespace Tizen.MachineLearning.Inference.Tests { try { - /* TEST CODE */ var tensorsData = _tensorsInfo.GetTensorsData(); Assert.IsInstanceOf(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(); } @@ -111,12 +110,14 @@ namespace Tizen.MachineLearning.Inference.Tests { try { - /* TEST CODE */ var tensorsData = _tensorsInfo.GetTensorsData(); Assert.IsInstanceOf(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) { @@ -208,6 +209,8 @@ namespace Tizen.MachineLearning.Inference.Tests { /* TEST CODE */ var buffer_out = tensorsData.GetTensorData(100); + + Assert.True(false, "DO NOT COME HERE!"); } catch (Exception e) { @@ -264,5 +267,104 @@ namespace Tizen.MachineLearning.Inference.Tests { } } } + + [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 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 is not the type of TensorsData."); + Assert.IsNotNull(tensorsData, "Fail to create tensorsData."); + + /* TEST CODE */ + var tensorsInfo = tensorsData.TensorsInfo; + Assert.IsInstanceOf(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); + } + } + } } } diff --git a/tct-suite-vs/Tizen.MachineLearning.Inference.Tests/testcase/TSTensorsInfo.cs b/tct-suite-vs/Tizen.MachineLearning.Inference.Tests/testcase/TSTensorsInfo.cs index 20ba274..b6cbe37 100755 --- a/tct-suite-vs/Tizen.MachineLearning.Inference.Tests/testcase/TSTensorsInfo.cs +++ b/tct-suite-vs/Tizen.MachineLearning.Inference.Tests/testcase/TSTensorsInfo.cs @@ -17,6 +17,7 @@ using NUnit.Framework; using NUnit.Framework.TUnit; using System; +using System.Linq; using Tizen; using Tizen.System; using Tizen.MachineLearning.Inference; @@ -27,7 +28,7 @@ namespace Tizen.MachineLearning.Inference.Tests { [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; @@ -35,7 +36,7 @@ namespace Tizen.MachineLearning.Inference.Tests { [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); } @@ -43,7 +44,7 @@ namespace Tizen.MachineLearning.Inference.Tests { [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] @@ -78,7 +79,6 @@ namespace Tizen.MachineLearning.Inference.Tests { } } - [Test] [Category("P1")] [Description("Add TensorInfo into TensorsInfo with the input dimension information")] @@ -273,6 +273,86 @@ namespace Tizen.MachineLearning.Inference.Tests { } [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, "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, "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")] @@ -314,12 +394,12 @@ namespace Tizen.MachineLearning.Inference.Tests { [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 }; @@ -344,9 +424,9 @@ namespace Tizen.MachineLearning.Inference.Tests { 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 { @@ -357,7 +437,7 @@ namespace Tizen.MachineLearning.Inference.Tests { [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")] @@ -399,14 +479,14 @@ namespace Tizen.MachineLearning.Inference.Tests { [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(in_dim, "Should return int[] instance"); Assert.IsNotNull(in_dim, "Failed to create in_dim instance"); @@ -420,7 +500,7 @@ namespace Tizen.MachineLearning.Inference.Tests { tensorsInfo.AddTensorInfo(TensorType.UInt8, in_dim); /* TEST CODE */ - tensorsInfo.SetTensorName(100, inTensorName); + tensorsInfo.SetTensorName(0, null); } catch (Exception e) { @@ -429,9 +509,9 @@ namespace Tizen.MachineLearning.Inference.Tests { 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 { @@ -442,27 +522,20 @@ namespace Tizen.MachineLearning.Inference.Tests { [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(in_dim, "Should return int[] instance"); - Assert.IsNotNull(in_dim, "Failed to create in_dim instance"); - try { var tensorsInfo = new TensorsInfo(); - Assert.IsInstanceOf(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) { @@ -523,12 +596,12 @@ namespace Tizen.MachineLearning.Inference.Tests { [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(in_dim, "Should return int[] instance"); @@ -552,9 +625,9 @@ namespace Tizen.MachineLearning.Inference.Tests { 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 { @@ -610,12 +683,12 @@ namespace Tizen.MachineLearning.Inference.Tests { [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(in_dim, "Should return int[] instance"); @@ -639,9 +712,9 @@ namespace Tizen.MachineLearning.Inference.Tests { 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 { @@ -702,31 +775,27 @@ namespace Tizen.MachineLearning.Inference.Tests { [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(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(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, "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) { @@ -735,9 +804,9 @@ namespace Tizen.MachineLearning.Inference.Tests { 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 { @@ -748,27 +817,26 @@ namespace Tizen.MachineLearning.Inference.Tests { [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(in_dim, "Should return int[] instance"); - Assert.IsNotNull(in_dim, "Failed to create in_dim instance"); - try { var tensorsInfo = new TensorsInfo(); Assert.IsInstanceOf(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(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) { @@ -832,12 +900,12 @@ namespace Tizen.MachineLearning.Inference.Tests { [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(in_dim, "Should return int[] instance"); @@ -861,9 +929,9 @@ namespace Tizen.MachineLearning.Inference.Tests { 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 { @@ -929,6 +997,44 @@ namespace Tizen.MachineLearning.Inference.Tests { } [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(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")] @@ -964,5 +1070,437 @@ namespace Tizen.MachineLearning.Inference.Tests { } } } + + [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(in_dim, "Should return int[] instance"); + Assert.IsNotNull(in_dim, "Failed to create in_dim instance"); + + try + { + var tensorsInfo = new TensorsInfo(); + Assert.IsInstanceOf(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(in_dim, "Should return int[] instance"); + Assert.IsNotNull(in_dim, "Failed to create in_dim instance"); + + try + { + var tensorsInfo = new TensorsInfo(); + Assert.IsInstanceOf(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(in_dim, "Should return int[] instance"); + Assert.IsNotNull(in_dim, "Failed to create in_dim instance"); + + try + { + var tensorsInfo = new TensorsInfo(); + Assert.IsInstanceOf(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(in_dim, "Should return int[] instance"); + Assert.IsNotNull(in_dim, "Failed to create in_dim instance"); + + try + { + var tensorsInfo1 = new TensorsInfo(); + Assert.IsInstanceOf(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(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(in_dim, "Should return int[] instance"); + Assert.IsNotNull(in_dim, "Failed to create in_dim instance"); + + try + { + var tensorsInfo = new TensorsInfo(); + Assert.IsInstanceOf(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(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(in_dim, "Should return int[] instance"); + Assert.IsNotNull(in_dim, "Failed to create in_dim instance"); + + try + { + var tensorsInfo = new TensorsInfo(); + Assert.IsInstanceOf(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(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(in_dim, "Should return int[] instance"); + Assert.IsNotNull(in_dim, "Failed to create in_dim instance"); + + try + { + var tensorsInfo = new TensorsInfo(); + Assert.IsInstanceOf(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(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(in_dim, "Should return int[] instance"); + Assert.IsNotNull(in_dim, "Failed to create in_dim instance"); + + try + { + var tensorsInfo = new TensorsInfo(); + Assert.IsInstanceOf(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(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(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(in_dim2, "Should return int[] instance"); + Assert.IsNotNull(in_dim2, "Failed to create in_dim instance"); + + try + { + var tensorsInfo = new TensorsInfo(); + Assert.IsInstanceOf(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(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(in_dim, "Should return int[] instance"); + Assert.IsNotNull(in_dim, "Failed to create in_dim instance"); + + try + { + var tensorsInfo = new TensorsInfo(); + Assert.IsInstanceOf(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); + } + } + } } } -- 2.7.4