clear all;
close all;
clc;

%testcase 1: b = 2, n = 31
n = 31;
a = [1 1 1 1 1];
if (max(abs(a-convert2basis(2,n)))==0)
    fprintf('Testcase 1 (b=%d,n=%d): Passed.\n',2,n)
else
    fprintf(2,'Testcase 1 (b=%d,n=%d): Failed.\n',2,n)
end

%testcase 2: b = 2, n = 42
n = 42;
a = [1 0 1 0 1 0];
if (max(abs(a-convert2basis(2,n)))==0)
    fprintf('Testcase 2 (b=%d,n=%d): Passed.\n',2,n)
else
    fprintf(2,'Testcase 2 (b=%d,n=%d): Failed.\n',2,n)
end    

%testcase 3: b = 2, n = 134110
n = 134110;
a = [1 0 0 0 0 0 1 0 1 1 1 1 0 1 1 1 1 0];
if (max(abs(a-convert2basis(2,n)))==0)
    fprintf('Testcase 3 (b=%d,n=%d): Passed.\n',2,n)
else
    fprintf(2,'Testcase 3 (b=%d,n=%d): Failed.\n',2,n)
end    

%testcase 4: b = 8, n = 27
n = 27;
a = [3 3];
if (max(abs(a-convert2basis(8,n)))==0)
    fprintf('Testcase 4 (b=%d,n=%d): Passed.\n',8,n)
else
    fprintf(2,'Testcase 4 (b=%d,n=%d): Failed.\n',8,n)
end

%testcase 5: b = 8, n = 3652
n = 3652;
a = [7 1 0 4];
if (max(abs(a-convert2basis(8,n)))==0)
    fprintf('Testcase 5 (b=%d,n=%d): Passed.\n',8,n)
else
    fprintf(2,'Testcase 5 (b=%d,n=%d): Failed.\n',8,n)
end

%testcase 6: b = 8, n = 46807
n = 46807;
a = [1 3 3 3 2 7];
if (max(abs(a-convert2basis(8,n)))==0)
    fprintf('Testcase 6 (b=%d,n=%d): Passed.\n',8,n)
else
    fprintf(2,'Testcase 6 (b=%d,n=%d): Failed.\n',8,n)
end

%testcase 7: b = 10, n = 3121
n = 3121;
a = [3 1 2 1];
if (max(abs(a-convert2basis(10,n)))==0)
    fprintf('Testcase 7 (b=%d,n=%d): Passed.\n',10,n)
else
    fprintf(2,'Testcase 7 (b=%d,n=%d): Failed.\n',10,n)
end

%testcase 8: b = 10, n = 192310030133
n = 192310030133;
a = [1 9 2 3 1 0 0 3 0 1 3 3];
if (max(abs(a-convert2basis(10,n)))==0)
    fprintf('Testcase 8 (b=%d,n=%d): Passed.\n',10,n)
else
    fprintf(2,'Testcase 8 (b=%d,n=%d): Failed.\n',10,n)
end

