Skip to content

Commit

Permalink
add func: bnc.SimpleKline.NotExist
Browse files Browse the repository at this point in the history
  • Loading branch information
dwdwow committed Mar 2, 2024
1 parent e231ed5 commit cbb98f5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions bnc/kline.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ func NewSimpleKlineFromRaw(k RawKline) (kline SimpleKline, err error) {
return kline, nil
}

func (k SimpleKline) NotExist() bool {
return k[0] == 0
}

func (k SimpleKline) OpenTime() int64 {
return int64(k[0])
}
Expand Down
11 changes: 11 additions & 0 deletions bnc/kline_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,14 @@ func TestNewSimpleKline(t *testing.T) {
}

}

func TestSimpleKline_NotExist(t *testing.T) {
kline := SimpleKline{1}
if kline.NotExist() {
t.FailNow()
}
kline[0] = 0
if !kline.NotExist() {
t.FailNow()
}
}

0 comments on commit cbb98f5

Please sign in to comment.