[gnome-commander/CppUnit] Automate fileops test



commit 2c19931c7ef58a55ece97749c53de36069fb679a
Author: Uwe Scholz <uwescholz src gnome org>
Date:   Sun Oct 4 21:54:20 2015 +0200

    Automate fileops test

 tests/intviewer/fileops.cc |   55 ++++++++++++++++----------------------------
 1 files changed, 20 insertions(+), 35 deletions(-)
---
diff --git a/tests/intviewer/fileops.cc b/tests/intviewer/fileops.cc
index c125594..0ae6685 100644
--- a/tests/intviewer/fileops.cc
+++ b/tests/intviewer/fileops.cc
@@ -2,7 +2,7 @@
   GNOME Commander - A GNOME based file manager
   Copyright (C) 2001-2006 Marcus Bjurman
   Copyright (C) 2007-2012 Piotr Eljasiak
-    Copyright (C) 2013-2015 Uwe Scholz
+  Copyright (C) 2013-2015 Uwe Scholz
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -17,8 +17,6 @@
   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
-
-   Author: Assaf Gordon  <agordon88 gmail com>
 */
 
 #include <glib.h>
@@ -28,51 +26,38 @@
 #include <intviewer/gvtypes.h>
 #include <intviewer/fileops.h>
 
-void usage()
-{
-    fprintf(stderr,"This program tests the file operations module in 'libgviewer'.\n\n");
-
-    fprintf(stderr,"Usage: test-fileops filename [start_offset] [end_offset]\n");
-    fprintf(stderr,"\t'filename' will be printed to STDOUT.\n");
-    fprintf(stderr,"\t'start_offset' and 'end_offset' are optimal.\n\n");
-    exit(0);
-}
-
 int main(int argc, char *argv[])
 {
     ViewerFileOps *fops;
     offset_type start = 0;
     offset_type end = 0;
     offset_type current;
-    int value;
-
-    if (argc<=1)
-        usage();
+    int result = 0;
 
     fops = gv_fileops_new();
 
-    if (gv_file_open(fops, argv[1])==-1) {
-        fprintf(stderr,"Failed to open \"%s\"\n", argv[1]);
-        goto error;
-    }
-
-    start = argc>=3 ? atol(argv[2]) : 0;
-
-    end = argc>=4 ? atol(argv[3]) : gv_file_get_max_offset(fops);
+    if (gv_file_open(fops, "../../INSTALL") == -1)
+        result = 1;
 
-
-    for (current = start; current < end; current++)
+    if (!result)
     {
-        value = gv_file_get_byte(fops, current);
-
-        if (value==-1)
-            break;
-
-        printf("%c",(unsigned char)value);
+        int value;
+        start = 0;
+        end = gv_file_get_max_offset(fops);
+
+        for (current = start; current < end; current++)
+        {
+            value = gv_file_get_byte(fops, current);
+
+            if (value == -1)
+            {
+                result = value;
+                break;
+            }
+        }
     }
 
-error:
     gv_file_free(fops);
     g_free(fops);
-    return 0;
+    return result;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]