Skip to content

Commit

Permalink
common/docs: Update SliceDifference and remove outdated steps from AD…
Browse files Browse the repository at this point in the history
…D_NEW_EXCHANGE.md
  • Loading branch information
thrasher- committed Aug 27, 2024
1 parent 9e9c92c commit 66f4770
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 39 deletions.
9 changes: 7 additions & 2 deletions common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,18 +137,23 @@ func NewHTTPClientWithTimeout(t time.Duration) *http.Client {

// SliceDifference returns the elements that are in slice1 or slice2 but not in both
func SliceDifference[T comparable](slice1, slice2 []T) []T {
var diff []T
diff := make([]T, 0, len(slice1)+len(slice2))
target := 0
for x := range slice1 {
if !slices.Contains(slice2, slice1[x]) {
diff = append(diff, slice1[x])
continue
}
slice1[target] = slice1[x]
target++
}
slice1 = slice1[:target]
for x := range slice2 {
if !slices.Contains(slice1, slice2[x]) {
diff = append(diff, slice2[x])
}
}
return diff
return slices.Clip(diff)
}

// StringSliceContains returns whether case sensitive needle is contained within haystack
Expand Down
37 changes: 0 additions & 37 deletions docs/ADD_NEW_EXCHANGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,43 +251,6 @@ var Exchanges = []string{
"yobit",
```
#### Increment the default number of supported exchanges in [config/config_test.go](../config/config_test.go):
```go
func TestGetEnabledExchanges(t *testing.T) {
cfg := GetConfig()
err := cfg.LoadConfig(TestFile, true)
if !errors.Is(err, errConfigDefineErrorExample) {
t.Errorf("received: '%v' but expected '%v'", err, errConfigDefineErrorExample)
}

exchanges := cfg.GetEnabledExchanges()
// modify the value of defaultEnabledExchanges at the top of the
// config_test.go file to match the total count of exchanges
if len(exchanges) != defaultEnabledExchanges {
t.Errorf("received: '%v' but expected '%v'", len(exchanges), defaultEnabledExchanges)
}

if !slices.Contains(exchanges, "Bitfinex") {
t.Errorf("received: '%v' but expected '%v'",
slices.Contains(exchanges, "Bitfinex"),
true)
}
}
```
#### Increment the number of supported exchanges in [the gctscript exchange wrapper test file](../gctscript/wrappers/gct/exchange/exchange_test.go):
```go
func TestExchange_Exchanges(t *testing.T) {
t.Parallel()
x := exchangeTest.Exchanges(false)
y := len(x)
expected := 28 // modify this value to match the total count of exchanges
if y != expected {
t.Fatalf("expected %v received %v", expected , y)
}
}
```
#### Setup and run the [documentation tool](../cmd/documentation):
- Create a new file named *exchangename*.tmpl
Expand Down

0 comments on commit 66f4770

Please sign in to comment.