]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | #if 0 |
2 | /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 | |
3 | // test_optional.cpp | |
4 | ||
5 | // (C) Copyright 2004 Pavel Vozenilek | |
6 | // Use, modification and distribution is subject to the Boost Software | |
7 | // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at | |
8 | // http://www.boost.org/LICENSE_1_0.txt) | |
9 | ||
10 | // should pass compilation and execution | |
11 | ||
12 | #include <cstddef> // NULL | |
13 | #include <cstdio> // remove | |
14 | #include <fstream> | |
15 | ||
16 | #include <boost/config.hpp> | |
17 | ||
18 | #if defined(BOOST_NO_STDC_NAMESPACE) | |
19 | namespace std{ | |
20 | using ::remove; | |
21 | } | |
22 | #endif | |
23 | ||
24 | #include <boost/archive/archive_exception.hpp> | |
25 | ||
26 | #define BOOST_ARCHIVE_TEST xml_archive.hpp | |
27 | ||
28 | #include "test_tools.hpp" | |
29 | ||
30 | #include <boost/serialization/optional.hpp> | |
31 | ||
32 | #include "A.hpp" | |
33 | #include "A.ipp" | |
34 | ||
35 | int test_main( int /* argc */, char* /* argv */[] ) | |
36 | { | |
37 | const char * testfile = boost::archive::tmpnam(NULL); | |
38 | BOOST_REQUIRE(NULL != testfile); | |
39 | ||
40 | const boost::optional<int> aoptional1; | |
41 | const boost::optional<int> aoptional2(123); | |
42 | { | |
43 | test_ostream os(testfile, TEST_STREAM_FLAGS); | |
44 | test_oarchive oa(os, TEST_ARCHIVE_FLAGS); | |
45 | //oa << boost::serialization::make_nvp("aoptional1",aoptional1); | |
46 | //oa << boost::serialization::make_nvp("aoptional2",aoptional2); | |
47 | } | |
48 | /* | |
49 | boost::optional<int> aoptional1a(999); | |
50 | boost::optional<int> aoptional2a; | |
51 | { | |
52 | test_istream is(testfile, TEST_STREAM_FLAGS); | |
53 | test_iarchive ia(is, TEST_ARCHIVE_FLAGS); | |
54 | ia >> boost::serialization::make_nvp("aoptional1",aoptional1a); | |
55 | ia >> boost::serialization::make_nvp("aoptional2",aoptional2a); | |
56 | } | |
57 | BOOST_CHECK(aoptional1 == aoptional1a); | |
58 | BOOST_CHECK(aoptional2 == aoptional2a); | |
59 | */ | |
60 | std::remove(testfile); | |
61 | return EXIT_SUCCESS; | |
62 | } | |
63 | ||
64 | // EOF | |
65 | ||
66 | #elseif 0 | |
67 | ||
68 | #include <fstream> | |
69 | ||
70 | #include <boost/archive/xml_woarchive.hpp> | |
71 | #include <boost/archive/xml_wiarchive.hpp> | |
72 | #include <boost/serialization/string.hpp> | |
73 | ||
74 | #include "test_tools.hpp" | |
75 | ||
76 | int test_main(int, char *argv[]) | |
77 | { | |
78 | const char * testfile = boost::archive::tmpnam(NULL); | |
79 | std::string s1 = "kkkabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"; | |
80 | std::wstring w1 = L"kkk"; | |
81 | std::wstring w2 = L"апр"; // some non-latin (for example russians) letters | |
82 | { | |
83 | std::wofstream ofs(testfile); | |
84 | { | |
85 | boost::archive::xml_woarchive oa(ofs); | |
86 | oa << boost::serialization::make_nvp("key1", s1); | |
87 | //oa << boost::serialization::make_nvp("key2", w1); | |
88 | //oa << boost::serialization::make_nvp("key3", w2); // here exception is thrown | |
89 | } | |
90 | } | |
91 | std::string new_s1; | |
92 | //std::wstring new_w1; | |
93 | //std::wstring new_w2; | |
94 | { | |
95 | std::wifstream ifs(testfile); | |
96 | { | |
97 | boost::archive::xml_wiarchive ia(ifs); | |
98 | ia >> boost::serialization::make_nvp("key1", new_s1); | |
99 | //ia >> boost::serialization::make_nvp("key2", new_w1); | |
100 | //ia >> boost::serialization::make_nvp("key3", new_w2); // here exception is thrown | |
101 | } | |
102 | } | |
103 | BOOST_CHECK(s1 == new_s1); | |
104 | //BOOST_CHECK(w1 == new_w1); | |
105 | //BOOST_CHECK(w2 == new_w2); | |
106 | return 0; | |
107 | } | |
108 | ||
109 | #else | |
110 | ||
111 | #include <boost/archive/xml_oarchive.hpp> | |
112 | #include <boost/serialization/nvp.hpp> | |
113 | ||
114 | #include <iostream> | |
115 | ||
116 | int main() { | |
117 | boost::archive::xml_oarchive oa( std::cerr ); | |
118 | int bob = 3; | |
119 | oa << boost::serialization::make_nvp( "bob", bob ); | |
120 | } | |
121 | ||
122 | #endif |