From d813e2d8d5ced94b7cc1ae15388228a5ef244769 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Mon, 26 May 2014 17:08:30 +0200 Subject: Split out method naming to its own function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- test/test.c | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/test/test.c b/test/test.c index 4b499b3..65a65b6 100644 --- a/test/test.c +++ b/test/test.c @@ -21,6 +21,25 @@ #include +static const char* method_name(int method) +{ + switch (method) + { + case GAMMA_METHOD_DUMMY: return "dummy"; + case GAMMA_METHOD_X_RANDR: return "RandR X extension"; + case GAMMA_METHOD_X_VIDMODE: return "VidMode X extension"; + case GAMMA_METHOD_LINUX_DRM: return "Linux DRM"; + case GAMMA_METHOD_W32_GDI: return "Windows GDI"; + case GAMMA_METHOD_QUARTZ_CORE_GRAPHICS: return "Quartz using Core Graphics"; + default: +#if GAMMA_METHOD_COUNT != 6 +# warning List of adjustment methods is out of date +#endif + return "(unknown)"; + } +} + + int main(void) { int* methods = malloc(GAMMA_METHOD_COUNT * sizeof(int)); @@ -35,21 +54,7 @@ int main(void) } for (i = 0; i < n; i++) - switch (methods[i]) - { - case GAMMA_METHOD_DUMMY: printf("dummy\n"); break; - case GAMMA_METHOD_X_RANDR: printf("RandR X extension\n"); break; - case GAMMA_METHOD_X_VIDMODE: printf("VidMode X extension\n"); break; - case GAMMA_METHOD_LINUX_DRM: printf("Linux DRM\n"); break; - case GAMMA_METHOD_W32_GDI: printf("Windows GDI\n"); break; - case GAMMA_METHOD_QUARTZ_CORE_GRAPHICS: printf("Quartz using Core Graphics\n"); break; - default: -#if GAMMA_METHOD_COUNT != 6 -# warning List of adjustment methods is out of date -#endif - printf("(unknown)\n"); - break; - } + printf("%s\n", method_name(methods[i])); return 0; } -- cgit v1.2.3-70-g09d2