diff --git a/eRINA_Tests/src/erina_tests.adb b/eRINA_Tests/src/erina_tests.adb index cd5f174..cdd44bf 100644 --- a/eRINA_Tests/src/erina_tests.adb +++ b/eRINA_Tests/src/erina_tests.adb @@ -9,6 +9,7 @@ with AUnit.Test_Suites; -- Test suites with Test_RINA_Open; with Test_RINA_Register; +with Test_RINA_Unregister; with Test_RINA_Flow_Alloc_Wait; with Test_RINA_Flow_Alloc; @@ -21,6 +22,7 @@ procedure eRINA_Tests is begin Result.Add_Test (Test_RINA_Open.Suite); Result.Add_Test (Test_RINA_Register.Suite); + Result.Add_Test (Test_RINA_Unregister.Suite); Result.Add_Test (Test_RINA_Flow_Alloc_Wait.Suite); Result.Add_Test (Test_RINA_Flow_Alloc.Suite); diff --git a/eRINA_Tests/src/test_rina_unregister.adb b/eRINA_Tests/src/test_rina_unregister.adb new file mode 100644 index 0000000..5c13af1 --- /dev/null +++ b/eRINA_Tests/src/test_rina_unregister.adb @@ -0,0 +1,65 @@ +-- Temp disabling +pragma Style_Checks (Off); + +with AUnit.Assertions; +with AUnit.Test_Caller; +with GNAT.OS_Lib; +with Bindings.Rlite.API; +with Exceptions; + +package body Test_RINA_Unregister is + use AUnit.Assertions; + use GNAT.OS_Lib; + use Bindings.Rlite.API; + + Application_Name : constant String := "TestApplicationName"; + DIF_Name : constant String := "test.DIF"; + RINA_Dev_FD : constant File_Descriptor := RINA_Open; + + package Caller is new AUnit.Test_Caller (Test); + + Test_Suite : aliased AUnit.Test_Suites.Test_Suite; + + function Suite return AUnit.Test_Suites.Access_Test_Suite is + Name_014 : constant String := "TC-014"; + Name_015 : constant String := "TC-015"; + begin + Test_Suite.Add_Test (Caller.Create + (Name_014 & " Verify rina_unregister throws exception when DIF name empty", Test_Unregister_DIF_Name_Empty'Access)); + Test_Suite.Add_Test (Caller.Create + (Name_015 & " Verify rina_unregister throws exception when DIF name isn't already registered", Test_Unregister_DIF_Name_Not_Registered'Access)); + + return Test_Suite'Access; + end Suite; + + --Test Case 014 + procedure Test_Unregister_DIF_Name_Empty (Object : in out Test) is + DIF_Name : constant String := ""; + App_Name : constant String := "Test App"; + Unregister_Success : File_Descriptor := Invalid_FD; + Caused_Error : Boolean := False; + begin + + Unregister_Success := RINA_Unregister (RINA_Dev_FD, DIF_Name, App_Name, 0); + exception + when Exceptions.Bounded_Length_Expcetion => + Caused_Error := True; + + Assert (Caused_Error and Unregister_Success = Invalid_FD, "DIF_Name is empty"); + end Test_Unregister_DIF_Name_Empty; + + procedure Test_Unregister_DIF_Name_Not_Registered (Object : in out Test) is + DIF_Name : constant String := "Unique_DIF_Name"; + App_Name : constant String := "Test App"; + Unregister_Success : File_Descriptor := Invalid_FD; + Caused_Error : Boolean := False; + begin + Unregister_Success := RINA_Unregister (RINA_Dev_FD, DIF_Name, App_Name, 0); + exception + when Exceptions.DIF_Registration_Failure => + Caused_Error := True; + + Assert (Caused_Error and Unregister_Success = Invalid_FD, "DIF_Name is not already registered"); + end Test_Unregister_DIF_Name_Not_Registered; + +end Test_RINA_Unregister; \ No newline at end of file diff --git a/eRINA_Tests/src/test_rina_unregister.ads b/eRINA_Tests/src/test_rina_unregister.ads new file mode 100644 index 0000000..dde01d1 --- /dev/null +++ b/eRINA_Tests/src/test_rina_unregister.ads @@ -0,0 +1,16 @@ +-- Temp disabling +pragma Style_Checks (Off); + +with AUnit.Test_Suites; +with AUnit.Test_Fixtures; + +package Test_RINA_Unregister is + function Suite return AUnit.Test_Suites.Access_Test_Suite; + +private + type Test is new AUnit.Test_Fixtures.Test_Fixture with null record; + + procedure Test_Unregister_DIF_Name_Empty (Object : in out Test); + procedure Test_Unregister_DIF_Name_Not_Registered (Object : in out Test); + +end Test_RINA_Unregister;