diff options
author | Carl Worth <cworth@cworth.org> | 2006-12-14 03:15:14 -0800 |
---|---|---|
committer | Carl Worth <cworth@cworth.org> | 2006-12-14 07:58:01 -0800 |
commit | 2174ee247554feef6a24792390d858b12fd44acd (patch) | |
tree | 8208b65a9ee7d361ea269752996763278f697948 /test/pdiff | |
parent | 91b156b82e0219b2b851c218813f24024cad7c69 (diff) | |
download | cairo-2174ee247554feef6a24792390d858b12fd44acd.tar.gz |
pdiff: Remove all uses of std::string
Diffstat (limited to 'test/pdiff')
-rw-r--r-- | test/pdiff/CompareArgs.cpp | 18 | ||||
-rw-r--r-- | test/pdiff/CompareArgs.h | 1 | ||||
-rw-r--r-- | test/pdiff/PerceptualDiff.cpp | 24 |
3 files changed, 14 insertions, 29 deletions
diff --git a/test/pdiff/CompareArgs.cpp b/test/pdiff/CompareArgs.cpp index 265cfed79..f33ba9feb 100644 --- a/test/pdiff/CompareArgs.cpp +++ b/test/pdiff/CompareArgs.cpp @@ -57,8 +57,8 @@ CompareArgs::~CompareArgs() bool CompareArgs::Parse_Args(int argc, char **argv) { if (argc < 3) { - ErrorStr = copyright; - ErrorStr += usage; + fprintf (stderr, "%s", copyright); + fprintf (stderr, "%s", usage); return false; } for (int i = 0; i < argc; i++) { @@ -66,22 +66,16 @@ bool CompareArgs::Parse_Args(int argc, char **argv) surface_a = cairo_image_surface_create_from_png (argv[1]); if (cairo_surface_status (surface_a)) { - ErrorStr = "FAIL: Cannot open "; - ErrorStr += argv[1]; - ErrorStr += " "; - ErrorStr += cairo_status_to_string (cairo_surface_status (surface_a)); - ErrorStr += "\n"; + fprintf (stderr, "FAIL: Cannot open %s: %s\n", + argv[1], cairo_status_to_string (cairo_surface_status (surface_a))); return false; } } else if (i == 2) { surface_b = cairo_image_surface_create_from_png (argv[2]); if (cairo_surface_status (surface_b)) { - ErrorStr = "FAIL: Cannot open "; - ErrorStr += argv[2]; - ErrorStr += " "; - ErrorStr += cairo_status_to_string (cairo_surface_status (surface_b)); - ErrorStr += "\n"; + fprintf (stderr, "FAIL: Cannot open %s: %s\n", + argv[2], cairo_status_to_string (cairo_surface_status (surface_b))); return false; } } else { diff --git a/test/pdiff/CompareArgs.h b/test/pdiff/CompareArgs.h index ac368d547..31cf05915 100644 --- a/test/pdiff/CompareArgs.h +++ b/test/pdiff/CompareArgs.h @@ -36,7 +36,6 @@ public: float Gamma; /* The gamma to convert to linear color space */ float Luminance; /* the display's luminance */ unsigned int ThresholdPixels; /* How many pixels different to ignore */ - std::string ErrorStr; /* Error string */ }; #endif diff --git a/test/pdiff/PerceptualDiff.cpp b/test/pdiff/PerceptualDiff.cpp index 45ab7cb9a..04b9e45ee 100644 --- a/test/pdiff/PerceptualDiff.cpp +++ b/test/pdiff/PerceptualDiff.cpp @@ -32,6 +32,8 @@ static bool Yee_Compare(CompareArgs &args) int width_b, height_b, stride_b; unsigned char *data_b, *row_b; uint32_t *pixel_b; + unsigned int x, y, dim, pixels_failed; + bool identical = true; width_a = cairo_image_surface_get_width (args.surface_a); height_a = cairo_image_surface_get_height (args.surface_a); @@ -44,12 +46,11 @@ static bool Yee_Compare(CompareArgs &args) data_b = cairo_image_surface_get_data (args.surface_b); if ((width_a != width_b) || (height_a != height_b)) { - args.ErrorStr = "Image dimensions do not match\n"; + printf ("FAIL: Image dimensions do not match\n"); return false; } - unsigned int x, y, dim, pixels_failed; - bool identical = true; + identical = true; for (y = 0; y < height_a; y++) { row_a = data_a + y * stride_a; @@ -65,7 +66,7 @@ static bool Yee_Compare(CompareArgs &args) } } if (identical) { - args.ErrorStr = "Images are binary identical\n"; + printf ("PASS: Images are binary identical\n"); return true; } @@ -74,15 +75,12 @@ static bool Yee_Compare(CompareArgs &args) args.FieldOfView); if (pixels_failed < args.ThresholdPixels) { - args.ErrorStr = "Images are perceptually indistinguishable\n"; + printf ("PASS: Images are perceptually indistinguishable\n"); return true; } - char different[100]; - sprintf(different, "%d pixels are different\n", pixels_failed); - - args.ErrorStr = "Images are visibly different\n"; - args.ErrorStr += different; + printf("FAIL: Images are visibly different\n" + "%d pixels are different\n", pixels_failed); return false; } @@ -92,16 +90,10 @@ int main(int argc, char **argv) CompareArgs args; if (!args.Parse_Args(argc, argv)) { - printf("%s", args.ErrorStr.c_str()); return -1; } else { if (args.Verbose) args.Print_Args(); } int result = Yee_Compare(args) == true; - if (result) { - printf("PASS: %s\n", args.ErrorStr.c_str()); - } else { - printf("FAIL: %s\n", args.ErrorStr.c_str()); - } return result; } |