Jens Geyer | 0e87c46 | 2013-06-18 22:25:07 +0200 | [diff] [blame] | 1 | /* |
| 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 | |
| 20 | package thrift |
| 21 | |
| 22 | import ( |
Jens Geyer | 31aebbe | 2013-11-04 22:17:48 +0100 | [diff] [blame] | 23 | "bytes" |
Jens Geyer | 0e87c46 | 2013-06-18 22:25:07 +0200 | [diff] [blame] | 24 | "testing" |
| 25 | ) |
| 26 | |
| 27 | func TestReadWriteCompactProtocol(t *testing.T) { |
| 28 | ReadWriteProtocolTest(t, NewTCompactProtocolFactory()) |
Vyacheslav Kulakov | 6e29b19 | 2018-08-31 13:42:50 +0300 | [diff] [blame] | 29 | |
D. Can Celasun | 8da0e72 | 2017-06-02 14:33:32 +0200 | [diff] [blame] | 30 | transports := []TTransport{ |
| 31 | NewTMemoryBuffer(), |
| 32 | NewStreamTransportRW(bytes.NewBuffer(make([]byte, 0, 16384))), |
| 33 | NewTFramedTransport(NewTMemoryBuffer()), |
| 34 | } |
Vyacheslav Kulakov | 6e29b19 | 2018-08-31 13:42:50 +0300 | [diff] [blame] | 35 | |
| 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 Celasun | 8da0e72 | 2017-06-02 14:33:32 +0200 | [diff] [blame] | 41 | 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 Geyer | 0e87c46 | 2013-06-18 22:25:07 +0200 | [diff] [blame] | 60 | } |