Сделан тест для zerror.[h,c] (и пройден)
This commit is contained in:
parent
2ce1fe251e
commit
6dc93548b9
|
@ -16,18 +16,18 @@ long_line_behaviour=1
|
||||||
long_line_column=72
|
long_line_column=72
|
||||||
|
|
||||||
[files]
|
[files]
|
||||||
current_page=10
|
current_page=7
|
||||||
FILE_NAME_0=1032;C;0;16;1;1;1;/home/kolan/dev/c/tex_parser/tex_parser_test.c;0
|
FILE_NAME_0=846;C;0;16;1;1;1;/home/kolan/dev/c/tex_parser/tex_parser_test.c;0
|
||||||
FILE_NAME_1=1320;C;0;16;1;1;1;/home/kolan/dev/c/tex_parser/tex_parser.c;0
|
FILE_NAME_1=284;C;0;16;1;1;1;/home/kolan/dev/c/tex_parser/tex_parser.c;0
|
||||||
FILE_NAME_2=655;C;0;16;1;1;1;/home/kolan/dev/c/tex_parser/tex_parser_tags.h;0
|
FILE_NAME_2=655;C;0;16;1;1;1;/home/kolan/dev/c/tex_parser/tex_parser_tags.h;0
|
||||||
FILE_NAME_3=1871;Make;0;16;1;1;1;/home/kolan/dev/c/tex_parser/Makefile;0
|
FILE_NAME_3=1952;Make;0;16;1;1;1;/home/kolan/dev/c/tex_parser/Makefile;0
|
||||||
FILE_NAME_4=334;C;0;16;1;1;1;/home/kolan/dev/c/tex_parser/tex_parser.h;0
|
FILE_NAME_4=410;C;0;16;1;1;1;/home/kolan/dev/c/tex_parser/tex_parser.h;0
|
||||||
FILE_NAME_5=0;C;0;16;1;1;1;/home/kolan/projects/include/xerror.c;0
|
FILE_NAME_5=1858;C;0;16;1;1;1;/home/kolan/projects/include/xerror.c;0
|
||||||
FILE_NAME_6=1146;C;0;16;1;1;1;/home/kolan/projects/include/xerror.h;0
|
FILE_NAME_6=877;C;0;16;1;1;1;/home/kolan/projects/include/xerror.h;0
|
||||||
FILE_NAME_7=3137;C;0;16;1;1;1;/home/kolan/projects/include/zerror.c;0
|
FILE_NAME_7=1049;C;0;16;1;1;1;/home/kolan/projects/include/zerror.c;0
|
||||||
FILE_NAME_8=1902;C;0;16;1;1;1;/home/kolan/projects/include/zerror.h;0
|
FILE_NAME_8=1912;C;0;16;1;1;1;/home/kolan/projects/include/zerror.h;0
|
||||||
FILE_NAME_9=2406;C;0;16;1;1;1;/home/kolan/projects/include/xalloc.c;0
|
FILE_NAME_9=1649;C;0;16;1;1;1;/home/kolan/projects/include/xalloc.c;0
|
||||||
FILE_NAME_10=3312;C;0;16;1;1;1;/home/kolan/projects/include/xalloc.h;0
|
FILE_NAME_10=4903;C;0;16;1;1;1;/home/kolan/projects/include/xalloc.h;0
|
||||||
|
|
||||||
[build-menu]
|
[build-menu]
|
||||||
NF_00_LB=_Сделать
|
NF_00_LB=_Сделать
|
||||||
|
|
|
@ -0,0 +1,69 @@
|
||||||
|
CC=cc
|
||||||
|
CXX=c++
|
||||||
|
INCLUDE=-I$(HOME)/projects/include
|
||||||
|
KOLAN_PROJECTS=$(HOME)/projects
|
||||||
|
KOLAN_INCLUDE=$(KOLAN_PROJECTS)/include
|
||||||
|
|
||||||
|
# Compiler flags
|
||||||
|
# if mode variable is empty, setting debug build mode
|
||||||
|
ifeq ($(mode),)
|
||||||
|
mode = debug
|
||||||
|
endif
|
||||||
|
ifeq ($(mode),debug)
|
||||||
|
CFLAGS = -O0 -g -std=gnu99 -pedantic -Wextra -Wconversion
|
||||||
|
LDFLAGS =
|
||||||
|
endif
|
||||||
|
ifeq ($(mode),profile)
|
||||||
|
CFLAGS = -O0 -g -p -ftest-coverage -Wcoverage-mismatch
|
||||||
|
LDFLAGS = -g -p
|
||||||
|
endif
|
||||||
|
ifeq ($(mode),develop)
|
||||||
|
CFLAGS += -O2 -g
|
||||||
|
LDFLAGS += -O1
|
||||||
|
endif
|
||||||
|
ifeq ($(mode),release)
|
||||||
|
CFLAGS += -O2
|
||||||
|
LDFLAGS += -O1
|
||||||
|
endif
|
||||||
|
|
||||||
|
CFLAGS += -Wall
|
||||||
|
#~ $(shell pkg-config --cflags liblist)
|
||||||
|
LDFLAGS += -Wall
|
||||||
|
#~ $(shell pkg-config --libs liblist) -lpthread -lexpat
|
||||||
|
|
||||||
|
all: zerror_test
|
||||||
|
|
||||||
|
ifneq ($(mode),debug)
|
||||||
|
ifneq ($(mode),profile)
|
||||||
|
ifneq ($(mode),develop)
|
||||||
|
ifneq ($(mode),release)
|
||||||
|
@echo "Invalid build mode."
|
||||||
|
@echo "Please use 'make mode=release', 'make mode=develop' or 'make mode=debug'"
|
||||||
|
@exit 1
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
@echo ".........................."
|
||||||
|
@echo "Building on "$(mode)" mode "
|
||||||
|
@echo "CFLAGS=$(CFLAGS)"
|
||||||
|
@echo "LDFLAGS=$(LDFLAGS)"
|
||||||
|
@echo ".........................."
|
||||||
|
|
||||||
|
%.o :
|
||||||
|
$(CC) -c $(CFLAGS) $(LDFLAGS) $(INCLUDE) -o $@ $<
|
||||||
|
|
||||||
|
zerror_test_obj = zerror_test.o zerror.o xerror.o
|
||||||
|
zerror_test: $(zerror_test_obj)
|
||||||
|
$(CC) $(CFLAGS) $(LDFLAGS) $(INCLUDE) -o $@ $(zerror_test_obj)
|
||||||
|
|
||||||
|
zerror_test.o: zerror_test.c $(KOLAN_INCLUDE)/zerror.h $(KOLAN_INCLUDE)/xerror.h
|
||||||
|
|
||||||
|
zerror.o: $(KOLAN_INCLUDE)/zerror.c $(KOLAN_INCLUDE)/zerror.h $(KOLAN_INCLUDE)/xerror.h
|
||||||
|
|
||||||
|
xerror.o: $(KOLAN_INCLUDE)/xerror.c $(KOLAN_INCLUDE)/xerror.h
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(RM) *.o *.out callgrind.out.* *.gcno tex_parser_test
|
||||||
|
|
||||||
|
.PHONY: all clean
|
|
@ -0,0 +1,70 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "zerror.h"
|
||||||
|
|
||||||
|
void test0()
|
||||||
|
{
|
||||||
|
struct zerror_s *zs, *zs_l, *zs_cp, *zs_se = NULL, *zs_se_l = NULL, *zs_pe = NULL, *zs_pe2 = NULL;
|
||||||
|
|
||||||
|
zs = zerror_new(-12, -45, "error № %d, %s", -8752, "некая строка");
|
||||||
|
|
||||||
|
printf("zerror_new = {%d, %d, %s}\n", zs->domain, zs->code, zs->message);
|
||||||
|
|
||||||
|
zs_l = zerror_new_literal(-52, -8954, "литерал");
|
||||||
|
|
||||||
|
printf("zerror_new_literal = {%d, %d, %s}\n", zs_l->domain, zs_l->code, zs_l->message);
|
||||||
|
|
||||||
|
zs_cp = zerror_copy(zs_l);
|
||||||
|
|
||||||
|
printf("zerror_copy = {%d, %d, %s}\n", zs_cp->domain, zs_cp->code, zs_cp->message);
|
||||||
|
|
||||||
|
printf("zerror_matches(-52, -8954) = %d\n", zerror_matches(zs_cp, -52, -8954));
|
||||||
|
printf("zerror_matches(-53, -8954) = %d\n", zerror_matches(zs_cp, -53, -8954));
|
||||||
|
printf("zerror_matches(-52, -1954) = %d\n", zerror_matches(zs_cp, -52, -1954));
|
||||||
|
|
||||||
|
/* indicates error in smb's code */
|
||||||
|
z_set_error(&zs, -928, -894, "error was set by z_set_error(%d, %d)", -928, -894);
|
||||||
|
printf("ERRinSMB'sCODE: z_set_error = {%d, %d, %s}\n", zs->domain, zs->code, zs->message);
|
||||||
|
|
||||||
|
z_set_error(&zs_se, -928, -894, "error was set by z_set_error(%d, %d)", -928, -894);
|
||||||
|
printf("z_set_error = {%d, %d, %s}\n", zs_se->domain, zs_se->code, zs_se->message);
|
||||||
|
|
||||||
|
/* indicates error in smb's code */
|
||||||
|
z_set_error_literal(&zs, -928, -894, "error was set by z_set_error_literal()");
|
||||||
|
printf("ERRinSMB'sCODE: z_set_error_literal = {%d, %d, %s}\n", zs->domain, zs->code, zs->message);
|
||||||
|
|
||||||
|
z_set_error_literal(&zs_se_l, -928, -894, "error was set by z_set_error_literal()");
|
||||||
|
printf("z_set_error_literal = {%d, %d, %s}\n", zs_se_l->domain, zs_se_l->code, zs_se_l->message);
|
||||||
|
|
||||||
|
/* indicates error in smb's code */
|
||||||
|
z_propagate_error(&zs, zs_se);
|
||||||
|
printf("ERRinSMB'sCODE: z_propagate_error = {%d, %d, %s}\n", zs->domain, zs->code, zs->message);
|
||||||
|
|
||||||
|
z_propagate_error(&zs_pe, zs_se);
|
||||||
|
printf("z_propagate_error = {%d, %d, %s}\n", zs_pe->domain, zs_pe->code, zs_pe->message);
|
||||||
|
|
||||||
|
z_prefix_error(&zs_pe, "prefix(%s): ", "PREFIX");
|
||||||
|
printf("z_prefix_error = {%d, %d, %s}\n", zs_pe->domain, zs_pe->code, zs_pe->message);
|
||||||
|
|
||||||
|
z_propagate_prefixed_error(&zs_pe2, zs_se_l, "prefix_propagate(%s): ", "propagated");
|
||||||
|
printf("z_propagate_prefixed_error = {%d, %d, %s}\n", zs_pe2->domain, zs_pe2->code, zs_pe2->message);
|
||||||
|
|
||||||
|
zerror_free(zs);
|
||||||
|
zs_l = zerror_free_null(zs_l);
|
||||||
|
zerror_free(zs_cp);
|
||||||
|
//~ z_clear_error(&zs_se_l); // not need clear, because zs_se_l propagated to zs_pe2
|
||||||
|
//~ z_clear_error(&zs_se); // not need clear, because zs_se propagated to zs_pe
|
||||||
|
z_clear_error(&zs_pe);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(/*int argc, char *argv[]*/)
|
||||||
|
{
|
||||||
|
test0();
|
||||||
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
|
@ -0,0 +1,44 @@
|
||||||
|
|
||||||
|
[indentation]
|
||||||
|
indent_width=8
|
||||||
|
indent_type=1
|
||||||
|
indent_hard_tab_width=8
|
||||||
|
detect_indent=false
|
||||||
|
indent_mode=2
|
||||||
|
|
||||||
|
[project]
|
||||||
|
name=zerror_test
|
||||||
|
base_path=/home/kolan/dev/c/zerror_test/
|
||||||
|
description=
|
||||||
|
|
||||||
|
[long line marker]
|
||||||
|
long_line_behaviour=1
|
||||||
|
long_line_column=72
|
||||||
|
|
||||||
|
[files]
|
||||||
|
current_page=0
|
||||||
|
FILE_NAME_0=0;C;0;16;1;1;1;/home/kolan/dev/c/zerror_test/zerror_test.c;0
|
||||||
|
FILE_NAME_1=1300;Make;0;16;1;1;1;/home/kolan/dev/c/zerror_test/Makefile;0
|
||||||
|
FILE_NAME_2=2162;C;0;16;1;1;1;/home/kolan/projects/include/zerror.c;0
|
||||||
|
FILE_NAME_3=0;C;0;16;1;1;1;/home/kolan/projects/include/zerror.h;0
|
||||||
|
|
||||||
|
[build-menu]
|
||||||
|
NF_00_LB=_Сделать
|
||||||
|
NF_00_CM=make
|
||||||
|
NF_00_WD=%p
|
||||||
|
NF_01_LB=Сделать заданную _цель
|
||||||
|
NF_01_CM=make
|
||||||
|
NF_01_WD=%p
|
||||||
|
NF_02_LB=Сделать _объект
|
||||||
|
NF_02_CM=make %e.o
|
||||||
|
NF_02_WD=%p
|
||||||
|
EX_00_LB=_Выполнить
|
||||||
|
EX_00_CM=./%e
|
||||||
|
EX_00_WD=%p
|
||||||
|
CFT_00_LB=_Скомпилировать
|
||||||
|
CFT_00_CM=gcc -Wall -c "%f"
|
||||||
|
CFT_00_WD=%p
|
||||||
|
CFT_01_LB=_Сборка
|
||||||
|
CFT_01_CM=gcc -Wall -o "%e" "%f" -lhash
|
||||||
|
CFT_01_WD=%p
|
||||||
|
filetypes=C;
|
Loading…
Reference in New Issue