[gtksourceviewmm/gtksourceviewmm-2.0] Modernize mime types test.



commit a7e5762c9ff87e81969d59e3bbfee840ca04ed5f
Author: Krzesimir Nowak <qdlacz gmail com>
Date:   Sat Nov 13 21:36:51 2010 +0100

    Modernize mime types test.
    
    * tests/mime_types/main.cc: Use vector of strings instead of
    C table of pointers to char.

 tests/mime_types/main.cc |   24 ++++++++++++------------
 1 files changed, 12 insertions(+), 12 deletions(-)
---
diff --git a/tests/mime_types/main.cc b/tests/mime_types/main.cc
index 1ce622e..b472248 100644
--- a/tests/mime_types/main.cc
+++ b/tests/mime_types/main.cc
@@ -1,20 +1,13 @@
 #include <iostream>
+#include <string>
+#include <vector>
 #include <gtkmm.h>
 #include <gtksourceviewmm/sourcelanguagemanager.h>
 #include <gtksourceviewmm/init.h>
-#include <gtksourceview/gtksourcelanguagemanager.h>
 
 using namespace std ;
 using namespace gtksourceview ;
 
-const char * s_mime_types [] = {
-"text/xml",
-"text/html",
-"text/x-c",
-"text/x-c++",
-0
-};
-
 int
 main (int argc, char **argv)
 {
@@ -29,12 +22,19 @@ main (int argc, char **argv)
         return -1 ;
     }
 
+    vector<string> mime_types;
+    mime_types.push_back ("text/xml");
+    mime_types.push_back ("text/html");
+    mime_types.push_back ("text/x-c");
+    mime_types.push_back ("text/x-c++");
+
     Glib::RefPtr<SourceLanguage> lang;
-    for (int i=0 ; s_mime_types[i] ; ++i) {
+    unsigned int size (mime_types.size ());
+    for (unsigned int i=0 ; i < size ; ++i) {
         cout << "Looking for language that matches mime type '"
-             << s_mime_types[i]
+             << mime_types[i]
              << "'" << std::endl;
-        lang = lang_mgr->guess_language(std::string(), s_mime_types[i]);
+        lang = lang_mgr->guess_language(std::string(), mime_types[i]);
         if (lang) {
             cout << "Found language '" << lang->get_name () << "'" << std::endl;
         } else {



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