X-Git-Url: https://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=tools%2Fccanlint%2Ftests%2Frun-coverage.c;h=7f2b3c24a0f7766d49d322d892ce3d83723c0a8e;hp=a526d55e8237cf4ed58afac49cc30d208a1a5d20;hb=fcf6cedb90d4a39bb0876abc597c82580a16ec43;hpb=ab3df365ce9bcd76379cda8d3a7c188baa3e0a05 diff --git a/tools/ccanlint/tests/run-coverage.c b/tools/ccanlint/tests/run-coverage.c index a526d55e..7f2b3c24 100644 --- a/tools/ccanlint/tests/run-coverage.c +++ b/tools/ccanlint/tests/run-coverage.c @@ -32,12 +32,16 @@ static bool find_source_file(const struct manifest *m, const char *filename) return false; } -/* 1 point for 50%, 2 points for 75%, 3 points for 87.5%... */ +/* 1 point for 50%, 2 points for 75%, 3 points for 87.5%... Bonus for 100%. */ static unsigned int score_coverage(float covered, unsigned total) { float thresh, uncovered = 1.0 - covered; unsigned int i; + if (covered == 1.0) + return total; + + total--; for (i = 0, thresh = 0.5; i < total; i++, thresh /= 2) { if (uncovered > thresh) break; @@ -112,7 +116,7 @@ static void analyze_coverage(struct manifest *m, bool full_gcov, if (total_lines == 0) score->total = score->score = 0; else { - score->total = 5; + score->total = 6; score->score = score_coverage(covered_lines / total_lines, score->total); }