\hypertarget{convert_8cpp_source}{}\doxysection{convert.\+cpp}
\label{convert_8cpp_source}\index{tests/convert.cpp@{tests/convert.cpp}}
\mbox{\hyperlink{convert_8cpp}{Go to the documentation of this file.}}
\begin{DoxyCode}{0}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00001}00001 \textcolor{preprocessor}{\#include "{}\mbox{\hyperlink{convert_8h}{kblib/convert.h}}"{}}}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00002}00002 \textcolor{preprocessor}{\#include "{}catch.hpp"{}}}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00003}00003 }
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00004}00004 \textcolor{keyword}{using namespace }std::literals;}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00005}00005 }
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00006}\mbox{\hyperlink{convert_8cpp_a723d70ba6e56b58e7b16ffc7792ca9c4}{00006}} \mbox{\hyperlink{convert_8cpp_a723d70ba6e56b58e7b16ffc7792ca9c4}{TEST\_CASE}}(\textcolor{stringliteral}{"{}bases"{}}) \{}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00007}00007    CHECK(kblib::to\_string<62>(0) == \textcolor{stringliteral}{"{}0"{}});}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00008}00008    CHECK(kblib::to\_string<62>(1) == \textcolor{stringliteral}{"{}1"{}});}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00009}00009    CHECK(kblib::to\_string<62>(-\/1) == \textcolor{stringliteral}{"{}-\/1"{}});}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00010}00010    CHECK(kblib::to\_string<62>(10) == \textcolor{stringliteral}{"{}A"{}});}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00011}00011    CHECK(kblib::to\_string<62>(26) == \textcolor{stringliteral}{"{}Q"{}});}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00012}00012    CHECK(kblib::to\_string<62>(35) == \textcolor{stringliteral}{"{}Z"{}});}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00013}00013    CHECK(kblib::to\_string<62>(36) == \textcolor{stringliteral}{"{}a"{}});}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00014}00014    CHECK(kblib::to\_string<62>(61) == \textcolor{stringliteral}{"{}z"{}});}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00015}00015    CHECK(kblib::to\_string<62>(62) == \textcolor{stringliteral}{"{}10"{}});}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00016}00016    CHECK(kblib::to\_string<62>(63) == \textcolor{stringliteral}{"{}11"{}});}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00017}00017    CHECK(kblib::to\_string<62>(630) == \textcolor{stringliteral}{"{}AA"{}});}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00018}00018 }
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00019}00019    CHECK(kblib::to\_string<2>(65536) == \textcolor{stringliteral}{"{}10000000000000000"{}});}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00020}00020 }
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00021}00021    \textcolor{keyword}{using namespace }\mbox{\hyperlink{namespacekblib_1_1literals}{kblib::literals}};}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00022}00022    \textcolor{keyword}{auto} one = 1\_c;}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00023}00023    \textcolor{keyword}{static\_assert}(\textcolor{keyword}{decltype}(one)::value == 1, \textcolor{stringliteral}{"{}"{}});}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00024}00024    \textcolor{keyword}{static\_assert}(one == 1, \textcolor{stringliteral}{"{}"{}});}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00025}00025 \}}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00026}00026 }
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00027}\mbox{\hyperlink{convert_8cpp_ae594d892cfafe16d44729560ade739bf}{00027}} \mbox{\hyperlink{convert_8cpp_a723d70ba6e56b58e7b16ffc7792ca9c4}{TEST\_CASE}}(\textcolor{stringliteral}{"{}parse\_integer"{}}) \{}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00028}00028    \textcolor{keyword}{using namespace }Catch::Matchers;}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00029}00029 }
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00030}00030    CHECK\_THROWS\_MATCHES(kblib::parse\_integer<long>(\textcolor{stringliteral}{"{}"{}}), std::invalid\_argument,}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00031}00031                         Message(\textcolor{stringliteral}{"{}\(\backslash\)"{}\(\backslash\)"{} is not an integer"{}}));}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00032}00032    CHECK\_THROWS\_MATCHES(kblib::parse\_integer<long>(\textcolor{stringliteral}{"{}"{}}s), std::invalid\_argument,}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00033}00033                         Message(\textcolor{stringliteral}{"{}\(\backslash\)"{}\(\backslash\)"{} is not an integer"{}}));}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00034}00034    CHECK(kblib::parse\_integer<long>(\textcolor{stringliteral}{"{}0"{}}) == 0);}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00035}00035    CHECK(kblib::parse\_integer<long>(\textcolor{stringliteral}{"{}1"{}}) == 1);}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00036}00036    CHECK(kblib::parse\_integer<long>(\textcolor{stringliteral}{"{}-\/1"{}}) == -\/1);}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00037}00037    CHECK(kblib::parse\_integer<long>(\textcolor{stringliteral}{"{}10"{}}) == 10);}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00038}00038    CHECK(kblib::parse\_integer<long>(\textcolor{stringliteral}{"{}010"{}}) == 010);}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00039}00039    CHECK(kblib::parse\_integer<long>(\textcolor{stringliteral}{"{}0x10"{}}) == 0x10);}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00040}00040    CHECK(kblib::parse\_integer<long>(\textcolor{stringliteral}{"{}0b10"{}}) == 0b10);}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00041}00041    CHECK(kblib::parse\_integer<long>(\textcolor{stringliteral}{"{}0b1'0000'0000'0000'0000"{}}) == 65536);}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00042}00042 }
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00043}00043    CHECK\_THROWS\_AS(kblib::parse\_integer<long>(\textcolor{stringliteral}{"{}"{}}, 1), std::invalid\_argument);}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00044}00044    CHECK\_THROWS\_MATCHES(}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00045}00045        kblib::parse\_integer<long>(\textcolor{stringliteral}{"{}1"{}}, 1), std::invalid\_argument,}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00046}00046        Message(\textcolor{stringliteral}{"{}base must be either 0 or a positive number between 2 and 62"{}}));}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00047}00047    CHECK\_THROWS\_AS(kblib::parse\_integer<long>(\textcolor{stringliteral}{"{}1"{}}, -\/1), std::invalid\_argument);}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00048}00048    CHECK\_THROWS\_AS(kblib::parse\_integer<long>(\textcolor{stringliteral}{"{}1"{}}, 63), std::invalid\_argument);}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00049}00049    CHECK\_THROWS\_AS(kblib::parse\_integer<long>(\textcolor{stringliteral}{"{}1"{}}, 100), std::invalid\_argument);}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00050}00050    CHECK(kblib::parse\_integer<long>(\textcolor{stringliteral}{"{}0"{}}, 10) == 0);}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00051}00051    CHECK(kblib::parse\_integer<long>(\textcolor{stringliteral}{"{}1'0000'0000'0000'0000"{}}, 2) == 65536);}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00052}00052 }
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00053}00053    CHECK\_THROWS\_MATCHES(kblib::parse\_integer<long>(\textcolor{stringliteral}{"{}2135agfd"{}}),}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00054}00054                         std::invalid\_argument,}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00055}00055                         Message(\textcolor{stringliteral}{"{}invalid character in integer"{}}));}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00056}00056    CHECK\_THROWS\_MATCHES(kblib::parse\_integer<long>(\textcolor{stringliteral}{"{}0-\/1"{}}),}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00057}00057                         std::invalid\_argument,}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00058}00058                         Message(\textcolor{stringliteral}{"{}unexpected -\/ in integer"{}}));}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00059}00059    CHECK\_THROWS\_MATCHES(kblib::parse\_integer<long>(\textcolor{stringliteral}{"{}0x-\/1"{}}),}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00060}00060                         std::invalid\_argument,}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00061}00061                         Message(\textcolor{stringliteral}{"{}unexpected -\/ in integer"{}}));}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00062}00062    CHECK\_THROWS\_MATCHES(kblib::parse\_integer<long>(\textcolor{stringliteral}{"{}0b-\/1"{}}),}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00063}00063                         std::invalid\_argument,}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00064}00064                         Message(\textcolor{stringliteral}{"{}unexpected -\/ in integer"{}}));}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00065}00065 \}}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00066}00066 }
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00067}\mbox{\hyperlink{convert_8cpp_a1920cec1fbd9a6beb48adbce10bc5990}{00067}} \mbox{\hyperlink{convert_8cpp_a723d70ba6e56b58e7b16ffc7792ca9c4}{TEST\_CASE}}(\textcolor{stringliteral}{"{}fromStr"{}}) \{}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00068}00068    \textcolor{keyword}{using namespace }std::literals;}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00069}00069    \textcolor{keyword}{const} std::string str = \textcolor{stringliteral}{"{}100"{}};}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00070}00070    CHECK(kblib::fromStr<std::string>(str) == str);}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00071}00071    CHECK(kblib::fromStr<int>(str) == 100);}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00072}00072    CHECK(kblib::fromStr<bool>(\textcolor{stringliteral}{"{}1"{}}) == \textcolor{keyword}{true});}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00073}00073    CHECK(kblib::fromStr<bool>(\textcolor{stringliteral}{"{}true"{}}) == \textcolor{keyword}{true});}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00074}00074    CHECK(kblib::fromStr<bool>(\textcolor{stringliteral}{"{}0"{}}) == \textcolor{keyword}{false});}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00075}00075    CHECK(kblib::fromStr<bool>(\textcolor{stringliteral}{"{}false"{}}) == \textcolor{keyword}{false});}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00076}00076 }
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00077}00077 \textcolor{preprocessor}{\#if KBLIB\_USE\_STRING\_VIEW}}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00078}00078    \textcolor{keyword}{const} std::string\_view strv = str;}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00079}00079    CHECK(kblib::fromStr<std::string>(strv) == strv);}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00080}00080    CHECK(kblib::fromStr<int>(strv) == 100);}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00081}00081    CHECK(kblib::fromStr<bool>(\textcolor{stringliteral}{"{}1"{}}sv) == \textcolor{keyword}{true});}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00082}00082    CHECK(kblib::fromStr<bool>(\textcolor{stringliteral}{"{}true"{}}sv) == \textcolor{keyword}{true});}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00083}00083    CHECK(kblib::fromStr<bool>(\textcolor{stringliteral}{"{}0"{}}sv) == \textcolor{keyword}{false});}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00084}00084    CHECK(kblib::fromStr<bool>(\textcolor{stringliteral}{"{}false"{}}sv) == \textcolor{keyword}{false});}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00085}00085 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{\Hypertarget{convert_8cpp_source_l00086}00086 \}}

\end{DoxyCode}
