close all;
clear all;
clc;

% testcase 1
k = 1;
x = 27.375;
[d,v,t] = dez2bad(2,8,3,x);
if (max([d-[1 1 0 1 1 0 1 1],v-[1 0 1],t-1]) == 0)
   fprintf('Testcase %d: Passed.\n',k)  
else
   fprintf(2,'Testcase %d: Failed.\n',k) 
end

% testcase 2
k = 2;
x = 27.375;
[d,v,t] = dez2bad(8,8,3,x);
if (max([d-[3 3 3 0 0 0 0 0],v-[0 0 2],t-1]) == 0)
   fprintf('Testcase %d: Passed.\n',k)  
else
   fprintf(2,'Testcase %d: Failed.\n',k) 
end

% testcase 3
k = 3;
x = 9.140625;
[d,v,t] = dez2bad(2,10,3,x);
if (max([d-[1 0 0 1 0 0 1 0 0 1],v-[1 0 0],t-1]) == 0)
   fprintf('Testcase %d: Passed.\n',k)  
else
   fprintf(2,'Testcase %d: Failed.\n',k) 
end

% testcase 4
k = 4;
x = 9.140625;
[d,v,t] = dez2bad(8,5,3,x);
if (max([d-[1 1 1 1 0],v-[0 0 2],t-1]) == 0)
   fprintf('Testcase %d: Passed.\n',k)  
else
   fprintf(2,'Testcase %d: Failed.\n',k) 
end

% testcase 5
k = 5;
x = 0.375;
[d,v,t] = dez2bad(2,3,2,x);
if (max([d-[1 1 0],v-[0 1],t+1]) == 0)
   fprintf('Testcase %d: Passed.\n',k)  
else
   fprintf(2,'Testcase %d: Failed.\n',k) 
end

% testcase 6
k = 6;
x = 0.0375;
[d,v,t] = dez2bad(8,5,2,x);
if (max([d-[2 3 1 4 6],v-[0 1],t+1]) == 0)
   fprintf('Testcase %d: Passed.\n',k)  
else
   fprintf(2,'Testcase %d: Failed.\n',k) 
end

% testcase 7
k = 7;
x = 0.0625;
[d,v,t] = dez2bad(2,3,3,x);
if (max([d-[1 0 0],v-[0 1 1],t+1]) == 0)
   fprintf('Testcase %d: Passed.\n',k)  
else
   fprintf(2,'Testcase %d: Failed.\n',k) 
end
