Global Metrics
path: .metrics.cognitive.average
old: null
new: 0.1111111111111111
path: .metrics.halstead.volume
old: 381.55971309377543
new: 9415.0
path: .metrics.halstead.N1
old: 37.0
new: 751.0
path: .metrics.halstead.N2
old: 38.0
new: 594.0
path: .metrics.halstead.vocabulary
old: 34.0
new: 128.0
path: .metrics.halstead.n2
old: 27.0
new: 114.0
path: .metrics.halstead.length
old: 75.0
new: 1345.0
path: .metrics.halstead.level
old: 0.2030075187969925
new: 0.027417027417027416
path: .metrics.halstead.n1
old: 7.0
new: 14.0
path: .metrics.halstead.time
old: 104.41860461208256
new: 19077.763157894737
path: .metrics.halstead.difficulty
old: 4.925925925925926
new: 36.473684210526315
path: .metrics.halstead.bugs
old: 0.050766708387169186
new: 1.6346020928227711
path: .metrics.halstead.effort
old: 1879.5348830174864
new: 343399.7368421053
path: .metrics.halstead.estimated_program_length
old: 148.03344701281688
new: 832.2524305235869
path: .metrics.halstead.purity_ratio
old: 1.973779293504225
new: 0.6187750412814772
path: .metrics.loc.cloc
old: 21.0
new: 34.0
path: .metrics.loc.blank
old: 12.0
new: 26.0
path: .metrics.loc.lloc
old: 0.0
new: 102.0
path: .metrics.loc.ploc
old: 28.0
new: 177.0
path: .metrics.loc.sloc
old: 61.0
new: 237.0
path: .metrics.cyclomatic.sum
old: 7.0
new: 11.0
path: .metrics.cyclomatic.average
old: 1.4
new: 1.1
path: .metrics.nargs.average
old: null
new: 2.0
path: .metrics.nargs.sum
old: 0.0
new: 18.0
path: .metrics.nom.functions
old: 0.0
new: 9.0
path: .metrics.nom.total
old: 0.0
new: 9.0
path: .metrics.mi.mi_original
old: 71.88365312658684
new: 32.30711661993635
path: .metrics.mi.mi_visual_studio
old: 42.03722405063557
new: 18.89305065493354
path: .metrics.mi.mi_sei
old: 68.16168656206915
new: -0.2876382136774325
path: .metrics.nexits.average
old: null
new: 0.0
Spaces Data
Minimal test - lines (105, 121)
path: .spaces[2].metrics.nexits.average
old: null
new: 0.0
path: .spaces[2].metrics.mi.mi_sei
old: 119.97629276875443
new: 75.71971753504829
path: .spaces[2].metrics.mi.mi_original
old: 135.56248504247483
new: 92.16844033089887
path: .spaces[2].metrics.mi.mi_visual_studio
old: 79.27630704238294
new: 53.899672708128
path: .spaces[2].metrics.cognitive.average
old: null
new: 0.0
path: .spaces[2].metrics.loc.ploc
old: 4.0
new: 16.0
path: .spaces[2].metrics.loc.sloc
old: 4.0
new: 17.0
path: .spaces[2].metrics.loc.cloc
old: 0.0
new: 1.0
path: .spaces[2].metrics.loc.lloc
old: 0.0
new: 10.0
path: .spaces[2].metrics.nom.functions
old: 0.0
new: 1.0
path: .spaces[2].metrics.nom.total
old: 0.0
new: 1.0
path: .spaces[2].metrics.halstead.length
old: 5.0
new: 116.0
path: .spaces[2].metrics.halstead.vocabulary
old: 5.0
new: 25.0
path: .spaces[2].metrics.halstead.bugs
old: 0.00170906242423416
new: 0.1018623574555468
path: .spaces[2].metrics.halstead.estimated_program_length
old: 6.754887502163468
new: 94.71013448036484
path: .spaces[2].metrics.halstead.purity_ratio
old: 1.3509775004326936
new: 0.8164666765548694
path: .spaces[2].metrics.halstead.difficulty
old: 1.0
new: 9.916666666666666
path: .spaces[2].metrics.halstead.effort
old: 11.60964047443681
new: 5341.982570304191
path: .spaces[2].metrics.halstead.N1
old: 2.0
new: 65.0
path: .spaces[2].metrics.halstead.N2
old: 3.0
new: 51.0
path: .spaces[2].metrics.halstead.level
old: 1.0
new: 0.10084033613445378
path: .spaces[2].metrics.halstead.time
old: 0.6449800263576005
new: 296.77680946134393
path: .spaces[2].metrics.halstead.n2
old: 3.0
new: 18.0
path: .spaces[2].metrics.halstead.n1
old: 2.0
new: 7.0
path: .spaces[2].metrics.halstead.volume
old: 11.60964047443681
new: 538.687318013868
path: .spaces[2].metrics.nargs.sum
old: 0.0
new: 2.0
path: .spaces[2].metrics.nargs.average
old: null
new: 2.0
Code
TEST(TextFormatterTestMismatch, format_d)
{
nsString out;
// just for completeness, this is our format, and works
nsTextFormatter::ssprintf(out, u"%d", int(-1));
EXPECT_STREQ("-1", NS_ConvertUTF16toUTF8(out).get());
nsTextFormatter::ssprintf(out, u"%d", uint32_t(-1));
EXPECT_STREQ("4294967295", NS_ConvertUTF16toUTF8(out).get());
#ifndef DEBUG
nsTextFormatter::ssprintf(out, u"%d", float(3.5));
EXPECT_STREQ("3.5", NS_ConvertUTF16toUTF8(out).get());
nsTextFormatter::ssprintf(out, u"%d", "foo");
EXPECT_STREQ("foo", NS_ConvertUTF16toUTF8(out).get());
nsTextFormatter::ssprintf(out, u"%d", u"foo");
EXPECT_STREQ("foo", NS_ConvertUTF16toUTF8(out).get());
#endif
}
Minimal test - lines (10, 47)
path: .spaces[0].metrics.mi.mi_original
old: null
new: 73.0906005818299
path: .spaces[0].metrics.mi.mi_visual_studio
old: null
new: 42.74304127592392
path: .spaces[0].metrics.mi.mi_sei
old: null
new: 51.03371083843999
path: .spaces[0].metrics.cognitive.sum
old: 0.0
new: 1.0
path: .spaces[0].metrics.cognitive.average
old: null
new: 1.0
path: .spaces[0].metrics.nom.functions
old: 0.0
new: 1.0
path: .spaces[0].metrics.nom.total
old: 0.0
new: 1.0
path: .spaces[0].metrics.loc.ploc
old: 1.0
new: 28.0
path: .spaces[0].metrics.loc.cloc
old: 0.0
new: 3.0
path: .spaces[0].metrics.loc.lloc
old: 0.0
new: 11.0
path: .spaces[0].metrics.loc.blank
old: 0.0
new: 7.0
path: .spaces[0].metrics.loc.sloc
old: 1.0
new: 38.0
path: .spaces[0].metrics.cyclomatic.average
old: 1.0
new: 2.0
path: .spaces[0].metrics.cyclomatic.sum
old: 1.0
new: 2.0
path: .spaces[0].metrics.halstead.estimated_program_length
old: null
new: 380.5804471432244
path: .spaces[0].metrics.halstead.length
old: 1.0
new: 269.0
path: .spaces[0].metrics.halstead.volume
old: 0.0
new: 1648.777131558196
path: .spaces[0].metrics.halstead.difficulty
old: 0.0
new: 13.342105263157896
path: .spaces[0].metrics.halstead.n2
old: 1.0
new: 57.0
path: .spaces[0].metrics.halstead.n1
old: 0.0
new: 13.0
path: .spaces[0].metrics.halstead.time
old: 0.0
new: 1222.119891374277
path: .spaces[0].metrics.halstead.N1
old: 0.0
new: 152.0
path: .spaces[0].metrics.halstead.N2
old: 1.0
new: 117.0
path: .spaces[0].metrics.halstead.purity_ratio
old: null
new: 1.4147972012759271
path: .spaces[0].metrics.halstead.bugs
old: 0.0
new: 0.2616995387610926
path: .spaces[0].metrics.halstead.vocabulary
old: 1.0
new: 70.0
path: .spaces[0].metrics.halstead.level
old: null
new: 0.07495069033530571
path: .spaces[0].metrics.halstead.effort
old: 0.0
new: 21998.158044736985
path: .spaces[0].metrics.nargs.average
old: null
new: 2.0
path: .spaces[0].metrics.nargs.sum
old: 0.0
new: 2.0
path: .spaces[0].metrics.nexits.average
old: null
new: 0.0
Code
TEST(TextFormatter, Tests)
{
nsAutoString fmt(u"%3$s %4$S %1$d %2$d %2$d %3$s"_ns);
char utf8[] = "Hello";
char16_t ucs2[] = {'W', 'o', 'r', 'l', 'd',
0x4e00, 0xAc00, 0xFF45, 0x0103, 0x00};
int d = 3;
char16_t buf[256];
nsTextFormatter::snprintf(buf, 256, fmt.get(), d, 333, utf8, ucs2);
nsAutoString out(buf);
const char16_t* uout = out.get();
const char16_t expected[] = {
0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x57, 0x6F, 0x72, 0x6C, 0x64,
0x4E00, 0xAC00, 0xFF45, 0x0103, 0x20, 0x33, 0x20, 0x33, 0x33, 0x33, 0x20,
0x33, 0x33, 0x33, 0x20, 0x48, 0x65, 0x6C, 0x6C, 0x6F};
for (uint32_t i = 0; i < out.Length(); i++) {
ASSERT_EQ(uout[i], expected[i]);
}
// Test that an unrecognized escape is passed through.
nsString out2;
nsTextFormatter::ssprintf(out2, u"%1m!", 23);
EXPECT_STREQ("%1m!", NS_ConvertUTF16toUTF8(out2).get());
// Treat NULL the same in both %s cases.
nsTextFormatter::ssprintf(out2, u"%s %S", (char*)nullptr, (char16_t*)nullptr);
EXPECT_STREQ("(null) (null)", NS_ConvertUTF16toUTF8(out2).get());
nsTextFormatter::ssprintf(out2, u"%lld", INT64_MIN);
EXPECT_STREQ("-9223372036854775808", NS_ConvertUTF16toUTF8(out2).get());
// Regression test for bug 1401821.
nsTextFormatter::ssprintf(out2, u"%*.f", 0, 23.2);
EXPECT_STREQ("23", NS_ConvertUTF16toUTF8(out2).get());
}
Minimal test - lines (123, 139)
path: .spaces[3].metrics.halstead.time
old: 5.765719364395496
new: 310.2491292154649
path: .spaces[3].metrics.halstead.length
old: 15.0
new: 116.0
path: .spaces[3].metrics.halstead.N2
old: 7.0
new: 51.0
path: .spaces[3].metrics.halstead.effort
old: 103.78294855911892
new: 5584.4843258783685
path: .spaces[3].metrics.halstead.estimated_program_length
old: 27.651484454403228
new: 89.138352755659
path: .spaces[3].metrics.halstead.n2
old: 7.0
new: 17.0
path: .spaces[3].metrics.halstead.vocabulary
old: 11.0
new: 24.0
path: .spaces[3].metrics.halstead.bugs
old: 0.007361439526411013
new: 0.10492221801530864
path: .spaces[3].metrics.halstead.purity_ratio
old: 1.8434322969602153
new: 0.768434075479819
path: .spaces[3].metrics.halstead.N1
old: 8.0
new: 65.0
path: .spaces[3].metrics.halstead.level
old: 0.5
new: 0.09523809523809525
path: .spaces[3].metrics.halstead.difficulty
old: 2.0
new: 10.5
path: .spaces[3].metrics.halstead.n1
old: 4.0
new: 7.0
path: .spaces[3].metrics.halstead.volume
old: 51.89147427955946
new: 531.8556500836542
path: .spaces[3].metrics.mi.mi_sei
old: 123.14513831425162
new: 75.81546701388919
path: .spaces[3].metrics.mi.mi_original
old: 114.63935842319393
new: 92.23480881219751
path: .spaces[3].metrics.mi.mi_visual_studio
old: 67.04056048139995
new: 53.938484685495624
path: .spaces[3].metrics.nargs.average
old: null
new: 2.0
path: .spaces[3].metrics.nargs.sum
old: 0.0
new: 2.0
path: .spaces[3].metrics.cognitive.average
old: null
new: 0.0
path: .spaces[3].metrics.nom.functions
old: 0.0
new: 1.0
path: .spaces[3].metrics.nom.total
old: 0.0
new: 1.0
path: .spaces[3].metrics.loc.cloc
old: 2.0
new: 1.0
path: .spaces[3].metrics.loc.lloc
old: 0.0
new: 10.0
path: .spaces[3].metrics.loc.blank
old: 2.0
new: 0.0
path: .spaces[3].metrics.loc.ploc
old: 5.0
new: 16.0
path: .spaces[3].metrics.loc.sloc
old: 9.0
new: 17.0
path: .spaces[3].metrics.nexits.average
old: null
new: 0.0
Code
TEST(TextFormatterTestMismatch, format_u)
{
nsString out;
nsTextFormatter::ssprintf(out, u"%u", int(-1));
EXPECT_STREQ("4294967295", NS_ConvertUTF16toUTF8(out).get());
// just for completeness, this is our format, and works
nsTextFormatter::ssprintf(out, u"%u", uint32_t(-1));
EXPECT_STREQ("4294967295", NS_ConvertUTF16toUTF8(out).get());
#ifndef DEBUG
nsTextFormatter::ssprintf(out, u"%u", float(3.5));
EXPECT_STREQ("3.5", NS_ConvertUTF16toUTF8(out).get());
nsTextFormatter::ssprintf(out, u"%u", "foo");
EXPECT_STREQ("foo", NS_ConvertUTF16toUTF8(out).get());
nsTextFormatter::ssprintf(out, u"%u", u"foo");
EXPECT_STREQ("foo", NS_ConvertUTF16toUTF8(out).get());
#endif
}
Minimal test - lines (53, 99)
path: .spaces[1].metrics.cognitive.average
old: null
new: 0.0
path: .spaces[1].metrics.nargs.sum
old: 0.0
new: 2.0
path: .spaces[1].metrics.nargs.average
old: null
new: 2.0
path: .spaces[1].metrics.nom.total
old: 0.0
new: 1.0
path: .spaces[1].metrics.nom.functions
old: 0.0
new: 1.0
path: .spaces[1].metrics.loc.blank
old: 0.0
new: 7.0
path: .spaces[1].metrics.loc.sloc
old: 1.0
new: 47.0
path: .spaces[1].metrics.loc.cloc
old: 0.0
new: 11.0
path: .spaces[1].metrics.loc.lloc
old: 0.0
new: 18.0
path: .spaces[1].metrics.loc.ploc
old: 1.0
new: 29.0
path: .spaces[1].metrics.halstead.n2
old: 1.0
new: 33.0
path: .spaces[1].metrics.halstead.N2
old: 1.0
new: 107.0
path: .spaces[1].metrics.halstead.effort
old: 0.0
new: 18804.236379916532
path: .spaces[1].metrics.halstead.bugs
old: 0.0
new: 0.2357124633401841
path: .spaces[1].metrics.halstead.N1
old: 0.0
new: 132.0
path: .spaces[1].metrics.halstead.estimated_program_length
old: null
new: 194.9943309518098
path: .spaces[1].metrics.halstead.purity_ratio
old: null
new: 0.8158758617230535
path: .spaces[1].metrics.halstead.difficulty
old: 0.0
new: 14.590909090909092
path: .spaces[1].metrics.halstead.level
old: null
new: 0.06853582554517133
path: .spaces[1].metrics.halstead.time
old: 0.0
new: 1044.6797988842518
path: .spaces[1].metrics.halstead.n1
old: 0.0
new: 9.0
path: .spaces[1].metrics.halstead.length
old: 1.0
new: 239.0
path: .spaces[1].metrics.halstead.volume
old: 0.0
new: 1288.7638640441237
path: .spaces[1].metrics.halstead.vocabulary
old: 1.0
new: 42.0
path: .spaces[1].metrics.nexits.average
old: null
new: 0.0
path: .spaces[1].metrics.mi.mi_sei
old: null
new: 61.122911456090506
path: .spaces[1].metrics.mi.mi_original
old: null
new: 71.15812712860084
path: .spaces[1].metrics.mi.mi_visual_studio
old: null
new: 41.61293984128704
Code
TEST(TextFormatterOrdering, orders)
{
nsString out;
// plain list
nsTextFormatter::ssprintf(out, u"%S %S %S", u"1", u"2", u"3");
EXPECT_STREQ("1 2 3", NS_ConvertUTF16toUTF8(out).get());
// ordered list
nsTextFormatter::ssprintf(out, u"%2$S %3$S %1$S", u"1", u"2", u"3");
EXPECT_STREQ("2 3 1", NS_ConvertUTF16toUTF8(out).get());
// Mixed ordered list and non-ordered does not work. This shouldn't
// crash (hence the calls to ssprintf) but should fail for for
// snprintf.
nsTextFormatter::ssprintf(out, u"%2S %S %1$S", u"1", u"2", u"3");
nsTextFormatter::ssprintf(out, u"%S %2$S", u"1", u"2");
char16_t buffer[1024]; // plenty big
EXPECT_EQ(nsTextFormatter::snprintf(buffer, sizeof(buffer), u"%2S %S %1$S",
u"1", u"2", u"3"),
uint32_t(-1));
EXPECT_EQ(
nsTextFormatter::snprintf(buffer, sizeof(buffer), u"%S %2$S", u"1", u"2"),
uint32_t(-1));
// Referencing an extra param returns empty strings in release.
#ifndef DEBUG
nsTextFormatter::ssprintf(out, u" %2$S ", u"1");
EXPECT_STREQ(" ", NS_ConvertUTF16toUTF8(out).get());
#endif
// Double referencing existing argument works
nsTextFormatter::ssprintf(out, u"%1$S %1$S", u"1");
EXPECT_STREQ("1 1", NS_ConvertUTF16toUTF8(out).get());
// Dropping trailing argument works
nsTextFormatter::ssprintf(out, u" %1$S ", u"1", u"2");
EXPECT_STREQ(" 1 ", NS_ConvertUTF16toUTF8(out).get());
// Dropping leading arguments works
nsTextFormatter::ssprintf(out, u" %2$S ", u"1", u"2");
EXPECT_STREQ(" 2 ", NS_ConvertUTF16toUTF8(out).get());
// Dropping middle arguments works
nsTextFormatter::ssprintf(out, u" %3$S %1$S ", u"1", u"2", u"3");
EXPECT_STREQ(" 3 1 ", NS_ConvertUTF16toUTF8(out).get());
}