From d9b2f2a45dc400f1c0011b969cd6e85479d39a72 Mon Sep 17 00:00:00 2001 From: Gorbunov Kirill Andreevich Date: Mon, 16 Sep 2024 14:48:47 +0300 Subject: [PATCH] #347 add test --- util/sort/sort_test.go | 60 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 util/sort/sort_test.go diff --git a/util/sort/sort_test.go b/util/sort/sort_test.go new file mode 100644 index 00000000..2c85bcd1 --- /dev/null +++ b/util/sort/sort_test.go @@ -0,0 +1,60 @@ +package sort + +import ( + "reflect" + "testing" +) + +func TestUniq(t *testing.T) { + type args struct { + labels []interface{} + } + + tests := []struct { + name string + args args + want []interface{} + }{ + { + name: "test#1", + args: args{ + labels: append(make([]interface{}, 0), "test-1", 1, "test-2", 2), + }, + want: append(make([]interface{}, 0), "test-1", 1, "test-2", 2), + }, + { + name: "test#2", + args: args{ + labels: append(make([]interface{}, 0), "test-1", 1, "test-2", 2, "test-2", 2), + }, + want: append(make([]interface{}, 0), "test-1", 1, "test-2", 2), + }, + { + name: "test#3", + args: args{ + labels: append(make([]interface{}, 0), "test-1", 1, "test-2", 2, "test-2", 3), + }, + want: append(make([]interface{}, 0), "test-1", 1, "test-2", 3), + }, + { + name: "test#4", + args: args{ + labels: append(make([]interface{}, 0), + "test-1", 1, "test-1", 2, + "test-2", 3, "test-2", 2, + "test-3", 5, "test-3", 3, + "test-1", 4, "test-1", 1), + }, + want: append(make([]interface{}, 0), "test-1", 1, "test-2", 2, "test-3", 3), + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + var got []interface{} + if got = Uniq(tt.args.labels); !reflect.DeepEqual(got, tt.want) { + t.Errorf("Uniq() = %v, want %v", got, tt.want) + } + t.Logf("got-%#v", got) + }) + } +} -- 2.45.2