Commit 1018365c authored by Bednárek David RNDr. Ph.D.'s avatar Bednárek David RNDr. Ph.D.
Browse files

asgn 4 tests

# Conflicts:
#	test/CMakeLists.txt
parent 716b5bec
function(CONFIG_TEST ANUM)
set(CFGNAME "TEST_CECKO${ANUM}")
if(NOT DEFINED ${CFGNAME})
set(${CFGNAME} TRUE CACHE BOOL "Test cecko${ANUM}")
message("${CFGNAME} was not defined, defaulting to TRUE")
endif()
endfunction()
CONFIG_TEST("1")
CONFIG_TEST("2")
CONFIG_TEST("3")
CONFIG_TEST("4")
CONFIG_TEST("5")
function(MAKE_TEST ANUM NAME)
set(TEST_NAME_RUN "${SOL_PREFIX}A${ANUM}T${NAME}R")
set(TEST_NAME_JUDGE "${SOL_PREFIX}A${ANUM}T${NAME}J")
set(TEST_EXE "${SOL_PREFIX}cecko${ANUM}")
set(TEST_MESSAGE "cecko${ANUM}")
set(TEST_INPUT "${NAME}.c")
set(TEST_OUTPUT "${NAME}.${TEST_EXE}.out")
set(TEST_GOLD "${NAME}.cecko${ANUM}.gold")
set(FNAME_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${TEST_OUTPUT}")
add_test(NAME "${TEST_NAME_RUN}" COMMAND "${TEST_EXE}" "-z" "${FNAME_OUTPUT}" "${TEST_INPUT}" WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
#set_tests_properties("${TEST_NAME_RUN}" PROPERTIES PASS_REGULAR_EXPRESSION ".*${TEST_MESSAGE} done.*")
set_tests_properties("${TEST_NAME_RUN}" PROPERTIES FIXTURES_SETUP "${TEST_OUTPUT}")
set_tests_properties("${TEST_NAME_RUN}" PROPERTIES TIMEOUT "5")
add_test(NAME "${TEST_NAME_JUDGE}" COMMAND "${CMAKE_COMMAND}" "-E" "compare_files" "--ignore-eol" "${FNAME_OUTPUT}" "${TEST_GOLD}" WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
set_tests_properties("${TEST_NAME_JUDGE}" PROPERTIES FIXTURES_REQUIRED "${TEST_OUTPUT}")
set_tests_properties("${TEST_NAME_JUDGE}" PROPERTIES TIMEOUT "5")
set(CFGNAME "TEST_CECKO${ANUM}")
if(${CFGNAME})
set(TEST_NAME_RUN "${SOL_PREFIX}A${ANUM}T${NAME}R")
set(TEST_NAME_JUDGE "${SOL_PREFIX}A${ANUM}T${NAME}J")
set(TEST_EXE "${SOL_PREFIX}cecko${ANUM}")
set(TEST_MESSAGE "cecko${ANUM}")
set(TEST_INPUT "${NAME}.c")
set(TEST_OUTPUT "${NAME}.${TEST_EXE}.out")
set(TEST_GOLD "${NAME}.cecko${ANUM}.gold")
set(FNAME_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${TEST_OUTPUT}")
add_test(NAME "${TEST_NAME_RUN}" COMMAND "${TEST_EXE}" "-z" "${FNAME_OUTPUT}" "${TEST_INPUT}" WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
#set_tests_properties("${TEST_NAME_RUN}" PROPERTIES PASS_REGULAR_EXPRESSION ".*${TEST_MESSAGE} done.*")
set_tests_properties("${TEST_NAME_RUN}" PROPERTIES FIXTURES_SETUP "${TEST_OUTPUT}")
set_tests_properties("${TEST_NAME_RUN}" PROPERTIES TIMEOUT "5")
add_test(NAME "${TEST_NAME_JUDGE}" COMMAND "${CMAKE_COMMAND}" "-E" "compare_files" "--ignore-eol" "${FNAME_OUTPUT}" "${TEST_GOLD}" WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
set_tests_properties("${TEST_NAME_JUDGE}" PROPERTIES FIXTURES_REQUIRED "${TEST_OUTPUT}")
set_tests_properties("${TEST_NAME_JUDGE}" PROPERTIES TIMEOUT "5")
endif()
endfunction()
MAKE_TEST("1" "test1")
......@@ -45,15 +62,14 @@ MAKE_TEST("3" "testdecl-pointer")
MAKE_TEST("3" "testdecl-struct")
MAKE_TEST("3" "testdecl-typedef")
MAKE_TEST("4" "test1")
MAKE_TEST("4" "test2typedef")
MAKE_TEST("4" "testexpr-compop")
MAKE_TEST("4" "testexpr-conv")
MAKE_TEST("4" "testexpr-intop")
MAKE_TEST("4" "testexpr-pointer")
MAKE_TEST("4" "testexpr-ptrop")
MAKE_TEST("4" "testexpr-sizeof")
MAKE_TEST("4" "testexpr-struct")
#MAKE_TEST("5" "test1")
#MAKE_TEST("5" "test2typedef")
#MAKE_TEST("5" "testsxa-arr")
#MAKE_TEST("5" "testsxa-enum")
#MAKE_TEST("5" "testsxa-expr")
#MAKE_TEST("5" "testsxa-stmt")
#MAKE_TEST("5" "testsxa-struct")
#MAKE_TEST("5" "testsxa-typedef")
MAKE_TEST("5" "test1")
MAKE_TEST("5" "test2typedef")
MAKE_TEST("5" "testcontrol-shortcut")
========== tables ==========
// --- GLOBAL TYPEDEFS ---
typedef struct _file_s_0 FILE_0;
// --- FUNCTION DECLARATIONS ---
void f_3(_Bool,_Bool,_Bool,_Bool);
int main_25(int,char**);
void*memset_0(void*,int,int);
int printf_0(const char*,...);
int scanf_0(const char*,...);
int sprintf_0(char*,const char*,...);
int sscanf_0(const char*,const char*,...);
// --- GLOBAL VARIABLES ---
// --- FUNCTION DEFINITIONS ---
void f_3(_Bool a_3,_Bool b_3,_Bool c_3,_Bool d_3){
{
}
{
}
{
}
{
}
}
int main_25(int argc_25,char**argv_25){
{
}
}
========== starting main() ==========
((0&&0)||(0&&0)) = 0 ; ((0||0)&&(0||0)) = 0
((0&&0)||(0&&1)) = 0 ; ((0||0)&&(0||1)) = 0
((0&&0)||(1&&0)) = 0 ; ((0||0)&&(1||0)) = 0
((0&&0)||(1&&1)) = 1 ; ((0||0)&&(1||1)) = 0
((0&&1)||(0&&0)) = 0 ; ((0||1)&&(0||0)) = 0
((0&&1)||(0&&1)) = 0 ; ((0||1)&&(0||1)) = 1
((0&&1)||(1&&0)) = 0 ; ((0||1)&&(1||0)) = 1
((0&&1)||(1&&1)) = 1 ; ((0||1)&&(1||1)) = 1
((1&&0)||(0&&0)) = 0 ; ((1||0)&&(0||0)) = 0
((1&&0)||(0&&1)) = 0 ; ((1||0)&&(0||1)) = 1
((1&&0)||(1&&0)) = 0 ; ((1||0)&&(1||0)) = 1
((1&&0)||(1&&1)) = 1 ; ((1||0)&&(1||1)) = 1
((1&&1)||(0&&0)) = 1 ; ((1||1)&&(0||0)) = 0
((1&&1)||(0&&1)) = 1 ; ((1||1)&&(0||1)) = 1
((1&&1)||(1&&0)) = 1 ; ((1||1)&&(1||0)) = 1
((1&&1)||(1&&1)) = 1 ; ((1||1)&&(1||1)) = 1
========== main() returned 0 ==========
========== cecko5 done ==========
// compound operators
int main(int argc, char** argv)
{
int ar, br, cr, dr, er, fr, gr, hr, ir;
{
int ai, bi, ci, di, ei, fi, gi, hi, ii;
ai = 7;
bi = 9;
ci = 11;
di = 13;
ei = 15;
fi = 17;
gi = 19;
hi = 21;
ii = 23;
ar = ++ai;
br = bi++;
cr = --ci;
dr = di--;
er = ei += 5;
fr = fi -= 4;
gr = gi *= 3;
hr = hi /= 2;
ir = ii %= 6;
printf("ai=%d bi=%d ci=%d di=%d ei=%d fi=%d gi=%d hi=%d ii=%d\n", ai, bi, ci, di, ei, fi, gi, hi, ii);
printf("ar=%d br=%d cr=%d dr=%d er=%d fr=%d gr=%d hr=%d ir=%d\n", ar, br, cr, dr, er, fr, gr, hr, ir);
}
{
char ai, bi, ci, di, ei, fi, gi, hi, ii;
ai = 255;
bi = 255;
ci = 0;
di = 0;
ei = 255;
fi = 0;
gi = 200;
hi = 200;
ii = 200;
ar = ++ai;
br = bi++;
cr = --ci;
dr = di--;
er = ei += 5;
fr = fi -= 4;
gr = gi *= 3;
hr = hi /= 2;
ir = ii %= 6;
printf("ai=%d bi=%d ci=%d di=%d ei=%d fi=%d gi=%d hi=%d ii=%d\n", ai, bi, ci, di, ei, fi, gi, hi, ii);
printf("ar=%d br=%d cr=%d dr=%d er=%d fr=%d gr=%d hr=%d ir=%d\n", ar, br, cr, dr, er, fr, gr, hr, ir);
}
{
const char* ai, * bi, * ci, * di, * ei, * fi;
const char* ar, * br, * cr, * dr, * er, * fr;
const char* d;
d = "ABCDEFGHIJ";
ai = d + 4;
bi = d + 4;
ci = d + 4;
di = d + 4;
ei = d + 4;
fi = d + 4;
ar = ++ai;
br = bi++;
cr = --ci;
dr = di--;
er = ei += 5;
fr = fi -= 4;
printf("*ai=%c *bi=%c *ci=%c *di=%c *ei=%c *fi=%c\n", *ai, *bi, *ci, *di, *ei, *fi);
printf("*ar=%c *br=%c *cr=%c *dr=%c *er=%c *fr=%c\n", *ar, *br, *cr, *dr, *er, *fr);
}
return 0;
}
========== tables ==========
// --- GLOBAL TYPEDEFS ---
typedef struct _file_s_0 FILE_0;
// --- FUNCTION DECLARATIONS ---
int main_3(int,char**);
void*memset_0(void*,int,int);
int printf_0(const char*,...);
int scanf_0(const char*,...);
int sprintf_0(char*,const char*,...);
int sscanf_0(const char*,const char*,...);
// --- GLOBAL VARIABLES ---
// --- FUNCTION DEFINITIONS ---
int main_3(int argc_3,char**argv_3){
int ar_5;
int br_5;
int cr_5;
int dr_5;
int er_5;
int fr_5;
int gr_5;
int hr_5;
int ir_5;
{
int ai_7;
int bi_7;
int ci_7;
int di_7;
int ei_7;
int fi_7;
int gi_7;
int hi_7;
int ii_7;
}
{
char ai_33;
char bi_33;
char ci_33;
char di_33;
char ei_33;
char fi_33;
char gi_33;
char hi_33;
char ii_33;
}
{
const char*ai_59;
const char*ar_60;
const char*bi_59;
const char*br_60;
const char*ci_59;
const char*cr_60;
const char*d_61;
const char*di_59;
const char*dr_60;
const char*ei_59;
const char*er_60;
const char*fi_59;
const char*fr_60;
}
}
========== starting main() ==========
ai=8 bi=10 ci=10 di=12 ei=20 fi=13 gi=57 hi=10 ii=5
ar=8 br=9 cr=10 dr=13 er=20 fr=13 gr=57 hr=10 ir=5
ai=0 bi=0 ci=255 di=255 ei=4 fi=252 gi=88 hi=100 ii=2
ar=0 br=255 cr=255 dr=0 er=4 fr=252 gr=88 hr=100 ir=2
*ai=F *bi=F *ci=D *di=D *ei=J *fi=A
*ar=F *br=E *cr=D *dr=E *er=J *fr=A
========== main() returned 0 ==========
========== cecko4 done ==========
// int operations
_Bool b; // false
int to_int(int a)
{
return a;
}
char to_char(char a)
{
return a;
}
const char* to_pointer(const char * a)
{
return a;
}
int char_to_int(char a)
{
return a;
}
char int_to_char(int a)
{
return a;
}
int main(int argc, char** argv)
{
{
char x, y;
int i, j, k;
const char* p;
x = 'X';
k = 0x3F41;
p = "Test"; // array-to-pointer
i = b; // _Bool-to-int
j = x; // char-to-int
y = k; // int-to-char
printf("to_int(x)=0x%x k=0x%x i=%d j=0x%x to_int(y)=0x%x\n", to_int(x), k, i, j, to_int(y));
printf("x='%c' k=%d p=\"%s\" i=%d j=%d y='%c'\n", x, k, p, i, j, y);
}
{
char x, y;
int i, j, k;
const char* p;
x = to_char('X');
k = to_int(0x3F41);
p = to_pointer("Test"); // array-to-pointer
i = to_int(b); // _Bool-to-int
j = char_to_int(x); // char-to-int
y = int_to_char(k); // int-to-char
printf("to_int(x)=0x%x k=0x%x i=%d j=0x%x to_int(y)=0x%x\n", to_int(x), k, i, j, to_int(y));
printf("x='%c' k=%d p=\"%s\" i=%d j=%d y='%c'\n", x, k, p, i, j, y);
}
return 0;
}
========== tables ==========
// --- GLOBAL TYPEDEFS ---
typedef struct _file_s_0 FILE_0;
// --- FUNCTION DECLARATIONS ---
int char_to_int_20(char);
char int_to_char_25(int);
int main_30(int,char**);
void*memset_0(void*,int,int);
int printf_0(const char*,...);
int scanf_0(const char*,...);
int sprintf_0(char*,const char*,...);
int sscanf_0(const char*,const char*,...);
char to_char_10(char);
int to_int_5(int);
const char*to_pointer_15(const char*);
// --- GLOBAL VARIABLES ---
_Bool b_3;
// --- FUNCTION DEFINITIONS ---
int char_to_int_20(char a_20){
}
char int_to_char_25(int a_25){
}
int main_30(int argc_30,char**argv_30){
{
int i_34;
int j_34;
int k_34;
const char*p_35;
char x_33;
char y_33;
}
{
int i_50;
int j_50;
int k_50;
const char*p_51;
char x_49;
char y_49;
}
}
char to_char_10(char a_10){
}
int to_int_5(int a_5){
}
const char*to_pointer_15(const char*a_15){
}
========== starting main() ==========
to_int(x)=0x58 k=0x3f41 i=0 j=0x58 to_int(y)=0x41
x='X' k=16193 p="Test" i=0 j=88 y='A'
to_int(x)=0x58 k=0x3f41 i=0 j=0x58 to_int(y)=0x41
x='X' k=16193 p="Test" i=0 j=88 y='A'
========== main() returned 0 ==========
========== cecko4 done ==========
// int operations
int main(int argc, char** argv)
{
int a, b, c, d, e, f, g, h;
a = 3;
b = 7;
c = a + b;
d = b - a;
e = a * a;
f = b / a;
g = b % a;
h = -b;
printf("a=%d b=%d c=%d d=%d e=%d f=%d g=%d h=%d\n", a, b, c, d, e, f, g, h);
return 0;
}
========== tables ==========
// --- GLOBAL TYPEDEFS ---
typedef struct _file_s_0 FILE_0;
// --- FUNCTION DECLARATIONS ---
int main_3(int,char**);
void*memset_0(void*,int,int);
int printf_0(const char*,...);
int scanf_0(const char*,...);
int sprintf_0(char*,const char*,...);
int sscanf_0(const char*,const char*,...);
// --- GLOBAL VARIABLES ---
// --- FUNCTION DEFINITIONS ---
int main_3(int argc_3,char**argv_3){
int a_5;
int b_5;
int c_5;
int d_5;
int e_5;
int f_5;
int g_5;
int h_5;
}
========== starting main() ==========
a=3 b=7 c=10 d=4 e=9 f=2 g=1 h=-7
========== main() returned 0 ==========
========== cecko4 done ==========
// int operations
_Bool gb; // false
char gx;
int gi;
int* gpi;
int main(int argc, char** argv)
{
char lx;
int li;
_Bool* pgb;
char* pgx, * plx;
int* pgi, * pli;
int** pgpi;
pgb = &gb;
pgx = &gx;
pgi = &gi;
plx = &lx;
pli = &li;
{
int j, k, l, m, n;
j = *pgb;
k = *pgx;
l = *pgi;
*pgx = 'L';
*pgi = 123;
m = gx;
n = gi;
printf("j=%d k=%d l=%d m='%c' n=%d\n", j, k, l, m, n);
}
{
int k, l, m, n;
*plx = 'Z';
*pli = 729;
k = *plx;
l = *pli;
m = lx;
n = li;
printf("k='%c' l=%d m='%c' n=%d\n", k, l, m, n);
}
gpi = pgi;
pgpi = &gpi;
{
int j, k, l, m;
j = **pgpi;
**pgpi = 333;
k = gi;
*pgpi = pli;
l = **pgpi;
**pgpi = 444;
m = li;
printf("j=%d k=%d l=%d m=%d\n", j, k, l, m);
}
return 0;
}
========== tables ==========
// --- GLOBAL TYPEDEFS ---
typedef struct _file_s_0 FILE_0;
// --- FUNCTION DECLARATIONS ---
int main_8(int,char**);
void*memset_0(void*,int,int);
int printf_0(const char*,...);
int scanf_0(const char*,...);
int sprintf_0(char*,const char*,...);
int sscanf_0(const char*,const char*,...);
// --- GLOBAL VARIABLES ---
_Bool gb_3;
int gi_5;
int*gpi_6;
char gx_4;
// --- FUNCTION DEFINITIONS ---
int main_8(int argc_8,char**argv_8){
int li_11;
char lx_10;
_Bool*pgb_13;
int*pgi_15;
int**pgpi_16;
char*pgx_14;
int*pli_15;
char*plx_14;
{
int j_25;
int k_25;
int l_25;
int m_25;
int n_25;
}
{
int k_41;
int l_41;
int m_41;
int n_41;
}
{
int j_59;
int k_59;
int l_59;
int m_59;
}
}
========== starting main() ==========
j=0 k=0 l=0 m='L' n=123
k='Z' l=729 m='Z' n=729
j=123 k=333 l=729 m=444
========== main() returned 0 ==========
========== cecko4 done ==========
// pointer operations
int main(int argc, char** argv)
{
int a, b, f;
a = 3;
b = 5;
{
char g;
const char* pa, * pb, * pc, * pd, * pe, * ph;
const char* p;
p = "ABCDEFGHIJK";
pa = p + 1;
pb = p + 7;
pc = pa + b;
pd = a + pb;
pe = pb - a;
f = pb - pa;
g = pa[a];
ph = &pb[-b];
printf("*pc=%c *pd=%c *pe=%c f=%d g=%c *ph=%c\n", *pc, *pd, *pe, f, g, *ph);
}
{
int g;
int* pa, * pb, * pc, * pd, * pe, * ph;
int arr[11];
arr[2] = 222;
arr[4] = 444;
arr[6] = 666;
arr[8] = 888;
arr[10] = 1010;
pa = arr + 1;
pb = arr + 7;
pc = pa + b;
pd = a + pb;
pe = pb - a;
f = pb - pa;