31 lines
870 B
C++
31 lines
870 B
C++
#include "parse/enum.hpp"
|
|
#include "parse/value.hpp"
|
|
#include "std.hpp"
|
|
#include "tap.hpp"
|
|
|
|
enum enumeration_t : u16 { FOO, BAR = 2, QUX = 257 };
|
|
|
|
int main ()
|
|
{
|
|
auto const cookie = cruft::parse::enumeration::setup<enumeration_t> ({
|
|
{ "FOO", FOO },
|
|
{ "BAR", BAR },
|
|
{ "QUX", QUX },
|
|
});
|
|
(void)cookie;
|
|
|
|
cruft::TAP::logger tap;
|
|
tap.expect_eq (FOO, cruft::parse::from_string<enumeration_t> ("FOO"), "enumeration, FOO");
|
|
tap.expect_eq (BAR, cruft::parse::from_string<enumeration_t> ("BAR"), "enumeration, BAR");
|
|
tap.expect_eq (QUX, cruft::parse::from_string<enumeration_t> ("QUX"), "enumeration, QUX");
|
|
|
|
tap.expect_eq (
|
|
u16 {QUX},
|
|
cruft::parse::enumeration::from_string<u16> (
|
|
cruft::typeidx<enumeration_t> (),
|
|
"QUX"
|
|
),
|
|
"u16, QUX"
|
|
);
|
|
return tap.status ();
|
|
} |