From 4039bc1b0858c033700e67364657c1f3fa110401 Mon Sep 17 00:00:00 2001 From: Vuong <3168632+vuon9@users.noreply.github.com> Date: Sun, 30 Jan 2022 12:21:44 +0700 Subject: [PATCH] Improve test for readable purpose --- cointop/util_test.go | 86 ++++++++++++++++++++++---------------------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/cointop/util_test.go b/cointop/util_test.go index 449940f..9809640 100644 --- a/cointop/util_test.go +++ b/cointop/util_test.go @@ -3,35 +3,6 @@ package cointop import "testing" func Test_getStructHash(t *testing.T) { - type SCoin struct { - Name string - Properties struct { - P7D int - P10D int - } - } - type SCoin1 struct { - Name string - Properties struct { - P7D int - P10D int - } - } - type SCoin2 struct { - Name interface{} - Properties struct { - P7D int - P10D int - } - } - type SCoin3 struct { - Name string - Age int - Properties *struct { - P7D int - P10D int - } - } type args struct { str1 interface{} str2 interface{} @@ -45,32 +16,61 @@ func Test_getStructHash(t *testing.T) { { name: "the same structs", args: args{ - str1: SCoin{}, - str2: SCoin{}, - }, - want: true, - }, - { - name: "different structs but have similar fields", - args: args{ - str1: SCoin{}, - str2: SCoin1{}, + str1: struct { + Name string + Properties struct { + P7D int + P10D int + } + }{}, + str2: struct { + Name string + Properties struct { + P7D int + P10D int + } + }{}, }, want: true, }, { name: "different structs but have similar fields and different field type", args: args{ - str1: SCoin{}, - str2: SCoin2{}, + str1: struct { + Name string + Properties struct { + P7D int + P10D int + } + }{}, + str2: struct { + Name rune + Properties struct { + P7D int + P10D int + } + }{}, }, want: false, }, { name: "different structs and different fields", args: args{ - str1: SCoin{}, - str2: SCoin3{}, + str1: struct { + Name string + Properties struct { + P7D int + P10D int + } + }{}, + str2: struct { + Name string + Age int + Properties struct { + P7D int + P10D int + } + }{}, }, want: false, },