blob: 65f77f2c42dbd41074bca3ade44849d9e5b8a87a [file] [log] [blame]
Jens Geyer0e87c462013-06-18 22:25:07 +02001/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20package thrift
21
22import (
Jens Geyer31aebbe2013-11-04 22:17:48 +010023 "bytes"
Jens Geyer0e87c462013-06-18 22:25:07 +020024 "testing"
25)
26
27func TestReadWriteCompactProtocol(t *testing.T) {
28 ReadWriteProtocolTest(t, NewTCompactProtocolFactory())
Vyacheslav Kulakov6e29b192018-08-31 13:42:50 +030029
D. Can Celasun8da0e722017-06-02 14:33:32 +020030 transports := []TTransport{
31 NewTMemoryBuffer(),
32 NewStreamTransportRW(bytes.NewBuffer(make([]byte, 0, 16384))),
33 NewTFramedTransport(NewTMemoryBuffer()),
34 }
Vyacheslav Kulakov6e29b192018-08-31 13:42:50 +030035
36 zlib0, _ := NewTZlibTransport(NewTMemoryBuffer(), 0)
37 zlib6, _ := NewTZlibTransport(NewTMemoryBuffer(), 6)
38 zlib9, _ := NewTZlibTransport(NewTFramedTransport(NewTMemoryBuffer()), 9)
39 transports = append(transports, zlib0, zlib6, zlib9)
40
D. Can Celasun8da0e722017-06-02 14:33:32 +020041 for _, trans := range transports {
42 p := NewTCompactProtocol(trans)
43 ReadWriteBool(t, p, trans)
44 p = NewTCompactProtocol(trans)
45 ReadWriteByte(t, p, trans)
46 p = NewTCompactProtocol(trans)
47 ReadWriteI16(t, p, trans)
48 p = NewTCompactProtocol(trans)
49 ReadWriteI32(t, p, trans)
50 p = NewTCompactProtocol(trans)
51 ReadWriteI64(t, p, trans)
52 p = NewTCompactProtocol(trans)
53 ReadWriteDouble(t, p, trans)
54 p = NewTCompactProtocol(trans)
55 ReadWriteString(t, p, trans)
56 p = NewTCompactProtocol(trans)
57 ReadWriteBinary(t, p, trans)
58 trans.Close()
59 }
Jens Geyer0e87c462013-06-18 22:25:07 +020060}