Minor refactoring of CL_PROGRAM_SOURCE tests (#1032)

Signed-off-by: Stuart Brady <stuart.brady@arm.com>
diff --git a/test_conformance/compiler/test_build_helpers.cpp b/test_conformance/compiler/test_build_helpers.cpp
index 6cfdcf2..c5ebb80 100644
--- a/test_conformance/compiler/test_build_helpers.cpp
+++ b/test_conformance/compiler/test_build_helpers.cpp
@@ -428,7 +428,8 @@
     int error;
     char buffer[10240];
     size_t length;
-
+    size_t line_length = strlen(sample_kernel_code_single_line[0]);
+    bool online_compilation = (gCompilationMode == kOnline);
 
     error = create_single_kernel_helper_create_program(context, &program, 1, sample_kernel_code_single_line);
     if( program == NULL )
@@ -440,7 +441,7 @@
     /* Try getting the length */
     error = clGetProgramInfo( program, CL_PROGRAM_SOURCE, 0, NULL, &length );
     test_error( error, "Unable to get program source length" );
-    if (length != strlen(sample_kernel_code_single_line[0]) + 1 && gCompilationMode == kOnline)
+    if (length != line_length + 1 && online_compilation)
     {
         log_error( "ERROR: Length returned for program source is incorrect!\n" );
         return -1;
@@ -449,7 +450,7 @@
     /* Try normal source */
     error = clGetProgramInfo( program, CL_PROGRAM_SOURCE, sizeof( buffer ), buffer, NULL );
     test_error( error, "Unable to get program source" );
-    if (strlen(buffer) != strlen(sample_kernel_code_single_line[0]) && gCompilationMode == kOnline)
+    if (strlen(buffer) != line_length && online_compilation)
     {
         log_error( "ERROR: Length of program source is incorrect!\n" );
         return -1;
@@ -458,12 +459,12 @@
     /* Try both at once */
     error = clGetProgramInfo( program, CL_PROGRAM_SOURCE, sizeof( buffer ), buffer, &length );
     test_error( error, "Unable to get program source" );
-    if (strlen(buffer) != strlen(sample_kernel_code_single_line[0]) && gCompilationMode == kOnline)
+    if (strlen(buffer) != line_length && online_compilation)
     {
         log_error( "ERROR: Length of program source is incorrect!\n" );
         return -1;
     }
-    if (length != strlen(sample_kernel_code_single_line[0]) + 1 && gCompilationMode == kOnline)
+    if (length != line_length + 1 && online_compilation)
     {
         log_error( "ERROR: Returned length of program source is incorrect!\n" );
         return -1;