Académique Documents
Professionnel Documents
Culture Documents
Fecha: 15/05/2016
Ejercicios de Caja Blanca
1. Considere el siguiente segmento de cdigo que busca un
elemento en un arreglo (table), asuma que la comparacin de
igualdad se representa con =
y la asignacin de valores con :=
y un arreglo se indexa en base al formato arreglo(i) (i.e se accede
al i-simo elemento de arreglo).
found: = false; counter:=1;
while (not found) and (counter < number_of_items) loop
if table(counter) = desired_element then
found : = true;
end if;
counter := counter +1;
end loop;
if found then
write(the desired element exists in the table);
else
write (the desired element does not exists in the table);
end if;
foun
d
desired_elem
ent
count
er
n_of_item write/Resultado
s
table (0)
=3
false
el arreglo no
compara desde el
valor inicial en 0
por lo que no lo
encuentra
table (1)
=2
false
table (2)
=5
false
no ingresa por la
condicin
table (i)
found
desired_element
numb_of_ite
ms
write
empty
false
the desired
element does
not exists in
the table
table (i)
foun
d
desired_elem
ent
count
er
n_of_ite
ms
write/Resultado
table (0) =
3
false
the desired
element does not
exists in the
table
table (1) =
2
false
the desired
element does not
exists in the
table
table (2) =
true
the desired
element exists in
the table
=3
Conjunto de pruebas de caja blanca
while (i < x) do begin
-
TABLA DE VERDAD
VALORES
I<x
>= X
<I
<X
>I
tcnica de dominio
DIRECTRIZ
a(i)
valor menor
< 50
valor igual
= 50
valor mayor
> 50
Tabla de Casos
ID
a[i]
Resultado
ok
end of
nonsense
end of
nonsense
49
ok
50
ok
51
array is
over the
limit