Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

set -e -x

go vet ./...
go test ./...
gofmt -w .
2 changes: 1 addition & 1 deletion gossip/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func NewFilter(N uint32, B uint32, maxFP float64) (*Filter, error) {
return nil, fmt.Errorf("number of bits (%d) must be a divisor of 8", B)
}
if maxFP <= 0 || maxFP >= 1 {
return nil, fmt.Errorf("max false positives must be 0 <= maxFP < 1:", maxFP)
return nil, fmt.Errorf("max false positives must be 0 <= maxFP < 1: %f", maxFP)
}
M, K := computeOptimalValues(N, maxFP)
maxCount := uint32((1 << B) - 1)
Expand Down
10 changes: 5 additions & 5 deletions gossip/filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,22 +104,22 @@ func TestSlots(t *testing.T) {
// Increment a slot and verify.
f.incrementSlot(0, 1)
if f.getSlot(0) != 1 {
t.Error("slot value %d != 1", f.getSlot(0))
t.Errorf("slot value %d != 1", f.getSlot(0))
}
// Increment past max count.
f.incrementSlot(0, int32(f.MaxCount))
if f.getSlot(0) != f.MaxCount {
t.Error("slot value should be max %d != %d", f.getSlot(0), f.MaxCount)
t.Errorf("slot value should be max %d != %d", f.getSlot(0), f.MaxCount)
}
// Decrement once.
f.incrementSlot(0, -1)
if f.getSlot(0) != f.MaxCount-1 {
t.Error("slot value should be max %d != %d", f.getSlot(0), f.MaxCount-1)
t.Errorf("slot value should be max %d != %d", f.getSlot(0), f.MaxCount-1)
}
// Decrement past 0.
f.incrementSlot(0, -int32(f.MaxCount))
if f.getSlot(0) != 0 {
t.Error("slot value should be max %d != 0", f.getSlot(0))
t.Errorf("slot value should be max %d != 0", f.getSlot(0))
}
}

Expand Down Expand Up @@ -181,7 +181,7 @@ func TestFalsePositives(t *testing.T) {
empFP := float64(countFP) / float64(1000)
diff := math.Abs(probFP - empFP)
if diff/probFP > 0.50 {
t.Errorf("measured P(FP) > 50% different from expected %f vs. %f", diff, empFP)
t.Errorf("measured P(FP) > 50%% different from expected %f vs. %f", diff, empFP)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

double percent?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in order to print an actual % within a Printf/Errorf, it must be escaped – http://play.golang.org/p/5ml2NQOWtn

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh right duh. didn't see you were trying to print a %-age value

}
}

Expand Down
8 changes: 8 additions & 0 deletions initrepo.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

# Create symlinks to all git hooks in your own .git dir.
echo "### Creating symlinks to our git hooks..."
for f in $(ls -d githooks/*)
do ln -s ../../$f .git/hooks
done && ls -al .git/hooks | grep githooks
echo ""