Skip to content
Snippets Groups Projects
Commit e4caab20 authored by Josh Brooks's avatar Josh Brooks
Browse files

Test clean up

parent 6cf058a4
No related branches found
No related tags found
4 merge requests!510Release,!227Have all Params objects adhere to json.Marshaler/Unmarshaler,!226WIP: Api2.0,!207WIP: Client Restructure
...@@ -40,6 +40,8 @@ func TestParams_MarshalUnmarshal(t *testing.T) { ...@@ -40,6 +40,8 @@ func TestParams_MarshalUnmarshal(t *testing.T) {
t.Fatalf("Marshal error: %v", err) t.Fatalf("Marshal error: %v", err)
} }
t.Logf("%s", string(data2))
// Check that they match (it is done this way to avoid // Check that they match (it is done this way to avoid
// false failures with the reflect.DeepEqual function and // false failures with the reflect.DeepEqual function and
// pointers) // pointers)
......
...@@ -18,7 +18,7 @@ import ( ...@@ -18,7 +18,7 @@ import (
// Tests that no data is lost when marshaling and // Tests that no data is lost when marshaling and
// unmarshaling the Params object. // unmarshaling the Params object.
func TestParams_MarshalJSON(t *testing.T) { func TestParams_MarshalUnmarshal(t *testing.T) {
// Construct a set of params // Construct a set of params
p := GetDefaultParams() p := GetDefaultParams()
...@@ -43,6 +43,8 @@ func TestParams_MarshalJSON(t *testing.T) { ...@@ -43,6 +43,8 @@ func TestParams_MarshalJSON(t *testing.T) {
t.Fatalf("Marshal error: %v", err) t.Fatalf("Marshal error: %v", err)
} }
t.Logf("%s", string(data2))
// Check that they match (it is done this way to avoid // Check that they match (it is done this way to avoid
// false failures with the reflect.DeepEqual function and // false failures with the reflect.DeepEqual function and
// pointers) // pointers)
......
////////////////////////////////////////////////////////////////////////////////
// Copyright © 2020 xx network SEZC //
// //
// Use of this source code is governed by a license that can be found in the //
// LICENSE file //
////////////////////////////////////////////////////////////////////////////////
package connect
import (
"bytes"
"encoding/json"
"testing"
)
func TestParams_MarshalUnmarshal(t *testing.T) {
// Construct a set of params
p := GetDefaultParams()
// Marshal the params
data, err := json.Marshal(&p)
if err != nil {
t.Fatalf("Marshal error: %v", err)
}
t.Logf("%s", string(data))
// Unmarshal the params object
received := Params{}
err = json.Unmarshal(data, &received)
if err != nil {
t.Fatalf("Unmarshal error: %v", err)
}
// Re-marshal this params object
data2, err := json.Marshal(received)
if err != nil {
t.Fatalf("Marshal error: %v", err)
}
t.Logf("%s", string(data2))
// Check that they match (it is done this way to avoid
// false failures with the reflect.DeepEqual function and
// pointers)
if !bytes.Equal(data, data2) {
t.Fatalf("Data was lost in marshal/unmarshal.")
}
}
...@@ -17,7 +17,7 @@ import ( ...@@ -17,7 +17,7 @@ import (
// Tests that no data is lost when marshaling and // Tests that no data is lost when marshaling and
// unmarshaling the Params object. // unmarshaling the Params object.
func TestParams_MarshalJSON(t *testing.T) { func TestParams_MarshalUnmarshal(t *testing.T) {
// Construct a set of params // Construct a set of params
p := DefaultParams() p := DefaultParams()
...@@ -42,6 +42,8 @@ func TestParams_MarshalJSON(t *testing.T) { ...@@ -42,6 +42,8 @@ func TestParams_MarshalJSON(t *testing.T) {
t.Fatalf("Marshal error: %v", err) t.Fatalf("Marshal error: %v", err)
} }
t.Logf("%s", string(data2))
// Check that they match (it is done this way to avoid // Check that they match (it is done this way to avoid
// false failures with the reflect.DeepEqual function and // false failures with the reflect.DeepEqual function and
// pointers) // pointers)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment