From 35fa23394ab0affde1e6dc20b0a19cb8d53d1e75 Mon Sep 17 00:00:00 2001 From: ionutboangiu Date: Thu, 4 Mar 2021 13:33:19 +0200 Subject: [PATCH] Test Sort for acc profiles in utils/accountprofile.go --- utils/accountprofile_test.go | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/utils/accountprofile_test.go b/utils/accountprofile_test.go index dae840489..8e47fd04f 100644 --- a/utils/accountprofile_test.go +++ b/utils/accountprofile_test.go @@ -371,7 +371,6 @@ func TestAPAccountBalancesBackup(t *testing.T) { t.Errorf("\ngot: <%+v>, \nwant: <%+v>", value, actPrf.Balances[key].Units.Big) } } - } func TestAPNewDefaultBalance(t *testing.T) { @@ -408,3 +407,34 @@ func TestAPNewDefaultBalance(t *testing.T) { t.Errorf("\nReceived: <%+v>,\nExpected: <%+v>", received, expected) } } + +func TestAPSort(t *testing.T) { + + apS := AccountProfilesWithWeight{ + { + Weight: 2, + }, + { + Weight: 1, + }, + { + Weight: 3, + }, + } + expected := AccountProfilesWithWeight{ + { + Weight: 3, + }, + { + Weight: 2, + }, + { + Weight: 1, + }, + } + + apS.Sort() + if !reflect.DeepEqual(apS, expected) { + t.Errorf("\nReceived: <%+v>, \nExpected: <%+v>", ToJSON(apS), ToJSON(expected)) + } +}