mirror of https://github.com/KLayout/klayout.git
Issue 723 fixed. (#724)
* Fixed a segfault with simple 'klayout -v' * Fixed #723
This commit is contained in:
parent
e31d7afb64
commit
d8c0ea806a
|
|
@ -287,7 +287,11 @@ std::string dirname (const std::string &s)
|
|||
parts.pop_back ();
|
||||
}
|
||||
|
||||
return tl::join (parts, "");
|
||||
if (parts.empty ()) {
|
||||
return is_part_with_separator (s) ? "" : ".";
|
||||
} else {
|
||||
return tl::join (parts, "");
|
||||
}
|
||||
}
|
||||
|
||||
std::string filename (const std::string &s)
|
||||
|
|
|
|||
|
|
@ -351,6 +351,9 @@ TEST (10)
|
|||
EXPECT_EQ (tl::normalize_path ("d:/"), "D:\\");
|
||||
EXPECT_EQ (tl::normalize_path ("d://"), "D:\\");
|
||||
|
||||
EXPECT_EQ (tl::dirname ("hello"), ".");
|
||||
EXPECT_EQ (tl::dirname (".\\hello"), ".");
|
||||
EXPECT_EQ (tl::dirname ("/hello"), "");
|
||||
EXPECT_EQ (tl::dirname ("/hello/world"), "\\hello");
|
||||
EXPECT_EQ (tl::dirname ("\\hello\\world"), "\\hello");
|
||||
EXPECT_EQ (tl::dirname ("/hello//world/"), "\\hello\\world");
|
||||
|
|
@ -406,6 +409,33 @@ TEST (10)
|
|||
EXPECT_EQ (tl::combine_path ("hello", "world"), "hello\\world");
|
||||
EXPECT_EQ (tl::combine_path ("hello", ""), "hello");
|
||||
EXPECT_EQ (tl::combine_path ("hello", "", true), "hello\\");
|
||||
EXPECT_EQ (tl::combine_path ("", "hello", true), "\\hello");
|
||||
EXPECT_EQ (tl::combine_path (".", "hello", true), ".\\hello");
|
||||
|
||||
EXPECT_EQ (tl::combine_path (tl::dirname ("hello"), tl::filename ("hello")), ".\\hello");
|
||||
EXPECT_EQ (tl::combine_path (tl::dirname ("\\hello"), tl::filename ("\\hello")), "\\hello");
|
||||
EXPECT_EQ (tl::combine_path (tl::dirname ("c:\\hello"), tl::filename ("c:\\hello")), "C:\\hello");
|
||||
EXPECT_EQ (tl::combine_path (tl::dirname ("\\c:\\hello"), tl::filename ("\\c:\\hello")), "C:\\hello");
|
||||
EXPECT_EQ (tl::combine_path (tl::dirname ("\\\\hello"), tl::filename ("\\\\hello")), "\\hello");
|
||||
EXPECT_EQ (tl::combine_path (tl::dirname ("\\\\server:\\hello"), tl::filename ("\\\\server:\\hello")), "\\\\server:\\hello");
|
||||
EXPECT_EQ (tl::combine_path (tl::dirname ("\\hello\\x"), tl::filename ("\\hello\\x")), "\\hello\\x");
|
||||
EXPECT_EQ (tl::combine_path (tl::dirname ("c:\\hello\\x"), tl::filename ("c:\\hello\\x")), "C:\\hello\\x");
|
||||
EXPECT_EQ (tl::combine_path (tl::dirname ("\\c:\\hello\\x"), tl::filename ("\\c:\\hello\\x")), "C:\\hello\\x");
|
||||
EXPECT_EQ (tl::combine_path (tl::dirname ("\\\\hello\\x"), tl::filename ("\\\\hello\\x")), "\\\\hello\\x");
|
||||
EXPECT_EQ (tl::combine_path (tl::dirname ("\\hello\\x\\y"), tl::filename ("\\hello\\x\\y")), "\\hello\\x\\y");
|
||||
|
||||
EXPECT_EQ (tl::combine_path (tl::dirname ("hello/x"), tl::filename ("hello/x")), "hello\\x");
|
||||
EXPECT_EQ (tl::combine_path (tl::dirname ("/hello"), tl::filename ("/hello")), "\\hello");
|
||||
EXPECT_EQ (tl::combine_path (tl::dirname ("c:/hello"), tl::filename ("c:/hello")), "C:\\hello");
|
||||
EXPECT_EQ (tl::combine_path (tl::dirname ("/c:/hello"), tl::filename ("/c:/hello")), "C:\\hello");
|
||||
EXPECT_EQ (tl::combine_path (tl::dirname ("//hello"), tl::filename ("//hello")), "\\hello");
|
||||
EXPECT_EQ (tl::combine_path (tl::dirname ("//server:/hello"), tl::filename ("//server:/hello")), "\\\\server:\\hello");
|
||||
EXPECT_EQ (tl::combine_path (tl::dirname ("/hello/x"), tl::filename ("/hello/x")), "\\hello\\x");
|
||||
EXPECT_EQ (tl::combine_path (tl::dirname ("c:/hello/x"), tl::filename ("c:/hello/x")), "C:\\hello\\x");
|
||||
EXPECT_EQ (tl::combine_path (tl::dirname ("/c:/hello/x"), tl::filename ("/c:/hello/x")), "C:\\hello\\x");
|
||||
EXPECT_EQ (tl::combine_path (tl::dirname ("//hello/x"), tl::filename ("//hello/x")), "\\\\hello\\x");
|
||||
EXPECT_EQ (tl::combine_path (tl::dirname ("/hello/x/y"), tl::filename ("/hello/x/y")), "\\hello\\x\\y");
|
||||
EXPECT_EQ (tl::combine_path (tl::dirname ("hello/x"), tl::filename ("hello/x")), "hello\\x");
|
||||
|
||||
tl::file_utils_force_reset ();
|
||||
|
||||
|
|
@ -436,6 +466,9 @@ TEST (11)
|
|||
EXPECT_EQ (tl::join (tl::split_path ("/"), "+"), "/");
|
||||
EXPECT_EQ (tl::join (tl::split_path ("//"), "+"), "/");
|
||||
|
||||
EXPECT_EQ (tl::dirname ("hello"), ".");
|
||||
EXPECT_EQ (tl::dirname ("./hello"), ".");
|
||||
EXPECT_EQ (tl::dirname ("/hello"), "");
|
||||
EXPECT_EQ (tl::dirname ("/hello/world"), "/hello");
|
||||
EXPECT_EQ (tl::dirname ("/hello//world/"), "/hello/world");
|
||||
EXPECT_EQ (tl::dirname ("hello//world/"), "hello/world");
|
||||
|
|
@ -461,6 +494,14 @@ TEST (11)
|
|||
EXPECT_EQ (tl::combine_path ("hello", "world"), "hello/world");
|
||||
EXPECT_EQ (tl::combine_path ("hello", ""), "hello");
|
||||
EXPECT_EQ (tl::combine_path ("hello", "", true), "hello/");
|
||||
EXPECT_EQ (tl::combine_path ("", "hello", true), "/hello");
|
||||
EXPECT_EQ (tl::combine_path (".", "hello", true), "./hello");
|
||||
|
||||
EXPECT_EQ (tl::combine_path (tl::dirname ("hello"), tl::filename ("hello")), "./hello");
|
||||
EXPECT_EQ (tl::combine_path (tl::dirname ("/hello"), tl::filename ("/hello")), "/hello");
|
||||
EXPECT_EQ (tl::combine_path (tl::dirname ("/hello/x"), tl::filename ("/hello/x")), "/hello/x");
|
||||
EXPECT_EQ (tl::combine_path (tl::dirname ("/hello/x/y"), tl::filename ("/hello/x/y")), "/hello/x/y");
|
||||
EXPECT_EQ (tl::combine_path (tl::dirname ("hello/x"), tl::filename ("hello/x")), "hello/x");
|
||||
|
||||
tl::file_utils_force_reset ();
|
||||
|
||||
|
|
|
|||
|
|
@ -138,15 +138,15 @@ TEST(TextInputStream)
|
|||
tl::InputStream is (fn);
|
||||
tl::TextInputStream tis (is);
|
||||
EXPECT_EQ (tis.get_line (), "Hello, world!");
|
||||
EXPECT_EQ (tis.line_number (), 1);
|
||||
EXPECT_EQ (tis.line_number (), size_t (1));
|
||||
EXPECT_EQ (tis.get_line (), "With another line");
|
||||
EXPECT_EQ (tis.line_number (), 2);
|
||||
EXPECT_EQ (tis.line_number (), size_t (2));
|
||||
EXPECT_EQ (tis.peek_char (), '\n');
|
||||
EXPECT_EQ (tis.get_line (), "");
|
||||
EXPECT_EQ (tis.line_number (), 3);
|
||||
EXPECT_EQ (tis.line_number (), size_t (3));
|
||||
EXPECT_EQ (tis.peek_char (), 's');
|
||||
EXPECT_EQ (tis.get_line (), "separated by a LFCR and CRLF.");
|
||||
EXPECT_EQ (tis.line_number (), 4);
|
||||
EXPECT_EQ (tis.line_number (), size_t (4));
|
||||
EXPECT_EQ (tis.at_end (), true);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue