2024-05-29 16:29:08 +10:00
|
|
|
#include <cruft/util/parse/value.hpp>
|
|
|
|
#include <cruft/util/tap.hpp>
|
2017-07-26 15:25:29 +10:00
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
int
|
|
|
|
main (void)
|
|
|
|
{
|
2018-08-05 14:42:02 +10:00
|
|
|
cruft::TAP::logger tap;
|
2017-07-26 15:25:29 +10:00
|
|
|
|
2019-03-19 12:38:22 +11:00
|
|
|
tap.expect_eq (cruft::parse::from_string<long> ("1"), 1L, "parsing long '1'");
|
|
|
|
tap.expect_throw<std::invalid_argument> ([] () { cruft::parse::from_string<long> ("a"); }, "parsing long 'a'");
|
2017-07-26 15:25:29 +10:00
|
|
|
|
2019-03-19 12:38:22 +11:00
|
|
|
tap.expect_eq (cruft::parse::from_string<float> ("1"), 1.f, "parsing float '1'");
|
|
|
|
tap.expect_throw<std::invalid_argument> ([] () { cruft::parse::from_string<float> ("a"); }, "parsing float 'a'");
|
2017-07-26 15:25:29 +10:00
|
|
|
|
2019-05-30 10:42:25 +10:00
|
|
|
tap.expect_eq (cruft::parse::from_string<bool> ("true"), true, "parsing true");
|
|
|
|
tap.expect_eq (cruft::parse::from_string<bool> ("false"), false, "parsing false");
|
|
|
|
|
2017-07-26 15:25:29 +10:00
|
|
|
return tap.status ();
|
|
|
|
}
|