Переглянути джерело

* Added error checks on canvas / display creations

tags/v0.99.beta14
Jean-Yves Lamoureux jylam 18 роки тому
джерело
коміт
6b807c1a90
17 змінених файлів з 161 додано та 14 видалено
  1. +12
    -1
      test/blit.c
  2. +9
    -3
      test/colors.c
  3. +6
    -0
      test/cucul.c
  4. +10
    -3
      test/demo.c
  5. +14
    -1
      test/dithering.c
  6. +10
    -3
      test/event.c
  7. +6
    -0
      test/font.c
  8. +6
    -0
      test/frames.c
  9. +10
    -0
      test/fullwidth.c
  10. +10
    -0
      test/gamma.c
  11. +10
    -0
      test/hsv.c
  12. +11
    -0
      test/import.c
  13. +10
    -0
      test/input.c
  14. +11
    -2
      test/swallow.c
  15. +6
    -0
      test/text.c
  16. +10
    -0
      test/transform.c
  17. +10
    -1
      test/unicode.c

+ 12
- 1
test/blit.c Переглянути файл

@@ -43,8 +43,19 @@ int main(int argc, char *argv[])
cucul_canvas_t *cv, *sprite; cucul_canvas_t *cv, *sprite;
caca_display_t *dp; caca_display_t *dp;


cv = cucul_create_canvas(0, 0); cv = cucul_create_canvas(32, 16);
if(cv == NULL)
{
printf("Failed to create canvas\n");
return 1;
}

dp = caca_create_display(cv); dp = caca_create_display(cv);
if(dp == NULL)
{
printf("Failed to create display\n");
return 1;
}


sprite = cucul_create_canvas(0, 0); sprite = cucul_create_canvas(0, 0);
cucul_set_color_ansi(sprite, CUCUL_LIGHTRED, CUCUL_BLACK); cucul_set_color_ansi(sprite, CUCUL_LIGHTRED, CUCUL_BLACK);


+ 9
- 3
test/colors.c Переглянути файл

@@ -28,13 +28,19 @@ int main(int argc, char **argv)
caca_display_t *dp; caca_display_t *dp;
int i, j; int i, j;


cv = cucul_create_canvas(0, 0); cv = cucul_create_canvas(32, 16);
if(!cv) if(cv == NULL)
{
printf("Failed to create canvas\n");
return 1; return 1;
}


dp = caca_create_display(cv); dp = caca_create_display(cv);
if(!dp) if(dp == NULL)
{
printf("Failed to create display\n");
return 1; return 1;
}


cucul_set_color_ansi(cv, CUCUL_LIGHTGRAY, CUCUL_BLACK); cucul_set_color_ansi(cv, CUCUL_LIGHTGRAY, CUCUL_BLACK);
cucul_clear_canvas(cv); cucul_clear_canvas(cv);


+ 6
- 0
test/cucul.c Переглянути файл

@@ -44,6 +44,12 @@ int main(int argc, char *argv[])


fprintf(stderr, "testing cucul_set_frame_name()\n"); fprintf(stderr, "testing cucul_set_frame_name()\n");
cv = cucul_create_canvas(1, 1); cv = cucul_create_canvas(1, 1);
if(cv == NULL)
{
printf("Failed to create canvas\n");
return 1;
}

for(i = 0; i < ITER; i++) for(i = 0; i < ITER; i++)
{ {
cucul_create_frame(cv, 0); cucul_create_frame(cv, 0);


+ 10
- 3
test/demo.c Переглянути файл

@@ -48,12 +48,19 @@ int main(int argc, char **argv)
void (*demo)(void) = NULL; void (*demo)(void) = NULL;
int quit = 0; int quit = 0;


cv = cucul_create_canvas(0, 0); cv = cucul_create_canvas(32, 16);
if(!cv) if(cv == NULL)
{
printf("Failed to create canvas\n");
return 1; return 1;
}

dp = caca_create_display(cv); dp = caca_create_display(cv);
if(!dp) if(dp == NULL)
{
printf("Failed to create display\n");
return 1; return 1;
}


caca_set_display_time(dp, 40000); caca_set_display_time(dp, 40000);




+ 14
- 1
test/dithering.c Переглянути файл

@@ -41,8 +41,21 @@ int main(int argc, char *argv[])
int neara, dista, nearb, distb, dist; int neara, dista, nearb, distb, dist;
int x, y; int x, y;


cv = cucul_create_canvas(0, 0); cv = cucul_create_canvas(32, 16);
if(cv == NULL)
{
printf("Failed to create canvas\n");
return 1;
}

dp = caca_create_display(cv); dp = caca_create_display(cv);
if(dp == NULL)
{
printf("Failed to create display\n");
return 1;
}




for(x = 0; x < 100; x++) for(x = 0; x < 100; x++)
for(y = 0; y < 100; y++) for(y = 0; y < 100; y++)


+ 10
- 3
test/event.c Переглянути файл

@@ -33,12 +33,19 @@ int main(int argc, char **argv)
caca_event_t *events; caca_event_t *events;
int i, h, quit; int i, h, quit;


cv = cucul_create_canvas(0, 0); cv = cucul_create_canvas(32, 16);
if(!cv) if(cv == NULL)
{
printf("Failed to create canvas\n");
return 1; return 1;
}

dp = caca_create_display(cv); dp = caca_create_display(cv);
if(!dp) if(dp == NULL)
{
printf("Failed to create display\n");
return 1; return 1;
}


h = cucul_get_canvas_height(cv) - 1; h = cucul_get_canvas_height(cv) - 1;




+ 6
- 0
test/font.c Переглянути файл

@@ -44,6 +44,12 @@ int main(int argc, char *argv[])


/* Create a canvas */ /* Create a canvas */
cv = cucul_create_canvas(8, 2); cv = cucul_create_canvas(8, 2);
if(cv == NULL)
{
printf("Can't create canvas\n");
return -1;
}



/* Draw stuff on our canvas */ /* Draw stuff on our canvas */
cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLACK); cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLACK);


+ 6
- 0
test/frames.c Переглянути файл

@@ -33,6 +33,12 @@ int main(int argc, char *argv[])


/* Create a canvas with 200 frames */ /* Create a canvas with 200 frames */
cv = cucul_create_canvas(0, 0); cv = cucul_create_canvas(0, 0);
if(cv == NULL)
{
printf("Can't create canvas\n");
return -1;
}

for(frame = 1; frame < 200; frame++) for(frame = 1; frame < 200; frame++)
cucul_create_frame(cv, frame); cucul_create_frame(cv, frame);




+ 10
- 0
test/fullwidth.c Переглянути файл

@@ -35,7 +35,17 @@ int main(int argc, char *argv[])
unsigned int i; unsigned int i;


cv = cucul_create_canvas(0, 0); cv = cucul_create_canvas(0, 0);
if(cv == NULL)
{
printf("Can't created canvas\n");
return -1;
}
dp = caca_create_display(cv); dp = caca_create_display(cv);
if(dp == NULL)
{
printf("Can't create display\n");
return -1;
}


caca = cucul_create_canvas(6, 10); caca = cucul_create_canvas(6, 10);
line = cucul_create_canvas(2, 1); line = cucul_create_canvas(2, 1);


+ 10
- 0
test/gamma.c Переглянути файл

@@ -38,7 +38,17 @@ int main(int argc, char *argv[])
int x; int x;


cv = cucul_create_canvas(0, 0); cv = cucul_create_canvas(0, 0);
if(cv == NULL)
{
printf("Can't created canvas\n");
return -1;
}
dp = caca_create_display(cv); dp = caca_create_display(cv);
if(dp == NULL)
{
printf("Can't create display\n");
return -1;
}


cw = cucul_create_canvas(cucul_get_canvas_width(cv), cucul_get_canvas_height(cv)); cw = cucul_create_canvas(cucul_get_canvas_width(cv), cucul_get_canvas_height(cv));
mask = cucul_create_canvas(cucul_get_canvas_width(cv), cucul_get_canvas_height(cv)); mask = cucul_create_canvas(cucul_get_canvas_width(cv), cucul_get_canvas_height(cv));


+ 10
- 0
test/hsv.c Переглянути файл

@@ -36,7 +36,17 @@ int main(int argc, char *argv[])
int x, y; int x, y;


cv = cucul_create_canvas(0, 0); cv = cucul_create_canvas(0, 0);
if(cv == NULL)
{
printf("Can't created canvas\n");
return -1;
}
dp = caca_create_display(cv); dp = caca_create_display(cv);
if(dp == NULL)
{
printf("Can't create display\n");
return -1;
}


for(y = 0; y < 256; y++) for(y = 0; y < 256; y++)
for(x = 0; x < 256; x++) for(x = 0; x < 256; x++)


+ 11
- 0
test/import.c Переглянути файл

@@ -41,6 +41,12 @@ int main(int argc, char *argv[])
} }


cv = cucul_create_canvas(0, 0); cv = cucul_create_canvas(0, 0);
if(cv == NULL)
{
printf("Can't create canvas\n");
return -1;
}

if(cucul_import_file(cv, argv[1], argc >= 3 ? argv[2] : "") < 0) if(cucul_import_file(cv, argv[1], argc >= 3 ? argv[2] : "") < 0)
{ {
fprintf(stderr, "%s: could not open `%s'.\n", argv[0], argv[1]); fprintf(stderr, "%s: could not open `%s'.\n", argv[0], argv[1]);
@@ -49,6 +55,11 @@ int main(int argc, char *argv[])
} }


dp = caca_create_display(cv); dp = caca_create_display(cv);
if(dp == NULL)
{
printf("Can't create display\n");
return -1;
}


caca_refresh_display(dp); caca_refresh_display(dp);




+ 10
- 0
test/input.c Переглянути файл

@@ -42,7 +42,17 @@ int main(int argc, char *argv[])
unsigned int i, e = 0, running = 1; unsigned int i, e = 0, running = 1;


cv = cucul_create_canvas(0, 0); cv = cucul_create_canvas(0, 0);
if(cv == NULL)
{
printf("Can't created canvas\n");
return -1;
}
dp = caca_create_display(cv); dp = caca_create_display(cv);
if(dp == NULL)
{
printf("Can't create display\n");
return -1;
}


cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE); cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE);
cucul_put_str(cv, 1, 1, "Text entries - press tab to cycle"); cucul_put_str(cv, 1, 1, "Text entries - press tab to cycle");


+ 11
- 2
test/swallow.c Переглянути файл

@@ -42,8 +42,17 @@ int main(int argc, char **argv)
cv = cucul_create_canvas(0, 0); cv = cucul_create_canvas(0, 0);
app = cucul_create_canvas(0, 0); app = cucul_create_canvas(0, 0);
dp = caca_create_display(cv); dp = caca_create_display(cv);
if(!dp) if(cv == NULL || app == NULL )
return 1; {
printf("Can't created canvas\n");
return -1;
}
if(dp == NULL)
{
printf("Can't create display\n");
return -1;
}


w = (cucul_get_canvas_width(cv) - 4) / 2; w = (cucul_get_canvas_width(cv) - 4) / 2;
h = (cucul_get_canvas_height(cv) - 6) / 2; h = (cucul_get_canvas_height(cv) - 6) / 2;


+ 6
- 0
test/text.c Переглянути файл

@@ -44,6 +44,12 @@ int main(int argc, char *argv[])
cv = cucul_create_canvas(cucul_get_canvas_width(pig) * 2, cv = cucul_create_canvas(cucul_get_canvas_width(pig) * 2,
cucul_get_canvas_height(pig) * 2); cucul_get_canvas_height(pig) * 2);


if(cv == NULL || pig == NULL)
{
printf("Can't created canvas\n");
return -1;
}

cucul_blit(cv, 0, 0, pig, NULL); cucul_blit(cv, 0, 0, pig, NULL);
cucul_flip(pig); cucul_flip(pig);
cucul_blit(cv, cucul_get_canvas_width(pig), 0, pig, NULL); cucul_blit(cv, cucul_get_canvas_width(pig), 0, pig, NULL);


+ 10
- 0
test/transform.c Переглянути файл

@@ -46,7 +46,17 @@ int main(int argc, char *argv[])
caca_display_t *dp; caca_display_t *dp;


cv = cucul_create_canvas(0, 0); cv = cucul_create_canvas(0, 0);
if(cv == NULL)
{
printf("Can't created canvas\n");
return -1;
}
dp = caca_create_display(cv); dp = caca_create_display(cv);
if(dp == NULL)
{
printf("Can't create display\n");
return -1;
}


image = cucul_create_canvas(70, 6); image = cucul_create_canvas(70, 6);
tmp = cucul_create_canvas(70, 6); tmp = cucul_create_canvas(70, 6);


+ 10
- 1
test/unicode.c Переглянути файл

@@ -31,8 +31,17 @@ int main(int argc, char *argv[])
caca_display_t *dp; caca_display_t *dp;


cv = cucul_create_canvas(0, 0); cv = cucul_create_canvas(0, 0);
if(cv == NULL)
{
printf("Can't created canvas\n");
return -1;
}
dp = caca_create_display(cv); dp = caca_create_display(cv);

if(dp == NULL)
{
printf("Can't create display\n");
return -1;
}
cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE); cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE);
cucul_put_str(cv, 1, 1, "Basic Unicode support"); cucul_put_str(cv, 1, 1, "Basic Unicode support");




||||||
x
 
000:0
Завантаження…
Відмінити
Зберегти