Browse Source

* Added error checks on canvas / display creations

tags/v0.99.beta14
Jean-Yves Lamoureux jylam 18 years ago
parent
commit
6b807c1a90
17 changed files with 161 additions and 14 deletions
  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 View File

@@ -43,8 +43,19 @@ int main(int argc, char *argv[])
cucul_canvas_t *cv, *sprite;
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);
if(dp == NULL)
{
printf("Failed to create display\n");
return 1;
}

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


+ 9
- 3
test/colors.c View File

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

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

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

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


+ 6
- 0
test/cucul.c View File

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

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

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


+ 10
- 3
test/demo.c View File

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

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

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

caca_set_display_time(dp, 40000);



+ 14
- 1
test/dithering.c View File

@@ -41,8 +41,21 @@ int main(int argc, char *argv[])
int neara, dista, nearb, distb, dist;
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);
if(dp == NULL)
{
printf("Failed to create display\n");
return 1;
}



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


+ 10
- 3
test/event.c View File

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

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

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

h = cucul_get_canvas_height(cv) - 1;



+ 6
- 0
test/font.c View File

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

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


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


+ 6
- 0
test/frames.c View File

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

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

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



+ 10
- 0
test/fullwidth.c View File

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

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

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


+ 10
- 0
test/gamma.c View File

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

cv = cucul_create_canvas(0, 0);
if(cv == NULL)
{
printf("Can't created canvas\n");
return -1;
}
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));
mask = cucul_create_canvas(cucul_get_canvas_width(cv), cucul_get_canvas_height(cv));


+ 10
- 0
test/hsv.c View File

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

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

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


+ 11
- 0
test/import.c View File

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

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)
{
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);
if(dp == NULL)
{
printf("Can't create display\n");
return -1;
}

caca_refresh_display(dp);



+ 10
- 0
test/input.c View File

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

cv = cucul_create_canvas(0, 0);
if(cv == NULL)
{
printf("Can't created canvas\n");
return -1;
}
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_put_str(cv, 1, 1, "Text entries - press tab to cycle");


+ 11
- 2
test/swallow.c View File

@@ -42,8 +42,17 @@ int main(int argc, char **argv)
cv = cucul_create_canvas(0, 0);
app = cucul_create_canvas(0, 0);
dp = caca_create_display(cv);
if(!dp)
return 1;

if(cv == NULL || app == NULL )
{
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;
h = (cucul_get_canvas_height(cv) - 6) / 2;


+ 6
- 0
test/text.c View File

@@ -44,6 +44,12 @@ int main(int argc, char *argv[])
cv = cucul_create_canvas(cucul_get_canvas_width(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_flip(pig);
cucul_blit(cv, cucul_get_canvas_width(pig), 0, pig, NULL);


+ 10
- 0
test/transform.c View File

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

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

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


+ 10
- 1
test/unicode.c View File

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

cv = cucul_create_canvas(0, 0);
if(cv == NULL)
{
printf("Can't created canvas\n");
return -1;
}
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_put_str(cv, 1, 1, "Basic Unicode support");



Loading…
Cancel
Save