]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-0.0.40
authorfred <fred>
Sat, 8 Mar 1997 19:29:07 +0000 (19:29 +0000)
committerfred <fred>
Sat, 8 Mar 1997 19:29:07 +0000 (19:29 +0000)
flower/lib/include/string-convert.hh
flower/test/stringtest.cc [new file with mode: 0644]

index bcf461f8f3f6a32c734f49716d6bef0ecbfd0666..f6bcfa7faeea590baf744a7e3256be16f59d8879 100644 (file)
@@ -30,14 +30,16 @@ public:
     static int dec2_i( String dec_str );
     static double dec2_f( String dec_str );
     static String double_str(double f, char const* fmt=0);
-    static int hex2int_i( String str );
+    static int hex2_i( String str );
+    static unsigned hex2_u( String str );
     static String hex2bin_str( String str );
     static String int_str(int i, char const *fmt=0  );
     static String i2hex_str( int i, int length_i, char ch );
+    static String u2hex_str( unsigned u, int length_i, char ch );
     static String i2dec_str( int i, int length_i, char ch );
     static String rational_str(Rational);
     static String pointer_str(const void *);
-    static String longlong_str(long long , char const * fmt = 0);
+    static String i64_str(I64, char const * fmt = 0);
 };
 
 #endif // __STRING_CONVERT_HH //
diff --git a/flower/test/stringtest.cc b/flower/test/stringtest.cc
new file mode 100644 (file)
index 0000000..5b4ace1
--- /dev/null
@@ -0,0 +1,130 @@
+#ifdef STRING_TEST
+/*
+  stupid test program to verify stringlib
+  stringtest.cc
+  */
+#include <iostream.h>
+#include "string.hh"
+#include "varray.hh"
+#include "string-convert.hh"
+
+void
+ctors()
+{
+    cout << "constructors"<<endl;
+
+    String str( "hai" );
+    String def;
+    String fromi(10);
+    String fromc('c');
+    String fromf(1.32e-2, "%g");
+
+    cout << str << endl;
+    cout << def << endl;
+    cout << fromi<< endl;
+    cout << fromc<< endl;       
+    cout << fromf<< endl;
+}
+
+void
+cmp()
+{
+    Array<String> a;
+    a.push("abcd");
+    a.push("zxy");
+    a.push("abc");
+    a.push("");
+    a.sort(String::compare_i);
+    cout << "compares: "<<endl;
+    for (int i=0; i < a.size(); i++)
+       cout << a[i] << endl;
+}
+
+
+void
+searching()
+{
+    String hay = "foobarbazblub";
+
+    char c =   'b';
+    String cstr =c;
+    String set = "bar";
+    cout << "hay = \"" << hay << "\" len="<< hay.length_i()<<endl;
+    cout << "index_i('"<< c<<"') " << c << "= " << hay.index_i(c) <<endl;
+    cout << "last_index_i('"<< c<<"') " << c << "= " << hay.index_last_i(c) <<endl;    
+//    cout << "last index of cstr " << c << ": " << hay.index_last_i(cstr) <<endl;    
+//    cout << "index_last_i(\""<<set<<"\"): " << hay.index_last_i(set) <<endl;
+    cout << "index_i(\""<<set<<"\"): " << hay.index_i(set) <<endl;    
+    cout << "index_any(\"" << set << "\"): " << cstr << ": " << hay.index_any_i(cstr) <<endl;
+
+    
+    
+}
+
+
+void
+kutenpeer()
+{
+    String str( "hai" );
+    for (int i=-1; i < str.length_i()+2; i++) {
+       cout<<" left_str(" << i<<"): " << str.left_str( i ) << endl;
+       cout<<" right_str( "<<i<<"): " << str.right_str( i ) << endl;
+    }
+    str = "blonde haren";
+    cout << str<<endl;
+    cout << "mid(2,6)="<<str.mid_str(2,3)<<endl;
+    cout << "nomid(2,6)="<<str.nomid_str(2,3)<<endl;
+}
+
+bool
+test_empty_bo( String str )
+{
+    cout << "`" << str << "' is ";
+
+    if ( str == String( "" ) ) {
+        cout << "empty" << endl;
+       return true;
+    }
+
+    cout << "not empty" << endl;
+    return false;
+}
+
+int 
+main()
+{
+    ctors();
+    cmp();
+    searching();
+    kutenpeer();
+    String str( "hai" );
+    cout <<  str << endl;
+    cout << "left" << endl;
+    str += " daar";
+    cout << str << endl;
+
+    str = String( "Hallo" ) + " daaR" + '!';
+    cout << str << endl;
+
+    cout << "up: " << str.upper_str() << " down: " << str.lower_str()<<endl;
+    
+    if ( test_empty_bo( str ) )
+       return 1;
+    
+    String fn = "";
+    if ( !test_empty_bo( fn ) )
+       return 1;
+    
+    fn = "";
+    fn += "";
+    delete fn.copy_byte_p();
+    delete str.copy_byte_p();
+
+    cout << String_convert::bin2hex_str( String( (char)0xff ) ) << endl;
+    cout << "-1:" << String_convert::i2hex_str( -1, 2, '0' );
+    cout << endl;
+    return 0;
+}
+
+#endif STRING_TEST
+