1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
|
From: Mathias Gibbens <gibmat@debian.org>
Description: Fix test failure on 32bit architectures
Forwarded: https://github.com/ovn-org/libovsdb/issues/374
diff --git a/ovsdb/schema.go b/ovsdb/schema.go
index cf80aa5..4ce1c4a 100644
--- a/ovsdb/schema.go
+++ b/ovsdb/schema.go
@@ -173,7 +173,7 @@ type BaseType struct {
minReal *float64
maxReal *float64
minInteger *int
- maxInteger *int
+ maxInteger *int64
minLength *int
maxLength *int
refTable *string
@@ -224,14 +224,14 @@ func (b *BaseType) MinInteger() (int, error) {
// MaxInteger returns the minimum integer value
// RFC7047 specifies the minimum to be 2^63-1
-func (b *BaseType) MaxInteger() (int, error) {
+func (b *BaseType) MaxInteger() (int64, error) {
if b.Type != TypeInteger {
return 0, fmt.Errorf("%s is not an integer", b.Type)
}
if b.maxInteger != nil {
return *b.maxInteger, nil
}
- return int(math.Pow(2, 63)) - 1, nil
+ return int64(math.Pow(2, 63)) - 1, nil
}
// MinLength returns the minimum string length
@@ -302,7 +302,7 @@ func (b *BaseType) UnmarshalJSON(data []byte) error {
MinReal *float64 `json:"minReal,omitempty"`
MaxReal *float64 `json:"maxReal,omitempty"`
MinInteger *int `json:"minInteger,omitempty"`
- MaxInteger *int `json:"maxInteger,omitempty"`
+ MaxInteger *int64 `json:"maxInteger,omitempty"`
MinLength *int `json:"minLength,omitempty"`
MaxLength *int `json:"maxLength,omitempty"`
RefTable *string `json:"refTable,omitempty"`
@@ -346,7 +346,7 @@ func (b BaseType) MarshalJSON() ([]byte, error) {
MinReal *float64 `json:"minReal,omitempty"`
MaxReal *float64 `json:"maxReal,omitempty"`
MinInteger *int `json:"minInteger,omitempty"`
- MaxInteger *int `json:"maxInteger,omitempty"`
+ MaxInteger *int64 `json:"maxInteger,omitempty"`
MinLength *int `json:"minLength,omitempty"`
MaxLength *int `json:"maxLength,omitempty"`
RefTable *string `json:"refTable,omitempty"`
diff --git a/ovsdb/schema_test.go b/ovsdb/schema_test.go
index fae2549..f2d1228 100644
--- a/ovsdb/schema_test.go
+++ b/ovsdb/schema_test.go
@@ -409,7 +409,7 @@ func TestTable(t *testing.T) {
func TestBaseTypeMarshalUnmarshalJSON(t *testing.T) {
datapath := "Datapath"
zero := 0
- max := 4294967295
+ max := int64(4294967295)
strong := "strong"
tests := []struct {
name string
@@ -677,7 +677,7 @@ func TestColumnSchemaMarshalUnmarshalJSON(t *testing.T) {
func TestBaseTypeSimpleAtomic(t *testing.T) {
b := BaseType{Type: TypeString}
assert.True(t, b.simpleAtomic())
- max := 1024
+ max := int64(1024)
b1 := BaseType{Type: TypeInteger, maxInteger: &max}
assert.False(t, b1.simpleAtomic())
}
@@ -803,11 +803,11 @@ func TestBaseTypeMinInteger(t *testing.T) {
}
func TestBaseTypeMaxInteger(t *testing.T) {
- value := 1024
+ value := int64(1024)
tests := []struct {
name string
bt *BaseType
- want int
+ want int64
wantErr bool
}{
{
@@ -819,7 +819,7 @@ func TestBaseTypeMaxInteger(t *testing.T) {
{
"nil",
&BaseType{Type: TypeInteger},
- int(math.Pow(2, 63)) - 1,
+ int64(math.Pow(2, 63)) - 1,
false,
},
{
|