|
| 1 | +// Copyright 2019-2026 CERN and copyright holders of ALICE O2. |
| 2 | +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. |
| 3 | +// All rights not expressly granted are reserved. |
| 4 | +// |
| 5 | +// This software is distributed under the terms of the GNU General Public |
| 6 | +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". |
| 7 | +// |
| 8 | +// In applying this license CERN does not waive the privileges and immunities |
| 9 | +// granted to it by virtue of its status as an Intergovernmental Organization |
| 10 | +// or submit itself to any jurisdiction. |
| 11 | + |
| 12 | +#include <catch_amalgamated.hpp> |
| 13 | +#include "Framework/AnalysisTask.h" |
| 14 | +#include <string_view> |
| 15 | + |
| 16 | +using namespace o2::framework; |
| 17 | + |
| 18 | +TEST_CASE("TypeIdHelpers_BasicConversion") |
| 19 | +{ |
| 20 | + // Basic CamelCase to snake-case conversion |
| 21 | + REQUIRE((type_to_task_name(std::string_view("SimpleTask")) == "simple-task")); |
| 22 | + REQUIRE((type_to_task_name(std::string_view("MyTask")) == "my-task")); |
| 23 | + REQUIRE((type_to_task_name(std::string_view("Task")) == "task")); |
| 24 | +} |
| 25 | + |
| 26 | +TEST_CASE("TypeIdHelpers_AbbreviationConsolidation") |
| 27 | +{ |
| 28 | + // Test ALICE detector abbreviations |
| 29 | + REQUIRE(type_to_task_name(std::string_view("ITSQA")) == "its-qa"); |
| 30 | + REQUIRE(type_to_task_name(std::string_view("TPCQCTask")) == "tpc-qc-task"); |
| 31 | + REQUIRE(type_to_task_name(std::string_view("EMCALQATask")) == "emcal-qa-task"); |
| 32 | + REQUIRE(type_to_task_name(std::string_view("HMPIDTask")) == "hmpid-task"); |
| 33 | + REQUIRE(type_to_task_name(std::string_view("ITSTPCTask")) == "its-tpc-task"); |
| 34 | + REQUIRE(type_to_task_name(std::string_view("QCFV0Task")) == "qc-fv0-task"); |
| 35 | +} |
| 36 | + |
| 37 | +TEST_CASE("TypeIdHelpers_QualityControlAbbreviations") |
| 38 | +{ |
| 39 | + // Test quality control abbreviations |
| 40 | + REQUIRE(type_to_task_name(std::string_view("QATask")) == "qa-task"); |
| 41 | + REQUIRE(type_to_task_name(std::string_view("QCTask")) == "qc-task"); |
| 42 | + REQUIRE(type_to_task_name(std::string_view("QCDAnalysis")) == "qcd-analysis"); |
| 43 | +} |
| 44 | + |
| 45 | +TEST_CASE("TypeIdHelpers_ComplexNames") |
| 46 | +{ |
| 47 | + // Test complex combinations |
| 48 | + REQUIRE(type_to_task_name(std::string_view("ITSQAAnalysisTask")) == "its-qa-analysis-task"); |
| 49 | + REQUIRE(type_to_task_name(std::string_view("TPCEMCQCTask")) == "tpc-emc-qc-task"); |
| 50 | + REQUIRE(type_to_task_name(std::string_view("MyITSTask")) == "my-its-task"); |
| 51 | +} |
| 52 | + |
| 53 | +TEST_CASE("TypeIdHelpers_EdgeCases") |
| 54 | +{ |
| 55 | + // Single character |
| 56 | + REQUIRE(type_to_task_name(std::string_view("A")) == "a"); |
| 57 | + |
| 58 | + // All uppercase. BC is Bunch Crossing! |
| 59 | + // |
| 60 | + REQUIRE(type_to_task_name(std::string_view("ABC")) == "a-bc"); |
| 61 | + REQUIRE(type_to_task_name(std::string_view("BC")) == "bc"); |
| 62 | + |
| 63 | + // Mixed with numbers (numbers are not uppercase, so no hyphens before them) |
| 64 | + REQUIRE(type_to_task_name(std::string_view("Task123")) == "task123"); |
| 65 | +} |
0 commit comments