• R/O
  • SSH
  • HTTPS

hamigaki: 提交


Commit MetaInfo

修訂1616 (tree)
時間2008-04-26 16:40:11
作者hamigaki

Log Message

added tar_pax_wide_test.cpp

Change Summary

差異

--- hamigaki/trunk/libs/archivers/test/tar_pax_wide_test.cpp (nonexistent)
+++ hamigaki/trunk/libs/archivers/test/tar_pax_wide_test.cpp (revision 1616)
@@ -0,0 +1,104 @@
1+// tar_pax_wide_test.cpp: test case for pax formatted tar (Unicode)
2+
3+// Copyright Takeshi Mouri 2008.
4+// Distributed under the Boost Software License, Version 1.0.
5+// (See accompanying file LICENSE_1_0.txt or copy at
6+// http://www.boost.org/LICENSE_1_0.txt)
7+
8+// See http://hamigaki.sourceforge.jp/libs/archivers for library home page.
9+
10+#include <hamigaki/archivers/tar_file.hpp>
11+#include <hamigaki/iostreams/device/tmp_file.hpp>
12+#include <hamigaki/iostreams/dont_close.hpp>
13+#include <boost/iostreams/copy.hpp>
14+#include <boost/test/unit_test.hpp>
15+#include <string>
16+
17+namespace ar = hamigaki::archivers;
18+namespace fs_ex = hamigaki::filesystem;
19+namespace io_ex = hamigaki::iostreams;
20+namespace fs = boost::filesystem;
21+namespace io = boost::iostreams;
22+namespace ut = boost::unit_test;
23+
24+void check_header(const ar::tar::wheader& old, const ar::tar::wheader& now)
25+{
26+ BOOST_CHECK_EQUAL(old.format, now.format);
27+ BOOST_CHECK_EQUAL(old.type_flag, now.type_flag);
28+ BOOST_CHECK(old.path == now.path);
29+ BOOST_CHECK(old.link_path == now.link_path);
30+ BOOST_CHECK(old.modified_time == now.modified_time);
31+ BOOST_CHECK(old.access_time == now.access_time);
32+ BOOST_CHECK(old.change_time == now.change_time);
33+ BOOST_CHECK_EQUAL(old.permissions, now.permissions);
34+ BOOST_CHECK(old.comment == now.comment);
35+}
36+
37+void unicode_test()
38+{
39+ ar::tar::wheader head;
40+ head.format = ar::tar::pax;
41+ head.type_flag = ar::tar::type_flag::regular;
42+ head.path = L"\x4F60\x597D.txt";
43+ head.modified_time = fs_ex::timestamp(std::time(0), 123456789);
44+ head.access_time = fs_ex::timestamp(1, 123456789);
45+ head.change_time = fs_ex::timestamp(12345, 0);
46+ head.permissions = 0123;
47+ head.comment = L"\xC548\xB155\xD558\xC2ED\xB2C8\xAE4C";
48+
49+ io_ex::tmp_file archive;
50+ ar::basic_tar_file_sink<
51+ io_ex::dont_close_device<io_ex::tmp_file>, fs::wpath
52+ > sink(io_ex::dont_close(archive));
53+
54+ sink.create_entry(head);
55+ sink.close();
56+ sink.close_archive();
57+
58+ io::seek(archive, 0, BOOST_IOS::beg);
59+
60+ ar::basic_tar_file_source<io_ex::tmp_file,fs::wpath> src(archive);
61+
62+ BOOST_CHECK(src.next_entry());
63+
64+ check_header(head, src.header());
65+
66+ BOOST_CHECK(!src.next_entry());
67+}
68+
69+void symlink_test()
70+{
71+ ar::tar::wheader head;
72+ head.format = ar::tar::pax;
73+ head.type_flag = ar::tar::type_flag::symlink;
74+ head.path = L"\x4F60\x597D.txt";
75+ head.link_path = L"\xC548\xB155\xD558\xC2ED\xB2C8\xAE4C.txt";
76+ head.modified_time = fs_ex::timestamp(std::time(0), 123456789);
77+
78+ io_ex::tmp_file archive;
79+ ar::basic_tar_file_sink<
80+ io_ex::dont_close_device<io_ex::tmp_file>, fs::wpath
81+ > sink(io_ex::dont_close(archive));
82+
83+ sink.create_entry(head);
84+ sink.close();
85+ sink.close_archive();
86+
87+ io::seek(archive, 0, BOOST_IOS::beg);
88+
89+ ar::basic_tar_file_source<io_ex::tmp_file,fs::wpath> src(archive);
90+
91+ BOOST_CHECK(src.next_entry());
92+
93+ check_header(head, src.header());
94+
95+ BOOST_CHECK(!src.next_entry());
96+}
97+
98+ut::test_suite* init_unit_test_suite(int, char* [])
99+{
100+ ut::test_suite* test = BOOST_TEST_SUITE("tar pax wide test");
101+ test->add(BOOST_TEST_CASE(&unicode_test));
102+ test->add(BOOST_TEST_CASE(&symlink_test));
103+ return test;
104+}
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Show on old repository browser