Skip to content

Commit

Permalink
Merge pull request #11 from PSU-Capstone-Team24/TC_014-015
Browse files Browse the repository at this point in the history
Tc 014 015
  • Loading branch information
masonticehurst authored Jan 28, 2024
2 parents 5ff69ee + bb5fa60 commit c42dc43
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 0 deletions.
2 changes: 2 additions & 0 deletions eRINA_Tests/src/erina_tests.adb
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
Expand Down
65 changes: 65 additions & 0 deletions eRINA_Tests/src/test_rina_unregister.adb
Original file line number Diff line number Diff line change
@@ -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;
16 changes: 16 additions & 0 deletions eRINA_Tests/src/test_rina_unregister.ads
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit c42dc43

Please sign in to comment.