forked from bsm/openrtb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pmp_test.go
38 lines (33 loc) · 886 Bytes
/
pmp_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package openrtb_test
import (
"bytes"
"reflect"
"testing"
. "github.com/bsm/openrtb/v3"
"github.com/bytedance/sonic"
)
func TestPMP(t *testing.T) {
var subject *PMP
if err := fixture("pmp", &subject); err != nil {
t.Fatalf("expected no error, got %v", err)
}
exp := &PMP{
Private: 1,
Deals: []Deal{
{ID: "DX-1985-010A", BidFloor: 2.5, BidFloorCurrency: "", AuctionType: 2},
{ID: "DX-1986-010A", BidFloor: 2.6, BidFloorCurrency: "", AuctionType: 2},
},
}
if got := subject; !reflect.DeepEqual(exp, got) {
t.Errorf("expected %+v, got %+v", exp, got)
}
}
func TestPMP_MarshalJSON(t *testing.T) {
subject := &PMP{Deals: []Deal{{}}}
exp := []byte(`{"deals":[{"at":2}]}`)
if got, err := sonic.Marshal(subject); err != nil {
t.Fatalf("expected no error, got %v", err)
} else if !bytes.Equal(exp, got) {
t.Errorf("expected %+v, got %+v", exp, got)
}
}