GCC Code Coverage Report


Directory: ./
File: src/TraitBackEnd/Nanobind/NanobindTraitTypeStream/NanobindTraitTypeStream.cpp
Date: 2026-09-08 15:48:42
Exec Total Coverage
Lines: 26 29 89.7%
Functions: 5 6 83.3%
Branches: 51 55 92.7%

Line Branch Exec Source
1 /***************************************
2 Auteur : Thibaut Oprinsen
3 Mail : thibaut.oprinsen@lapp.in2p3.fr
4 Licence : CeCILL-C
5 ****************************************/
6
7 #include "NanobindTraitTypeStream.h"
8
9 ///Constructor of NanobindTraitTypeStream
10 1 NanobindTraitTypeStream::NanobindTraitTypeStream()
11 1 : PAbstractNanobindTraitBackend()
12 1 {}
13
14 ///Destructor of NanobindTraitTypeStream
15 2 NanobindTraitTypeStream::~NanobindTraitTypeStream(){}
16
17 ///Registration of static method
18 4 void NanobindTraitTypeStream::registerStaticMethod(std::ofstream & fs, const PClassConfig & classConfig, const GeneratorMode & mode) const{
19
1/2
✗ Branch 0 (2→3) not taken.
✓ Branch 1 (2→4) taken 4 times.
4 if(!mode.enableTypeStream){return;}
20
2/2
✓ Branch 0 (4→5) taken 4 times.
✓ Branch 2 (5→6) taken 4 times.
4 PString name(classConfig.getName());
21
3/3
✓ Branch 0 (6→7) taken 4 times.
✓ Branch 2 (7→8) taken 1 times.
✓ Branch 3 (7→14) taken 3 times.
4 if(classConfig.getIsEnum()){
22
3/3
✓ Branch 0 (8→9) taken 1 times.
✓ Branch 2 (9→10) taken 1 times.
✓ Branch 4 (10→11) taken 1 times.
1 name = name + "::" + name;
23 }
24
4/4
✓ Branch 0 (14→15) taken 4 times.
✓ Branch 2 (15→16) taken 4 times.
✓ Branch 4 (16→17) taken 4 times.
✓ Branch 6 (17→18) taken 4 times.
4 fs << std::endl << std::endl << "\t\t///Get the name of the class " << name;
25
2/2
✓ Branch 0 (18→19) taken 4 times.
✓ Branch 2 (19→20) taken 4 times.
4 fs << std::endl << "\t\t.def_static(\"phoenix_get_type_name\", []() {";
26
4/4
✓ Branch 0 (20→21) taken 4 times.
✓ Branch 2 (21→22) taken 4 times.
✓ Branch 4 (22→23) taken 4 times.
✓ Branch 6 (23→24) taken 4 times.
4 fs << std::endl << "\t\t\treturn phoenix_getTypeName<" << name << ">();}, ";
27
4/4
✓ Branch 0 (24→25) taken 4 times.
✓ Branch 2 (25→26) taken 4 times.
✓ Branch 4 (26→27) taken 4 times.
✓ Branch 6 (27→28) taken 4 times.
4 fs << std::endl << "\t\t\t\"Return the type name of " << name << "\")";
28 4 }
29
30 ///Test function for type stream trait
31 4 void NanobindTraitTypeStream::testFunction(std::ofstream & fs, const PClassConfig & classConfig, const GeneratorMode & mode, const PString & baseFileName) const{
32
1/2
✗ Branch 0 (2→3) not taken.
✓ Branch 1 (2→4) taken 4 times.
4 if(!mode.enableTypeStream){return;}
33
2/2
✓ Branch 0 (4→5) taken 4 times.
✓ Branch 2 (5→6) taken 4 times.
4 PString name(classConfig.getName());
34
1/1
✓ Branch 0 (6→7) taken 4 times.
4 PString moduleName = baseFileName.toLower();
35
3/3
✓ Branch 0 (7→8) taken 4 times.
✓ Branch 2 (8→9) taken 4 times.
✓ Branch 4 (9→10) taken 4 times.
4 fs << "#Test Phoenix type name retrieval for " << name << std::endl;
36
2/2
✓ Branch 0 (10→11) taken 4 times.
✓ Branch 2 (11→12) taken 4 times.
4 fs << "def test_phoenix_type_name():" << std::endl;
37
2/2
✓ Branch 0 (12→13) taken 4 times.
✓ Branch 2 (13→14) taken 4 times.
4 fs << "\t\"\"\"Test Phoenix type name retrieval\"\"\"" << std::endl;
38
6/6
✓ Branch 0 (14→15) taken 4 times.
✓ Branch 2 (15→16) taken 4 times.
✓ Branch 4 (16→17) taken 4 times.
✓ Branch 6 (17→18) taken 4 times.
✓ Branch 8 (18→19) taken 4 times.
✓ Branch 10 (19→20) taken 4 times.
4 fs << "\ttype_name = " << moduleName << "." << name << ".phoenix_get_type_name()" << std::endl;
39
3/3
✓ Branch 0 (20→21) taken 4 times.
✓ Branch 2 (21→22) taken 1 times.
✓ Branch 3 (21→28) taken 3 times.
4 if(classConfig.getIsEnum()){
40
3/3
✓ Branch 0 (22→23) taken 1 times.
✓ Branch 2 (23→24) taken 1 times.
✓ Branch 4 (24→25) taken 1 times.
1 name = name + "::" + name;
41 }
42
5/5
✓ Branch 0 (28→29) taken 4 times.
✓ Branch 2 (29→30) taken 4 times.
✓ Branch 4 (30→31) taken 4 times.
✓ Branch 6 (31→32) taken 4 times.
✓ Branch 8 (32→33) taken 4 times.
4 fs << "\tassert type_name == \"" << name << "\"" << std::endl << std::endl;
43 4 }
44
45 ///call the test function for type stream trait
46 void NanobindTraitTypeStream::testCallFunction(std::ofstream & fs, const PClassConfig & classConfig, const GeneratorMode & mode) const{
47 if(!mode.enableTypeStream){return;}
48 fs << "\ttest_phoenix_type_name()" << std::endl;
49 }
50