Ring CRDT for IP Allocation Management
The basic data structure used to share information about IP allocations between peers
This commit is contained in:
1 parent
c158b86dc6
commit
4f3dcf8dc9
6 files changed
+1471
No files matched your search
@@ -40,12 +40,29 @@ func AssertNoErr(t *testing.T, err error) {
|
||||
}
|
||||
}
|
||||
|
||||
func AssertBool(t *testing.T, got, wanted bool, desc string) {
|
||||
if got != wanted {
|
||||
Fatalf(t, "Expected %s %t but got %t", desc, wanted, got)
|
||||
}
|
||||
}
|
||||
|
||||
func AssertEqualUint32(t *testing.T, got, wanted uint32, desc string) {
|
||||
if got != wanted {
|
||||
Fatalf(t, "Expected %s %d but got %d", desc, wanted, got)
|
||||
}
|
||||
}
|
||||
|
||||
func AssertEqualuint64(t *testing.T, got, wanted uint64, desc string) {
|
||||
if got != wanted {
|
||||
Fatalf(t, "Expected %s %d but got %d", desc, wanted, got)
|
||||
}
|
||||
}
|
||||
|
||||
func AssertEqualInt64(t *testing.T, got, wanted int64, desc string) {
|
||||
if got != wanted {
|
||||
Fatalf(t, "Expected %s %d but got %d", desc, wanted, got)
|
||||
}
|
||||
}
|
||||
func AssertEqualInt(t *testing.T, got, wanted int, desc string) {
|
||||
if got != wanted {
|
||||
Fatalf(t, "Expected %s %d but got %d", desc, wanted, got)
|
||||
@@ -64,6 +81,18 @@ func AssertEqualString(t *testing.T, got, wanted string, desc string) {
|
||||
}
|
||||
}
|
||||
|
||||
func AssertNotEqualString(t *testing.T, got, wanted string, desc string) {
|
||||
if got == wanted {
|
||||
Fatalf(t, "Expected %s unlike '%s'", desc, wanted)
|
||||
}
|
||||
}
|
||||
|
||||
func AssertEquals(t *testing.T, a1, a2 interface{}) {
|
||||
if !reflect.DeepEqual(a1, a2) {
|
||||
Fatalf(t, "Expected %+v == %+v", a1, a2)
|
||||
}
|
||||
}
|
||||
|
||||
func AssertStatus(t *testing.T, got int, wanted int, desc string) {
|
||||
if got != wanted {
|
||||
Fatalf(t, "Expected %s %d but got %d", desc, wanted, got)
|
||||
@@ -72,6 +101,9 @@ func AssertStatus(t *testing.T, got int, wanted int, desc string) {
|
||||
|
||||
func AssertErrorInterface(t *testing.T, got interface{}, wanted interface{}, desc string) {
|
||||
gotT, wantedT := reflect.TypeOf(got), reflect.TypeOf(wanted).Elem()
|
||||
if got == nil {
|
||||
Fatalf(t, "Expected %s but got nil (%s)", wantedT.String(), desc)
|
||||
}
|
||||
if !gotT.Implements(wantedT) {
|
||||
Fatalf(t, "Expected %s but got %s (%s)", wantedT.String(), gotT.String(), desc)
|
||||
}
|
||||
@@ -79,6 +111,9 @@ func AssertErrorInterface(t *testing.T, got interface{}, wanted interface{}, des
|
||||
|
||||
func AssertErrorType(t *testing.T, got interface{}, wanted interface{}, desc string) {
|
||||
gotT, wantedT := reflect.TypeOf(got), reflect.TypeOf(wanted).Elem()
|
||||
if got == nil {
|
||||
Fatalf(t, "Expected %s but got nil (%s)", wantedT.String(), desc)
|
||||
}
|
||||
if gotT != wantedT {
|
||||
Fatalf(t, "Expected %s but got %s (%s)", wantedT.String(), gotT.String(), desc)
|
||||
}
|
||||
@@ -97,6 +132,26 @@ func AssertEmpty(t *testing.T, array interface{}, desc string) {
|
||||
}
|
||||
}
|
||||
|
||||
func AssertSuccess(t *testing.T, err error) {
|
||||
if err != nil {
|
||||
Fatalf(t, "Expected success, got '%s'", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
func AssertPanic(t *testing.T, f func()) {
|
||||
wrapper := func() (paniced bool) {
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
paniced = true
|
||||
}
|
||||
}()
|
||||
|
||||
f()
|
||||
return
|
||||
}
|
||||
AssertTrue(t, wrapper(), "Expected panic")
|
||||
}
|
||||
|
||||
// Like testing.Fatalf, but adds the stack trace of the current call
|
||||
func Fatalf(t *testing.T, format string, args ...interface{}) {
|
||||
t.Fatalf(format+"\n%s", append(args, StackTrace())...)
|
||||
|
||||
Reference in new issue
Block a user