text stringlengths 0 234 |
|---|
Function Definition: procedure Register_Tests (T : in out TC) is |
Function Body: use AUnit.Test_Cases.Registration; |
begin |
Register_Routine |
(T, Test_Get_String_Flag_OK_With_Default'Access, "Test CLI get string with default values"); |
Register_Routine |
(T, Test_Get_String_Flag_Throws_No_Flag_Or_Short'Access, "Test CLI get string throws when no flag and short"); |
Register_Routine |
(T, Test_Get_String_Flag_Throws_When_Required'Access, "Test CLI get string when required argument not found"); |
end Register_Tests; |
function Name (T : TC) return Message_String is |
pragma Unreferenced (T); |
begin |
return AUnit.Format ("CLI Get_String_Flag"); |
end Name; |
procedure Set_Up (T : in out TC) is |
begin |
null; |
end Set_Up; |
-- Test_Get_String_Flag_OK_With_Default |
-- ------------------------------------ |
procedure Test_Get_String_Flag_OK_With_Default (T : in out Test_Cases.Test_Case'Class) is |
Required_Flag : constant String := "--test-switch"; |
Default_Value : constant String := "this is the default value"; |
begin |
declare |
Res : String := Cli.Get_String_Flag(Flag => Required_Flag, Required => false, DefaultValue => Default_Value); |
begin |
Assert(Res = Default_Value, "Expected didn't match received: expected=" & Default_Value & ", received=" & Res); |
Function Definition: procedure Main is |
Function Body: begin |
begin |
declare |
GrossSalaryValue : Float := Get_Float_Flag(Flag => "--gross", Short => "-g", Required => true); |
GrossMode : String := Get_String_Flag(Flag => "--mode", Short => "-m", DefaultValue => "annual"); |
begin |
Put_Line("Hello, World... gross=" & Float'Image(GrossSalaryValue) & ", mode=" & GrossMode); |
Function Definition: procedure Represent is |
Function Body: use Ada; |
type Byte is mod 2**8 with Size => 8; |
type T_Instruction is (Load, Store, Clear, Move) |
with Size => 2; |
for T_Instruction use (Load => 2#00#, |
Store => 2#01#, |
Clear => 2#10#, |
Move => 2#11#); |
type T_Register is mod 2**3 with Size => 3; |
type Command is record |
Instruction : T_Instruction; |
Source : T_Register; |
Dest : T_Register; |
end record |
with |
Size => 8, |
Bit_Order => System.Low_Order_First; |
for Command use record |
Instruction at 0 range 6 .. 7; |
Source at 0 range 3 .. 5; |
Dest at 0 range 0 .. 2; |
end record; |
function To_Byte is new Unchecked_Conversion |
(Source => Command, |
Target => Byte); |
procedure Put_Instruction |
(Instruction : T_Instruction; |
Src, Dest : T_Register) |
is |
Instr : Command := (Instruction, Src, Dest); |
begin |
Put_Line (Byte'Image (To_Byte (Instr))); |
Function Definition: procedure Task_Queue is |
Function Body: -- cf. Barnes, J., "Programming in Ada 2012" (Chapter 20) |
task Buffer is |
entry Put (X : in Integer); |
entry Get (X : out Integer); |
Function Definition: procedure represent2 is |
Function Body: type Action_Type is (Load, |
Store, |
Copy, |
Add, |
Clear, |
Jump, |
Ret) |
with Size => 4; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.