@@ -455,20 +455,92 @@ TEST(Component_cfg_test, Dict_internals_benchmark)
455455 * perf matters has much subtlety to it -- this tests it end-to-end through the publicly available log::Config API. */
456456TEST (Component_cfg_test, Interface)
457457{
458- #if 0
459458 Config cfg (Sev::S_INFO);
460- cfg.init_component_to_union_idx_mapping<>
461- (10,
462- S_CMPS_SZ, // @todo Test subtleties of this arg.
463- true);
464459
465460 Component comp0a{n0::n0::Cmps::S_COMP_A};
466461 Component comp0b{n0::n0::Cmps::S_COMP_B};
467462 Component comp1a{n1::n1::Cmps::S_COMP_A};
468463 Component comp1b{n1::n1::Cmps::S_COMP_B};
469-
470-
471-
464+ Component comp2a{n2::n2::Cmps::S_COMP_A};
465+ Component comp2b{n2::n2::Cmps::S_COMP_B};
466+ Component comp3a{n3::n3::Cmps::S_COMP_A};
467+ Component comp3b{n3::n3::Cmps::S_COMP_B};
468+ Component compXa{nX::nX::Cmps::S_COMP_A};
469+ Component compXb{nX::nX::Cmps::S_COMP_B};
470+
471+ cfg.init_component_to_union_idx_mapping <n0::n0::Cmps>(10 ,
472+ S_CMPS_SZ, // @todo Test subtleties of this arg.
473+ true );
474+ cfg.init_component_to_union_idx_mapping <n1::n1::Cmps>(10 + S_CMPS_SZ,
475+ S_CMPS_SZ);
476+ // 3rd arg default = false.
477+ cfg.init_component_to_union_idx_mapping <n2::n2::Cmps>(10 + (2 * S_CMPS_SZ),
478+ S_CMPS_SZ,
479+ true );
480+ cfg.init_component_to_union_idx_mapping <n3::n3::Cmps>(10 + (3 * S_CMPS_SZ),
481+ S_CMPS_SZ,
482+ false );
483+ // Logging (and/or per-component verbosity configuring) would begin here and below.
484+
485+ EXPECT_TRUE (cfg.output_whether_should_log (Sev::S_INFO, comp0a));
486+ EXPECT_TRUE (cfg.output_whether_should_log (Sev::S_INFO, comp0b));
487+ EXPECT_TRUE (cfg.output_whether_should_log (Sev::S_INFO, comp1a));
488+ EXPECT_TRUE (cfg.output_whether_should_log (Sev::S_INFO, comp1b));
489+ EXPECT_TRUE (cfg.output_whether_should_log (Sev::S_INFO, comp3a));
490+ EXPECT_TRUE (cfg.output_whether_should_log (Sev::S_INFO, comp3b));
491+ EXPECT_TRUE (cfg.output_whether_should_log (Sev::S_WARNING, comp0a));
492+ EXPECT_TRUE (cfg.output_whether_should_log (Sev::S_WARNING, comp0b));
493+ EXPECT_TRUE (cfg.output_whether_should_log (Sev::S_WARNING, comp1a));
494+ EXPECT_TRUE (cfg.output_whether_should_log (Sev::S_WARNING, comp1b));
495+ EXPECT_TRUE (cfg.output_whether_should_log (Sev::S_WARNING, comp3a));
496+ EXPECT_TRUE (cfg.output_whether_should_log (Sev::S_WARNING, comp3b));
497+ EXPECT_FALSE (cfg.output_whether_should_log (Sev::S_TRACE, comp0a));
498+ EXPECT_FALSE (cfg.output_whether_should_log (Sev::S_TRACE, comp0b));
499+ EXPECT_FALSE (cfg.output_whether_should_log (Sev::S_TRACE, comp1a));
500+ EXPECT_FALSE (cfg.output_whether_should_log (Sev::S_TRACE, comp1b));
501+ EXPECT_FALSE (cfg.output_whether_should_log (Sev::S_TRACE, comp3a));
502+ EXPECT_FALSE (cfg.output_whether_should_log (Sev::S_TRACE, comp3b));
503+ // These enums are not registered (but same result for now).
504+ EXPECT_TRUE (cfg.output_whether_should_log (Sev::S_INFO, compXa));
505+ EXPECT_TRUE (cfg.output_whether_should_log (Sev::S_INFO, compXb));
506+ EXPECT_TRUE (cfg.output_whether_should_log (Sev::S_WARNING, compXa));
507+ EXPECT_TRUE (cfg.output_whether_should_log (Sev::S_WARNING, compXb));
508+ EXPECT_FALSE (cfg.output_whether_should_log (Sev::S_TRACE, compXa));
509+ EXPECT_FALSE (cfg.output_whether_should_log (Sev::S_TRACE, compXb));
510+
511+ cfg.configure_component_verbosity (Sev::S_TRACE, comp0a);
512+ cfg.configure_component_verbosity (Sev::S_TRACE, comp3b);
513+ EXPECT_TRUE (cfg.output_whether_should_log (Sev::S_INFO, comp0a));
514+ EXPECT_TRUE (cfg.output_whether_should_log (Sev::S_INFO, comp0b));
515+ EXPECT_TRUE (cfg.output_whether_should_log (Sev::S_INFO, comp1a));
516+ EXPECT_TRUE (cfg.output_whether_should_log (Sev::S_INFO, comp1b));
517+ EXPECT_TRUE (cfg.output_whether_should_log (Sev::S_INFO, comp2a));
518+ EXPECT_TRUE (cfg.output_whether_should_log (Sev::S_INFO, comp2b));
519+ EXPECT_TRUE (cfg.output_whether_should_log (Sev::S_INFO, comp3a));
520+ EXPECT_TRUE (cfg.output_whether_should_log (Sev::S_INFO, comp3b));
521+ EXPECT_TRUE (cfg.output_whether_should_log (Sev::S_WARNING, comp0a));
522+ EXPECT_TRUE (cfg.output_whether_should_log (Sev::S_WARNING, comp0b));
523+ EXPECT_TRUE (cfg.output_whether_should_log (Sev::S_WARNING, comp1a));
524+ EXPECT_TRUE (cfg.output_whether_should_log (Sev::S_WARNING, comp1b));
525+ EXPECT_TRUE (cfg.output_whether_should_log (Sev::S_WARNING, comp2a));
526+ EXPECT_TRUE (cfg.output_whether_should_log (Sev::S_WARNING, comp2b));
527+ EXPECT_TRUE (cfg.output_whether_should_log (Sev::S_WARNING, comp3a));
528+ EXPECT_TRUE (cfg.output_whether_should_log (Sev::S_WARNING, comp3b));
529+ EXPECT_TRUE (cfg.output_whether_should_log (Sev::S_TRACE, comp0a)); // Oh goody! This should log now!
530+ EXPECT_FALSE (cfg.output_whether_should_log (Sev::S_TRACE, comp0b)); // Not this, though, still.
531+ EXPECT_FALSE (cfg.output_whether_should_log (Sev::S_TRACE, comp1a));
532+ EXPECT_FALSE (cfg.output_whether_should_log (Sev::S_TRACE, comp1b));
533+ EXPECT_FALSE (cfg.output_whether_should_log (Sev::S_TRACE, comp2a));
534+ EXPECT_FALSE (cfg.output_whether_should_log (Sev::S_TRACE, comp2b));
535+ EXPECT_FALSE (cfg.output_whether_should_log (Sev::S_TRACE, comp3a)); // Not this, though, still.
536+ EXPECT_TRUE (cfg.output_whether_should_log (Sev::S_TRACE, comp3b)); // Oh yay!
537+ // These enums are not registered... so same as before.
538+ EXPECT_TRUE (cfg.output_whether_should_log (Sev::S_INFO, compXa));
539+ EXPECT_TRUE (cfg.output_whether_should_log (Sev::S_INFO, compXb));
540+ EXPECT_TRUE (cfg.output_whether_should_log (Sev::S_WARNING, compXa));
541+ EXPECT_TRUE (cfg.output_whether_should_log (Sev::S_WARNING, compXb));
542+ EXPECT_FALSE (cfg.output_whether_should_log (Sev::S_TRACE, compXa));
543+ EXPECT_FALSE (cfg.output_whether_should_log (Sev::S_TRACE, compXb));
472544
473545 /* @todo Test component names (config via component-name Config::configure_component_verbosity_by_name();
474546 * output of component-names Config::output_component_to_ostream(); the relevant Config::init_*()).
@@ -479,7 +551,5 @@ TEST(Component_cfg_test, Interface)
479551 /* @todo Test various `Logger`s and/or Ostream_log_msg_writer in the sense that they leverage component-based
480552 * log::Config aspects. I.e., test from a still-higher layer. Possibly that would go in the unit tests
481553 * for those classes though. As of this writing they don't exist. */
482- #endif
483-
484554} // TEST(Component_cfg_test, Interface)
485555} // namespace flow::log::test
0 commit comments