]> git.donarmstrong.com Git - lilypond.git/blob - flower/test-file.cc
177676f791577b5ca0c30234d712ef9f9f083060
[lilypond.git] / flower / test-file.cc
1 #define HAVE_BOOST_LAMBDA 1
2 #include "std-vector.hh"
3
4 #include <unistd.h>
5 #include <iostream>
6
7 #include <boost/test/auto_unit_test.hpp>
8 #include <boost/test/floating_point_comparison.hpp>
9
10 using namespace std;
11 using boost::unit_test::test_suite;
12
13 #include "file-name.hh"
14 string slashify (string file_name);
15
16 // FIXME
17 //BOOST_AUTO_UNIT_TEST (mingw_slashify)
18 void mingw_slashify ()
19 {
20   File_name f = string ("foe.ly");
21   string s = slashify (f.to_string ());
22   cout << s << endl;
23   BOOST_CHECK_EQUAL (s, "foe.ly");
24   f = string ("/tmp/x.ly");
25   s = slashify (f.to_string ());
26   cout << s << endl;
27   BOOST_CHECK_EQUAL (s, "/tmp/x.ly");
28   f = string ("c:/tmp/x.ly");
29   s = slashify (f.to_string ());
30   cout << s << endl;
31   BOOST_CHECK_EQUAL (s, "c:/tmp/x.ly");
32   f = string ("\\tmp\\x.ly");
33   s = slashify (f.to_string ());
34   cout << s << endl;
35   BOOST_CHECK_EQUAL (s, "/tmp/x.ly");
36 }
37
38 #include "config.hh"
39 #include "file-path.hh"
40
41 // FIXME
42 //BOOST_AUTO_UNIT_TEST (mingw_slashify)
43 void file_find ()
44 {
45   char const *extensions[] = {"ly", "", 0};
46   string file = "init";
47   File_path path;
48   char cwd[PATH_MAX];
49   getcwd (cwd, PATH_MAX);
50   string ly_dir = string (getenv ("top-src-dir")) + "/ly";
51   cout << ly_dir << endl;
52   path.parse_path (string (1, PATHSEP) + ly_dir);
53   string file_name = path.find (file, extensions);
54   cout << file_name << endl;
55   BOOST_CHECK_EQUAL (file_name.substr (file_name.rfind ('/')), "/init.ly");
56   file = "init.ly";
57   file_name = path.find (file, extensions);
58   cout << file_name << endl;
59   BOOST_CHECK_EQUAL (file_name, ly_dir + "/init.ly");
60   
61 }