@@ -13,18 +13,18 @@ using namespace odr;
1313using namespace odr ::test;
1414
1515TEST (Document, odt) {
16- auto logger = Logger::create_stdio (" odr-test" , LogLevel::verbose);
16+ const auto logger = Logger::create_stdio (" odr-test" , LogLevel::verbose);
1717
18- DocumentFile document_file (
18+ const DocumentFile document_file (
1919 TestData::test_file_path (" odr-public/odt/about.odt" ), *logger);
2020
2121 EXPECT_EQ (document_file.file_type (), FileType::opendocument_text);
2222
23- Document document = document_file.document ();
23+ const Document document = document_file.document ();
2424
2525 EXPECT_EQ (document.document_type (), DocumentType::text);
2626
27- auto page_layout = document.root_element ().as_text_root ().page_layout ();
27+ const auto page_layout = document.root_element ().as_text_root ().page_layout ();
2828 EXPECT_TRUE (page_layout.width );
2929 EXPECT_EQ (Measure (" 8.2673in" ), page_layout.width );
3030 EXPECT_TRUE (page_layout.height );
@@ -57,96 +57,96 @@ TEST(Document, odg) {
5757}
5858
5959TEST (Document, edit_odt) {
60- auto logger = Logger::create_stdio (" odr-test" , LogLevel::verbose);
60+ const auto logger = Logger::create_stdio (" odr-test" , LogLevel::verbose);
6161
62- DocumentFile document_file (
62+ const DocumentFile document_file (
6363 TestData::test_file_path (" odr-public/odt/about.odt" ), *logger);
64- Document document = document_file.document ();
64+ const Document document = document_file.document ();
6565
66- std::function<void (Element)> edit = [&](Element element) {
67- for (Element child : element.children ()) {
66+ std::function<void (Element)> edit = [&](const Element element) {
67+ for (const Element child : element.children ()) {
6868 edit (child);
6969 }
7070 // TODO make editing empty text possible
71- if (auto text = element.as_text (); text && !text.content ().empty ()) {
71+ if (const auto text = element.as_text (); text && !text.content ().empty ()) {
7272 text.set_content (" hello world!" );
7373 }
7474 };
7575 edit (document.root_element ());
7676
77- std::string output_path =
77+ const std::string output_path =
7878 (std::filesystem::current_path () / " about_edit.odt" ).string ();
7979 document.save (output_path);
8080
81- DocumentFile validate_file (output_path);
82- Document validate_document = validate_file.document ();
83- std::function<void (Element)> validate = [&](Element element) {
84- for (Element child : element.children ()) {
81+ const DocumentFile validate_file (output_path);
82+ const Document validate_document = validate_file.document ();
83+ std::function<void (Element)> validate = [&](const Element element) {
84+ for (const Element child : element.children ()) {
8585 validate (child);
8686 }
8787 // TODO make editing empty text possible
88- if (auto text = element.as_text (); text && !text.content ().empty ()) {
88+ if (const auto text = element.as_text (); text && !text.content ().empty ()) {
8989 EXPECT_EQ (" hello world!" , text.content ());
9090 }
9191 };
9292 validate (validate_document.root_element ());
9393}
9494
9595TEST (Document, edit_docx) {
96- auto logger = Logger::create_stdio (" odr-test" , LogLevel::verbose);
96+ const auto logger = Logger::create_stdio (" odr-test" , LogLevel::verbose);
9797
98- DocumentFile document_file (
98+ const DocumentFile document_file (
9999 TestData::test_file_path (" odr-public/docx/style-various-1.docx" ),
100100 *logger);
101- Document document = document_file.document ();
101+ const Document document = document_file.document ();
102102
103- std::function<void (Element)> edit = [&](Element element) {
104- for (Element child : element.children ()) {
103+ std::function<void (Element)> edit = [&](const Element element) {
104+ for (const Element child : element.children ()) {
105105 edit (child);
106106 }
107107 // TODO make editing empty text possible
108- if (auto text = element.as_text (); text && !text.content ().empty ()) {
108+ if (const auto text = element.as_text (); text && !text.content ().empty ()) {
109109 text.set_content (" hello world!" );
110110 }
111111 };
112112 edit (document.root_element ());
113113
114- std::string output_path =
114+ const std::string output_path =
115115 (std::filesystem::current_path () / " style-various-1_edit.docx" ).string ();
116116 document.save (output_path);
117117
118- DocumentFile validate_file (output_path);
119- Document validate_document = validate_file.document ();
120- std::function<void (Element)> validate = [&](Element element) {
121- for (Element child : element.children ()) {
118+ const DocumentFile validate_file (output_path);
119+ const Document validate_document = validate_file.document ();
120+ std::function<void (Element)> validate = [&](const Element element) {
121+ for (const Element child : element.children ()) {
122122 validate (child);
123123 }
124124 // TODO make editing empty text possible
125- if (auto text = element.as_text (); text && !text.content ().empty ()) {
125+ if (const auto text = element.as_text (); text && !text.content ().empty ()) {
126126 EXPECT_EQ (" hello world!" , text.content ());
127127 }
128128 };
129129 validate (validate_document.root_element ());
130130}
131131
132132TEST (Document, edit_odt_diff) {
133- auto logger = Logger::create_stdio (" odr-test" , LogLevel::verbose);
133+ const auto logger = Logger::create_stdio (" odr-test" , LogLevel::verbose);
134134
135- auto diff =
135+ const auto diff =
136136 R"( {"modifiedText":{"/child:16/child:0":"Outasdfsdafdline","/child:24/child:0":"Colorasdfasdfasdfed Line","/child:6/child:0":"Text hello world!"}})" ;
137- DocumentFile document_file (
137+ const DocumentFile document_file (
138138 TestData::test_file_path (" odr-public/odt/style-various-1.odt" ), *logger);
139- Document document = document_file.document ();
139+ const Document document = document_file.document ();
140140
141141 html::edit (document, diff);
142142
143- std::string output_path =
143+ const std::string output_path =
144144 (std::filesystem::current_path () / " style-various-1_edit_diff.odt" )
145145 .string ();
146146 document.save (output_path);
147147
148- DocumentFile validate_file (output_path);
149- Document validate_document = validate_file.document ();
148+ const DocumentFile validate_file (output_path);
149+ const Document validate_document = validate_file.document ();
150150 EXPECT_EQ (" Outasdfsdafdline" ,
151151 DocumentPath::find (validate_document.root_element (),
152152 DocumentPath (" /child:16/child:0" ))
@@ -222,24 +222,24 @@ TEST(Document, edit_odt_diff) {
222222// }
223223
224224TEST (Document, edit_docx_diff) {
225- auto logger = Logger::create_stdio (" odr-test" , LogLevel::verbose);
225+ const auto logger = Logger::create_stdio (" odr-test" , LogLevel::verbose);
226226
227- auto diff =
227+ const auto diff =
228228 R"( {"modifiedText":{"/child:16/child:0/child:0":"Outasdfsdafdline","/child:24/child:0/child:0":"Colorasdfasdfasdfed Line","/child:6/child:0/child:0":"Text hello world!"}})" ;
229- DocumentFile document_file (
229+ const DocumentFile document_file (
230230 TestData::test_file_path (" odr-public/docx/style-various-1.docx" ),
231231 *logger);
232- Document document = document_file.document ();
232+ const Document document = document_file.document ();
233233
234234 html::edit (document, diff);
235235
236- std::string output_path =
236+ const std::string output_path =
237237 (std::filesystem::current_path () / " style-various-1_edit_diff.docx" )
238238 .string ();
239239 document.save (output_path);
240240
241- DocumentFile validate_file (output_path);
242- Document validate_document = validate_file.document ();
241+ const DocumentFile validate_file (output_path);
242+ const Document validate_document = validate_file.document ();
243243 EXPECT_EQ (" Outasdfsdafdline" ,
244244 DocumentPath::find (validate_document.root_element (),
245245 DocumentPath (" /child:16/child:0/child:0" ))
0 commit comments