From 15f3ccad1b756253b99e33290b4ecb2aee4fb2eb Mon Sep 17 00:00:00 2001 From: Niklas Hauser Date: Mon, 21 Dec 2015 12:00:14 +0000 Subject: [PATCH] Add constants to `{default|ignore}_handler`. This is better than explicitly casting to the handler you want. --- "frameworks\\utest/utest/default_handlers.h" | 56 ++++++++++++++------ 1 file changed, 39 insertions(+), 17 deletions(-) diff --git "a/frameworks\\utest/utest/default_handlers.h" "b/frameworks\\utest/utest/default_handlers.h" index 970b21da49..3c9fa516ca 100644 --- "a/frameworks\\utest/utest/default_handlers.h" +++ "b/frameworks\\utest/utest/default_handlers.h" @@ -31,37 +31,59 @@ namespace v1 { /** Default handler hint. * * Use this handler to indicate the you want the default handler to be called. - * This type automatically casts itself into the appropriate handler type. + * This type automatically casts itself into the appropriate handler type, when possible. + * Use the constants to default a handler unambigously. */ const struct { - operator test_setup_handler_t() const { return test_setup_handler_t(1); } - operator test_teardown_handler_t() const { return test_teardown_handler_t(1); } - operator test_failure_handler_t() const { return test_failure_handler_t(1); } + const test_setup_handler_t test_setup = test_setup_handler_t(1); + const test_teardown_handler_t test_teardown = test_teardown_handler_t(1); + const test_failure_handler_t test_failure = test_failure_handler_t(1); - operator case_setup_handler_t() const { return case_setup_handler_t(1); } - operator case_teardown_handler_t() const { return case_teardown_handler_t(1); } - operator case_failure_handler_t() const { return case_failure_handler_t(1); } + const case_setup_handler_t case_setup = case_setup_handler_t(1); + const case_teardown_handler_t case_teardown = case_teardown_handler_t(1); + const case_failure_handler_t case_failure = case_failure_handler_t(1); + + operator test_setup_handler_t() const { return test_setup; } + operator test_teardown_handler_t() const { return test_teardown; } + operator test_failure_handler_t() const { return test_failure; } + + operator case_setup_handler_t() const { return case_setup; } + operator case_teardown_handler_t() const { return case_teardown; } + operator case_failure_handler_t() const { return case_failure; } } default_handler; /** Ignore handler hint. * * Use this handler to indicate the you want to ignore this handler and it will not be called. - * This type automatically casts itself into the appropriate handler type. + * This type automatically casts itself into the appropriate handler type, when possible. + * Use the constants to ignore a handler unambigously. */ const struct { - operator case_handler_t() const { return case_handler_t(NULL); } - operator case_control_handler_t() const { return case_control_handler_t(NULL); } - operator case_repeat_count_handler_t() const { return case_repeat_count_handler_t(NULL); } + const case_handler_t handler = case_handler_t(NULL); + const case_control_handler_t control = case_control_handler_t(NULL); + const case_repeat_count_handler_t repeat_count = case_repeat_count_handler_t(NULL); - operator test_setup_handler_t() const { return test_setup_handler_t(NULL); } - operator test_teardown_handler_t() const { return test_teardown_handler_t(NULL); } - operator test_failure_handler_t() const { return test_failure_handler_t(NULL); } + const test_setup_handler_t test_setup = test_setup_handler_t(1); + const test_teardown_handler_t test_teardown = test_teardown_handler_t(1); + const test_failure_handler_t test_failure = test_failure_handler_t(1); - operator case_setup_handler_t() const { return case_setup_handler_t(NULL); } - operator case_teardown_handler_t() const { return case_teardown_handler_t(NULL); } - operator case_failure_handler_t() const { return case_failure_handler_t(NULL); } + const case_setup_handler_t case_setup = case_setup_handler_t(1); + const case_teardown_handler_t case_teardown = case_teardown_handler_t(1); + const case_failure_handler_t case_failure = case_failure_handler_t(1); + + operator case_handler_t() const { return handler; } + operator case_control_handler_t() const { return control; } + operator case_repeat_count_handler_t() const { return repeat_count; } + + operator test_setup_handler_t() const { return test_setup; } + operator test_teardown_handler_t() const { return test_teardown; } + operator test_failure_handler_t() const { return test_failure; } + + operator case_setup_handler_t() const { return case_setup; } + operator case_teardown_handler_t() const { return case_teardown; } + operator case_failure_handler_t() const { return case_failure; } } ignore_handler; /** A table of handlers.