diff options
author | Jay Berkenbilt <ejb@ql.org> | 2022-02-08 15:18:08 +0100 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2022-02-08 17:51:15 +0100 |
commit | cb769c62e55599e9f980001830bc61d9fcaa64a9 (patch) | |
tree | 0bf980c385a61cbc8720cf990762ffc1200f9d6a /libtests/qutil.cc | |
parent | 716381f65a2b2dc72f8da2426ba71aeab02c507f (diff) | |
download | qpdf-cb769c62e55599e9f980001830bc61d9fcaa64a9.tar.zst |
WHITESPACE ONLY -- expand tabs in source code
This comment expands all tabs using an 8-character tab-width. You
should ignore this commit when using git blame or use git blame -w.
In the early days, I used to use tabs where possible for indentation,
since emacs did this automatically. In recent years, I have switched
to only using spaces, which means qpdf source code has been a mixture
of spaces and tabs. I have avoided cleaning this up because of not
wanting gratuitous whitespaces change to cloud the output of git
blame, but I changed my mind after discussing with users who view qpdf
source code in editors/IDEs that have other tab widths by default and
in light of the fact that I am planning to start applying automatic
code formatting soon.
Diffstat (limited to 'libtests/qutil.cc')
-rw-r--r-- | libtests/qutil.cc | 132 |
1 files changed, 66 insertions, 66 deletions
diff --git a/libtests/qutil.cc b/libtests/qutil.cc index 75cd47b3..e6fc4661 100644 --- a/libtests/qutil.cc +++ b/libtests/qutil.cc @@ -115,11 +115,11 @@ void string_conversion_test() // a non-C locale. set_locale(); std::cout << QUtil::int_to_string(16059) << std::endl - << QUtil::int_to_string(16059, 7) << std::endl - << QUtil::int_to_string(16059, -7) << std::endl - << QUtil::double_to_string(3.14159, 0, false) << std::endl - << QUtil::double_to_string(3.14159, 3) << std::endl - << QUtil::double_to_string(1000.123, -1024, false) << std::endl + << QUtil::int_to_string(16059, 7) << std::endl + << QUtil::int_to_string(16059, -7) << std::endl + << QUtil::double_to_string(3.14159, 0, false) << std::endl + << QUtil::double_to_string(3.14159, 3) << std::endl + << QUtil::double_to_string(1000.123, -1024, false) << std::endl << QUtil::double_to_string(.1234, 5, false) << std::endl << QUtil::double_to_string(.0001234, 5) << std::endl << QUtil::double_to_string(.123456, 5) << std::endl @@ -143,31 +143,31 @@ void string_conversion_test() char* tmp = QUtil::copy_string(embedded_null); if (memcmp(tmp, embedded_null.c_str(), 7) == 0) { - std::cout << "compare okay" << std::endl; + std::cout << "compare okay" << std::endl; } else { - std::cout << "compare failed" << std::endl; + std::cout << "compare failed" << std::endl; } delete [] tmp; // Also test with make_shared_cstr and make_unique_cstr auto tmp2 = QUtil::make_shared_cstr(embedded_null); if (memcmp(tmp2.get(), embedded_null.c_str(), 7) == 0) { - std::cout << "compare okay" << std::endl; + std::cout << "compare okay" << std::endl; } else { - std::cout << "compare failed" << std::endl; + std::cout << "compare failed" << std::endl; } auto tmp3 = QUtil::make_unique_cstr(embedded_null); if (memcmp(tmp3.get(), embedded_null.c_str(), 7) == 0) { - std::cout << "compare okay" << std::endl; + std::cout << "compare okay" << std::endl; } else { - std::cout << "compare failed" << std::endl; + std::cout << "compare failed" << std::endl; } std::string int_max_str = QUtil::int_to_string(INT_MAX); @@ -197,14 +197,14 @@ void os_wrapper_test() { try { - std::cout << "before remove" << std::endl; - QUtil::os_wrapper("remove file", + std::cout << "before remove" << std::endl; + QUtil::os_wrapper("remove file", remove("/this/file/does/not/exist")); - std::cout << "after remove" << std::endl; + std::cout << "after remove" << std::endl; } catch (std::runtime_error& s) { - std::cout << "exception: " << s.what() << std::endl; + std::cout << "exception: " << s.what() << std::endl; } } @@ -212,14 +212,14 @@ void fopen_wrapper_test() { try { - std::cout << "before fopen" << std::endl; - FILE* f = QUtil::safe_fopen("/this/file/does/not/exist", "r"); - std::cout << "after fopen" << std::endl; - (void) fclose(f); + std::cout << "before fopen" << std::endl; + FILE* f = QUtil::safe_fopen("/this/file/does/not/exist", "r"); + std::cout << "after fopen" << std::endl; + (void) fclose(f); } catch (QPDFSystemError& s) { - std::cout << "exception: " << s.what() << std::endl; + std::cout << "exception: " << s.what() << std::endl; assert(s.getErrno() != 0); } @@ -231,10 +231,10 @@ void getenv_test() { std::string val; std::cout << "IN_TESTSUITE: " << QUtil::get_env("IN_TESTSUITE", &val) - << ": " << val << std::endl; + << ": " << val << std::endl; // Hopefully this environment variable is not defined. std::cout << "HAGOOGAMAGOOGLE: " << QUtil::get_env("HAGOOGAMAGOOGLE") - << std::endl; + << std::endl; } static void print_utf8(unsigned long val) @@ -243,19 +243,19 @@ static void print_utf8(unsigned long val) std::cout << "0x" << QUtil::uint_to_string_base(val, 16) << " ->"; if (val < 0xfffe) { - std::cout << " " << result; + std::cout << " " << result; } else { - // Emacs has trouble with utf-8 encoding files with characters - // outside the 16-bit portion, so just show the character - // values. - for (std::string::iterator iter = result.begin(); - iter != result.end(); ++iter) - { - std::cout << " " << QUtil::int_to_string_base( + // Emacs has trouble with utf-8 encoding files with characters + // outside the 16-bit portion, so just show the character + // values. + for (std::string::iterator iter = result.begin(); + iter != result.end(); ++iter) + { + std::cout << " " << QUtil::int_to_string_base( static_cast<int>(static_cast<unsigned char>(*iter)), 16, 2); - } + } } std::cout << std::endl; } @@ -269,11 +269,11 @@ void to_utf8_test() print_utf8(0x7fffffffUL); try { - print_utf8(0x80000000UL); + print_utf8(0x80000000UL); } catch (std::runtime_error& e) { - std::cout << "0x80000000: " << e.what() << std::endl; + std::cout << "0x80000000: " << e.what() << std::endl; } } @@ -407,11 +407,11 @@ void transcoding_test() assert(! QUtil::utf8_to_pdf_doc(input2, output)); assert(QUtil::utf8_to_pdf_doc(input3, output)); std::cout << "alternatives" << std::endl; - // char name mac win pdf-doc - // U+0192 florin 304 203 206 - // U+00A9 copyright 251 251 251 - // U+00E9 eacute 216 351 351 - // U+017E zcaron - 236 236 + // char name mac win pdf-doc + // U+0192 florin 304 203 206 + // U+00A9 copyright 251 251 251 + // U+00E9 eacute 216 351 351 + // U+017E zcaron - 236 236 std::string pdfdoc = "\206\251\351\236"; std::string utf8 = QUtil::pdf_doc_to_utf8(pdfdoc); print_alternatives(pdfdoc); @@ -669,39 +669,39 @@ int main(int argc, char* argv[]) try { std::cout << "---- string conversion" << std::endl; - string_conversion_test(); - std::cout << "---- os wrapper" << std::endl; - os_wrapper_test(); - std::cout << "---- fopen" << std::endl; - fopen_wrapper_test(); - std::cout << "---- getenv" << std::endl; - getenv_test(); - std::cout << "---- utf8" << std::endl; - to_utf8_test(); - std::cout << "---- utf16" << std::endl; - to_utf16_test(); - std::cout << "---- utf8_to_ascii" << std::endl; + string_conversion_test(); + std::cout << "---- os wrapper" << std::endl; + os_wrapper_test(); + std::cout << "---- fopen" << std::endl; + fopen_wrapper_test(); + std::cout << "---- getenv" << std::endl; + getenv_test(); + std::cout << "---- utf8" << std::endl; + to_utf8_test(); + std::cout << "---- utf16" << std::endl; + to_utf16_test(); + std::cout << "---- utf8_to_ascii" << std::endl; utf8_to_ascii_test(); - std::cout << "---- transcoding" << std::endl; + std::cout << "---- transcoding" << std::endl; transcoding_test(); - std::cout << "---- whoami" << std::endl; - get_whoami_test(); - std::cout << "---- file" << std::endl; - same_file_test(); - std::cout << "---- path" << std::endl; - path_test(); - std::cout << "---- read from file" << std::endl; - read_from_file_test(); - std::cout << "---- hex encode/decode" << std::endl; - hex_encode_decode_test(); - std::cout << "---- rename/delete" << std::endl; - rename_delete_test(); - std::cout << "---- timestamp" << std::endl; - timestamp_test(); + std::cout << "---- whoami" << std::endl; + get_whoami_test(); + std::cout << "---- file" << std::endl; + same_file_test(); + std::cout << "---- path" << std::endl; + path_test(); + std::cout << "---- read from file" << std::endl; + read_from_file_test(); + std::cout << "---- hex encode/decode" << std::endl; + hex_encode_decode_test(); + std::cout << "---- rename/delete" << std::endl; + rename_delete_test(); + std::cout << "---- timestamp" << std::endl; + timestamp_test(); } catch (std::exception& e) { - std::cout << "unexpected exception: " << e.what() << std::endl; + std::cout << "unexpected exception: " << e.what() << std::endl; } return 0; |