Skip to content

Commit

Permalink
tb_set_generic: test generic string length
Browse files Browse the repository at this point in the history
  • Loading branch information
eine committed Jan 13, 2020
1 parent 522c456 commit 3198655
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 14 deletions.
5 changes: 5 additions & 0 deletions tests/acceptance/artificial/vhdl/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ def configure_tb_set_generic(ui):
tb.set_generic("str_val", "4ns")
tb.set_generic("str_space_val", "1 2 3")
tb.set_generic("str_quote_val", 'a"b')
str_long_num = 512
tb.set_generic("str_long_num", str_long_num)
tb.set_generic(
"str_long_val", "".join(["0123456789abcdef" for x in range(str_long_num)])
)


def configure_tb_assert_stop_level(ui):
Expand Down
39 changes: 25 additions & 14 deletions tests/acceptance/artificial/vhdl/tb_set_generic.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,48 @@ context vunit_lib.vunit_context;

entity tb_set_generic is
generic (
runner_cfg : string;
is_ghdl : boolean;
true_boolean : boolean;
false_boolean : boolean;
runner_cfg : string;
is_ghdl : boolean;
true_boolean : boolean;
false_boolean : boolean;
negative_integer : integer;
positive_integer : integer;
negative_real : real := 0.0;
positive_real : real := 0.0;
time_val : time := 0 ns;
str_val : string;
str_space_val : string;
str_quote_val : string);
negative_real : real := 0.0;
positive_real : real := 0.0;
time_val : time := 0 ns;
str_val : string;
str_space_val : string;
str_quote_val : string;
str_long_num : integer := 64;
str_long_val : string);
end entity;

architecture tb of tb_set_generic is
impure function str_long(num: natural) return string is
variable str: string(1 to 16*num);
begin
for x in 1 to num loop
str((x-1)*16+1 to x*16) := "0123456789abcdef";
end loop;
return str;
end;
begin
main : process
begin
test_runner_setup(runner, runner_cfg);
assert true_boolean = true;
assert false_boolean = false;
assert true_boolean = true;
assert false_boolean = false;
assert negative_integer = -10000;
assert positive_integer = 99999;
if not is_ghdl then
assert negative_real = -9999.9;
assert positive_real = 2222.2;
assert time_val = 4 ns;
assert time_val = 4 ns;
end if;
assert str_val = "4ns";
assert str_val = "4ns";
assert str_space_val = "1 2 3";
assert str_quote_val = "a""b";
assert str_long_val = str_long(str_long_num);
test_runner_cleanup(runner);
end process;
end architecture;

0 comments on commit 3198655

Please sign in to comment.