< Summary - Igor Pro Universal Testing Framework

Information
Class: tests.UnitTests.Tracing.CoberturaTests
Assembly: Tracing
File(s): /builds/mirror/igortest/tests/UnitTests/Tracing/CoberturaTests.ipf
Tag: 74147b3
Line coverage
100%
Covered lines: 141
Uncovered lines: 0
Coverable lines: 141
Total lines: 199
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

File(s)

/builds/mirror/igortest/tests/UnitTests/Tracing/CoberturaTests.ipf

#LineLine coverage
 1#pragma rtGlobals=3
 2#pragma TextEncoding="UTF-8"
 3#pragma rtFunctionErrors=1
 4#pragma version=1.10
 5#pragma ModuleName=TEST_Tracing_Cobertura
 6
 7#undef UTF_ALLOW_TRACING
 8#if Exists("TUFXOP_Version")
 9
 10#if IgorVersion() >= 10.00
 11#define UTF_ALLOW_TRACING
 12#elif (IgorVersion() >= 9.00) && (NumberByKey("BUILD", IgorInfo(0)) >= 38812)
 13#define UTF_ALLOW_TRACING
 14#endif
 15
 16#endif
 17
 18#ifdef UTF_ALLOW_TRACING
 19
 120static Function Test_FilePathToXml()
 121  string result, expect
 22
 123  expect = "abc/def/ghi"
 124  result = IUTF_Tracing_Cobertura#FilePathToXml("abc\\def\\ghi")
 125  CHECK_EQUAL_STR(expect, result)
 126End
 27
 128static Function Test_GetClassName()
 129  string result, expect
 30
 131  expect = "abc.def.ghi.jkl"
 132  result = IUTF_Tracing_Cobertura#GetClassName("abc\\def\\ghi\\jkl.txt")
 133  CHECK_EQUAL_STR(expect, result)
 34
 135  expect = "abc"
 136  result = IUTF_Tracing_Cobertura#GetClassName("abc.txt")
 137  CHECK_EQUAL_STR(expect, result)
 38
 139  expect = "abc.def.ghi.jkl"
 140  result = IUTF_Tracing_Cobertura#GetClassName("abc\\def\\ghi\\jkl")
 141  CHECK_EQUAL_STR(expect, result)
 42
 143  expect = ""
 144  result = IUTF_Tracing_Cobertura#GetClassName("")
 145  CHECK_EQUAL_STR(expect, result)
 146End
 47
 448static Function CheckProcInfo(string infoStr, STRUCT IUTF_Cobertura_ProcInfo &procInfo, string sourcePath, string packag
 449  string value
 50
 451  value = procInfo.sourcePath
 452  INFO(infoStr)
 453  INFO("Source Path")
 454  CHECK_EQUAL_STR(sourcePath, value)
 55
 456  value = procInfo.packageName
 457  INFO(infoStr)
 458  INFO("Package Name")
 459  CHECK_EQUAL_STR(packageName, value)
 60
 461  value = procInfo.classFileName
 462  INFO(infoStr)
 463  INFO("Class File Name")
 464  CHECK_EQUAL_STR(classFileName, value)
 65
 466  value = procInfo.className
 467  INFO(infoStr)
 468  INFO("Class Name")
 469  CHECK_EQUAL_STR(className, value)
 470End
 71
 172static Function Test_GetProcInfo()
 173  string                         infoStr
 174  STRUCT IUTF_Cobertura_ProcInfo procInfo
 75
 176  infoStr = "path is directly inside first path"
 177  Make/FREE=1/T sources = {"foo\\bar\\"}
 178  [procInfo] = IUTF_Tracing_Cobertura#GetProcInfo("foo\\bar\\baz.txt", sources)
 179  CheckProcInfo(infoStr, procInfo, "foo\\bar", "", "baz.txt", "baz")
 80
 181  infoStr = "path is directly inside second path"
 182  Make/FREE=1/T sources = {"abc\\", "foo\\bar\\"}
 183  [procInfo] = IUTF_Tracing_Cobertura#GetProcInfo("foo\\bar\\baz.txt", sources)
 184  CheckProcInfo(infoStr, procInfo, "foo\\bar", "", "baz.txt", "baz")
 85
 186  infoStr = "path is somewhere in a subdirectory of a path"
 187  Make/FREE=1/T sources = {"abc\\", "foo\\bar\\"}
 188  [procInfo] = IUTF_Tracing_Cobertura#GetProcInfo("foo\\bar\\abc\\def\\baz.txt", sources)
 189  CheckProcInfo(infoStr, procInfo, "foo\\bar", "abc\\def", "abc\\def\\baz.txt", "abc.def.baz")
 90
 191  infoStr = "path is not included in sources"
 192  Make/FREE=1/T sources = {"abc\\"}
 193  [procInfo] = IUTF_Tracing_Cobertura#GetProcInfo("foo\\bar\\baz.txt", sources)
 194  CheckProcInfo(infoStr, procInfo, "foo\\bar", "", "baz.txt", "baz")
 195End
 96
 197static Function Test_GetLinesReport_NoBranch()
 198  STRUCT IUTF_Cobertura_Metrics metrics
 199  string                        result
 100
 1101  string   indent    = ""
 1102  variable lineStart = 0
 1103  variable lineEnd   = 2
 1104  variable procIndex = 1
 1105  string   expected  = "<lines>\n"                                            + \
 1106                       "\t<line number=\"1\" hits=\"1\" branch=\"false\"/>\n" + \
 1107                       "\t<line number=\"2\" hits=\"2\" branch=\"false\"/>\n" + \
 1108                       "</lines>\n"
 109
 1110  Make/FREE=1/N=(3, 3, 2) totals
 1111  totals[][0][procIndex] = p + 1
 112
 1113  WAVE marker = IUTF_Tracing#GetNewMarkerWave(3)
 1114  marker[][%INSTR] = 1
 115
 1116  [result, metrics] = IUTF_Tracing_Cobertura#GetLinesReport(indent, lineStart, lineEnd, procIndex, totals, marker)
 117
 1118  INFO("xml output")
 1119  CHECK_EQUAL_STR(expected, result)
 120
 1121  CHECK_EQUAL_VAR(1, metrics.lineRate)
 1122  CHECK_EQUAL_VAR(2, metrics.lineCovered)
 1123  CHECK_EQUAL_VAR(2, metrics.lineValid)
 1124  CHECK_EQUAL_VAR(1, metrics.branchRate)
 1125  CHECK_EQUAL_VAR(0, metrics.branchCovered)
 1126  CHECK_EQUAL_VAR(0, metrics.branchValid)
 1127End
 128
 1129static Function Test_GetLinesReport_SingleBranch()
 1130  STRUCT IUTF_Cobertura_Metrics metrics
 1131  string                        result
 132
 1133  string   indent    = ""
 1134  variable lineStart = 0
 1135  variable lineEnd   = 4
 1136  variable procIndex = 1
 1137  string   expected  = "<lines>\n"                                                                           + \
 1138                       "\t<line number=\"1\" hits=\"1\" branch=\"false\"/>\n"                                + \
 1139                       "\t<line number=\"2\" hits=\"1\" branch=\"true\" condition-coverage=\"50% (1/2)\">\n" + \
 1140                       "\t\t<conditions>\n"                                                                  + \
 1141                       "\t\t\t<condition number=\"0\" type=\"jump\" coverage=\"50%\"/>\n"                    + \
 1142                       "\t\t</conditions>\n"                                                                 + \
 1143                       "\t</line>\n"                                                                         + \
 1144                       "\t<line number=\"3\" hits=\"0\" branch=\"false\"/>\n"                                + \
 1145                       "\t<line number=\"4\" hits=\"1\" branch=\"false\"/>\n"                                + \
 1146                       "</lines>\n"
 147
 1148  Make/FREE=1/N=(5, 3, 2) totals
 1149  totals[][0][procIndex]  = 1
 1150  totals[2][0][procIndex] = 0
 1151  totals[1][1][procIndex] = 1
 152
 1153  WAVE marker = IUTF_Tracing#GetNewMarkerWave(5)
 1154  marker[][%INSTR] = 1
 155
 1156  [result, metrics] = IUTF_Tracing_Cobertura#GetLinesReport(indent, lineStart, lineEnd, procIndex, totals, marker)
 157
 1158  INFO("xml output")
 1159  CHECK_EQUAL_STR(expected, result)
 160
 1161  CHECK_EQUAL_VAR(0.75, metrics.lineRate)
 1162  CHECK_EQUAL_VAR(3, metrics.lineCovered)
 1163  CHECK_EQUAL_VAR(4, metrics.lineValid)
 1164  CHECK_EQUAL_VAR(0.5, metrics.branchRate)
 1165  CHECK_EQUAL_VAR(1, metrics.branchCovered)
 1166  CHECK_EQUAL_VAR(2, metrics.branchValid)
 1167End
 168
 1169static Function Test_GetLinesReport_Empty()
 1170  STRUCT IUTF_Cobertura_Metrics metrics
 1171  string                        result
 172
 1173  string   indent    = ""
 1174  variable lineStart = 0
 1175  variable lineEnd   = 2
 1176  variable procIndex = 1
 1177  string   expected  = "<lines>\n" + \
 1178                       "</lines>\n"
 179
 1180  Make/FREE=1/N=(3, 3, 2) totals
 1181  totals[][0][procIndex] = p + 1
 182
 1183  WAVE marker = IUTF_Tracing#GetNewMarkerWave(3)
 1184  marker[][%INSTR] = 0
 185
 1186  [result, metrics] = IUTF_Tracing_Cobertura#GetLinesReport(indent, lineStart, lineEnd, procIndex, totals, marker)
 187
 1188  INFO("xml output")
 1189  CHECK_EQUAL_STR(expected, result)
 190
 1191  CHECK_EQUAL_VAR(1, metrics.lineRate)
 1192  CHECK_EQUAL_VAR(0, metrics.lineCovered)
 1193  CHECK_EQUAL_VAR(0, metrics.lineValid)
 1194  CHECK_EQUAL_VAR(1, metrics.branchRate)
 1195  CHECK_EQUAL_VAR(0, metrics.branchCovered)
 1196  CHECK_EQUAL_VAR(0, metrics.branchValid)
 1197End
 198
 199#endif // UTF_ALLOW_TRACING