Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 316 lines (271 sloc) 12.282 kb
35bb363a »
2012-02-03 Generated protocol buffer code now lives in separate packages, the na…
1 ;;;; Copyright 2008 Google Inc. All Rights Reserved
2
3 ;;;; Redistribution and use in source and binary forms, with or without
4 ;;;; modification, are permitted provided that the following conditions are
5 ;;;; met:
6
7 ;;;; * Redistributions of source code must retain the above copyright
8 ;;;; notice, this list of conditions and the following disclaimer.
9 ;;;; * Redistributions in binary form must reproduce the above
10 ;;;; copyright notice, this list of conditions and the following disclaimer
11 ;;;; in the documentation and/or other materials provided with the
12 ;;;; distribution.
13 ;;;; * Neither the name of Google Inc. nor the names of its
14 ;;;; contributors may be used to endorse or promote products derived from
15 ;;;; this software without specific prior written permission.
16
17 ;;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 ;;;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 ;;;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 ;;;; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 ;;;; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 ;;;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 ;;;; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 ;;;; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 ;;;; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 ;;;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 ;;;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
29 ;;;; Author: brown@google.com (Robert Brown)
30
31 ;;;; Protobuf tests
5d1a4268 » Robert Brown
2008-09-30 Initial commit of Common Lisp protocol buffer project.
32
2364038c »
2011-09-28 Convert tests to Stefil.
33 (in-package #:common-lisp-user)
34
35 (defpackage #:proto-lisp-test
36 (:documentation "Test the Lisp implementation of protocol buffers.")
37 (:use #:common-lisp
38 #:com.google.base
819368cf »
2011-10-05 Use config packages. *protoc* and *protoc-gen-lisp* move from ASDF to
39 #:hu.dwim.stefil
40 #:protobuf-test-config)
2364038c »
2011-09-28 Convert tests to Stefil.
41 (:export #:test-proto-lisp))
5d1a4268 » Robert Brown
2008-09-30 Initial commit of Common Lisp protocol buffer project.
42
43 (in-package #:proto-lisp-test)
15b121b7 »
2011-03-15 Move base and varint code into separate directories with their own ASDF
44 (declaim #.*optimize-default*)
5d1a4268 » Robert Brown
2008-09-30 Initial commit of Common Lisp protocol buffer project.
45
2364038c »
2011-09-28 Convert tests to Stefil.
46 (defsuite (test-proto-lisp :in root-suite) ()
47 (run-child-tests))
48
49 (in-suite test-proto-lisp)
50
819368cf »
2011-10-05 Use config packages. *protoc* and *protoc-gen-lisp* move from ASDF to
51 (defconst +golden-file-name+ (merge-pathnames "golden" *base-directory*)
49dfce6c »
2010-06-19 Fix dependencies for protobuf-test. Add test-op methods
52 "Pathname of a file containing correct protocol buffer data.")
53
819368cf »
2011-10-05 Use config packages. *protoc* and *protoc-gen-lisp* move from ASDF to
54 (defconst +test-file-name+ (merge-pathnames "test-output-file" *base-directory*)
49dfce6c »
2010-06-19 Fix dependencies for protobuf-test. Add test-op methods
55 "Pathname of file to which we write protocol buffer data.")
5d1a4268 » Robert Brown
2008-09-30 Initial commit of Common Lisp protocol buffer project.
56
35bb363a »
2012-02-03 Generated protocol buffer code now lives in separate packages, the na…
57 (defun verify-string-field (string-field expected)
58 (is (string= (pb:string-value string-field) expected))
59 (is (equalp (pb:utf8-string-value string-field) (string-to-utf8-octets expected))))
5d1a4268 » Robert Brown
2008-09-30 Initial commit of Common Lisp protocol buffer project.
60
2364038c »
2011-09-28 Convert tests to Stefil.
61 (deftest correctness-tests ()
5d1a4268 » Robert Brown
2008-09-30 Initial commit of Common Lisp protocol buffer project.
62 ;; Check that required strings are cleared by CLEAR.
35bb363a »
2012-02-03 Generated protocol buffer code now lives in separate packages, the na…
63 (let ((p (make-instance 'pb:test-protocol)))
64 (verify-string-field (pb:zero p) "")
65 (setf (pb:zero p) (pb:string-field "x"))
66 (verify-string-field (pb:zero p) "x")
5d1a4268 » Robert Brown
2008-09-30 Initial commit of Common Lisp protocol buffer project.
67 (pb:clear p)
35bb363a »
2012-02-03 Generated protocol buffer code now lives in separate packages, the na…
68 (verify-string-field (pb:zero p) ""))
5d1a4268 » Robert Brown
2008-09-30 Initial commit of Common Lisp protocol buffer project.
69
70 ;; Check that optional strings are set to their default value by CLEAR.
35bb363a »
2012-02-03 Generated protocol buffer code now lives in separate packages, the na…
71 (let ((p (make-instance 'pb:test-protocol)))
72 (verify-string-field (pb:opt-string p) "opt")
73 (setf (pb:opt-string p) (pb:string-field "x"))
74 (verify-string-field (pb:opt-string p) "x")
5d1a4268 » Robert Brown
2008-09-30 Initial commit of Common Lisp protocol buffer project.
75 (pb:clear p)
35bb363a »
2012-02-03 Generated protocol buffer code now lives in separate packages, the na…
76 (verify-string-field (pb:opt-string p) "opt")
77 (setf (pb:opt-string p) (pb:string-field "x"))
5d1a4268 » Robert Brown
2008-09-30 Initial commit of Common Lisp protocol buffer project.
78 (pb:clear p)
35bb363a »
2012-02-03 Generated protocol buffer code now lives in separate packages, the na…
79 (verify-string-field (pb:opt-string p) "opt")
80 (setf (pb:opt-string p) (pb:string-field "x"))
81 (pb:clear-opt-string p)
82 (verify-string-field (pb:opt-string p) "opt"))
5d1a4268 » Robert Brown
2008-09-30 Initial commit of Common Lisp protocol buffer project.
83 (values))
84
2364038c »
2011-09-28 Convert tests to Stefil.
85 (deftest test-pb-write ()
35bb363a »
2012-02-03 Generated protocol buffer code now lives in separate packages, the na…
86 (let ((p (make-instance 'pb:test1proto)))
5d1a4268 » Robert Brown
2008-09-30 Initial commit of Common Lisp protocol buffer project.
87 ;; verify enum values
35bb363a »
2012-02-03 Generated protocol buffer code now lives in separate packages, the na…
88 (is (= pb:+test1proto-enum-code-foo+ 0))
89 (is (= pb:+test1proto-enum-code-bar+ 1))
90 (is (= pb:+test1proto-enum-code-baz+ 2))
5d1a4268 » Robert Brown
2008-09-30 Initial commit of Common Lisp protocol buffer project.
91
92 ;; default settings
2364038c »
2011-09-28 Convert tests to Stefil.
93 (is (= (pb:d-int32 p) 12))
35bb363a »
2012-02-03 Generated protocol buffer code now lives in separate packages, the na…
94 (verify-string-field (pb:d-string p) "foo")
2364038c »
2011-09-28 Convert tests to Stefil.
95 (is (eq (pb:d-bool p) t))
5d1a4268 » Robert Brown
2008-09-30 Initial commit of Common Lisp protocol buffer project.
96
97 ;; test is-initialized
2364038c »
2011-09-28 Convert tests to Stefil.
98 (is (not (pb:is-initialized p)))
52cbe24a » Robert Brown
2009-12-28 The test that serializes a protocol buffer to octets now works.
99 (setf (pb:o-a p) 20)
2364038c »
2011-09-28 Convert tests to Stefil.
100 (is (pb:is-initialized p))
5d1a4268 » Robert Brown
2008-09-30 Initial commit of Common Lisp protocol buffer project.
101
102 ;; unrepeated things
52cbe24a » Robert Brown
2009-12-28 The test that serializes a protocol buffer to octets now works.
103 (setf (pb:u-int32 p) 20)
104 (setf (pb:u-int64 p) -20)
105 (setf (pb:u-uint64 p) 12345678900)
106 (setf (pb:u-fixed32 p) 100)
107 (setf (pb:u-fixed64 p) 12345678900)
108 (setf (pb:u-bool p) t)
109 (setf (pb:u-float p) 3.14159f0)
110 (setf (pb:u-double p) 3.14159265d0)
35bb363a »
2012-02-03 Generated protocol buffer code now lives in separate packages, the na…
111 (setf (pb:u-string p) (pb:string-field "foo"))
112 (setf (pb:u-vardata p) (pb:string-field "bar"))
52cbe24a » Robert Brown
2009-12-28 The test that serializes a protocol buffer to octets now works.
113 (setf (pb:foo (pb:u-msg p)) 12)
5d1a4268 » Robert Brown
2008-09-30 Initial commit of Common Lisp protocol buffer project.
114
115 ;; repeated things
52cbe24a » Robert Brown
2009-12-28 The test that serializes a protocol buffer to octets now works.
116 (vector-push-extend -20 (pb:r-int32 p))
117 (vector-push-extend -30 (pb:r-int32 p))
118 (vector-push-extend 20 (pb:r-int64 p))
119 (vector-push-extend 30 (pb:r-int64 p))
120 (vector-push-extend 12345678900 (pb:r-uint64 p))
121 (vector-push-extend 98765432100 (pb:r-uint64 p))
122 (vector-push-extend 12345 (pb:r-fixed32 p))
123 (vector-push-extend 23456 (pb:r-fixed32 p))
124 (vector-push-extend 12345678900 (pb:r-fixed64 p))
125 (vector-push-extend 98765432100 (pb:r-fixed64 p))
126 (vector-push-extend nil (pb:r-bool p))
127 (vector-push-extend t (pb:r-bool p))
128 (vector-push-extend 1.5f0 (pb:r-float p))
129 (vector-push-extend -1.75f0 (pb:r-float p))
130 (vector-push-extend 3.3d0 (pb:r-double p))
131 (vector-push-extend -1.2d0 (pb:r-double p))
35bb363a »
2012-02-03 Generated protocol buffer code now lives in separate packages, the na…
132 (vector-push-extend (pb:string-field "foo") (pb:r-string p))
133 (vector-push-extend (pb:string-field "bar") (pb:r-string p))
134 (vector-push-extend (pb:string-field "ping") (pb:r-vardata p))
135 (vector-push-extend (pb:string-field "pong") (pb:r-vardata p))
52cbe24a » Robert Brown
2009-12-28 The test that serializes a protocol buffer to octets now works.
136
35bb363a »
2012-02-03 Generated protocol buffer code now lives in separate packages, the na…
137 (let ((x (make-instance 'pb:test1msg))
138 (y (make-instance 'pb:test1msg)))
5d1a4268 » Robert Brown
2008-09-30 Initial commit of Common Lisp protocol buffer project.
139 (setf (pb:foo x) 12)
140 (setf (pb:foo y) 13)
52cbe24a » Robert Brown
2009-12-28 The test that serializes a protocol buffer to octets now works.
141 (vector-push-extend x (pb:r-msg p))
142 (vector-push-extend y (pb:r-msg p)))
5d1a4268 » Robert Brown
2008-09-30 Initial commit of Common Lisp protocol buffer project.
143
35bb363a »
2012-02-03 Generated protocol buffer code now lives in separate packages, the na…
144 (let ((x (make-instance 'pb:test1proto-test-group1))
145 (y (make-instance 'pb:test1proto-test-group2))
146 (z (make-instance 'pb:test1proto-test-group2)))
5d1a4268 » Robert Brown
2008-09-30 Initial commit of Common Lisp protocol buffer project.
147 (setf (pb:a x) 80)
148 (setf (pb:b y) 100)
149 (setf (pb:b z) 130)
35bb363a »
2012-02-03 Generated protocol buffer code now lives in separate packages, the na…
150 (vector-push-extend x (pb:test-group1 p))
151 (vector-push-extend y (pb:test-group2 p))
152 (vector-push-extend z (pb:test-group2 p)))
5d1a4268 » Robert Brown
2008-09-30 Initial commit of Common Lisp protocol buffer project.
153
154 ;; int32 tests
155 (loop for x in (list (1- (ash 1 31)) (- (ash 1 31)) 1 0 -1)
52cbe24a » Robert Brown
2009-12-28 The test that serializes a protocol buffer to octets now works.
156 do (vector-push-extend x (pb:r-int32 p)))
5d1a4268 » Robert Brown
2008-09-30 Initial commit of Common Lisp protocol buffer project.
157
158 ;; int64 tests
159 (loop for x in (list (1- (ash 1 63)) (- (ash 1 63)) 1 0 -1)
52cbe24a » Robert Brown
2009-12-28 The test that serializes a protocol buffer to octets now works.
160 do (vector-push-extend x (pb:r-int64 p)))
5d1a4268 » Robert Brown
2008-09-30 Initial commit of Common Lisp protocol buffer project.
161
162 ;; fixed32 tests
52cbe24a » Robert Brown
2009-12-28 The test that serializes a protocol buffer to octets now works.
163 (loop for x in (list #xffffffff (1- (ash 1 31)) 0 1)
164 do (vector-push-extend x (pb:r-fixed32 p)))
5d1a4268 » Robert Brown
2008-09-30 Initial commit of Common Lisp protocol buffer project.
165
166 ;; fixed64 tests
52cbe24a » Robert Brown
2009-12-28 The test that serializes a protocol buffer to octets now works.
167 (loop for x in (list #xffffffffffffffff (1- (ash 1 63)) 0 1)
168 do (vector-push-extend x (pb:r-fixed64 p)))
5d1a4268 » Robert Brown
2008-09-30 Initial commit of Common Lisp protocol buffer project.
169
170 ;; uint64 tests
171 (loop for x in (list (1- (ash 1 64)) (1- (ash 1 63)) 0 1)
52cbe24a » Robert Brown
2009-12-28 The test that serializes a protocol buffer to octets now works.
172 do (vector-push-extend x (pb:r-uint64 p)))
5d1a4268 » Robert Brown
2008-09-30 Initial commit of Common Lisp protocol buffer project.
173
174 ;; write buffer to a file
175 (let ((size (pb:octet-size p)))
761c554b »
2011-09-12 Move the code in base to a new repository. It now lives in a system
176 (let* ((output-buffer (make-octet-vector size))
52cbe24a » Robert Brown
2009-12-28 The test that serializes a protocol buffer to octets now works.
177 (end (pb:serialize p output-buffer 0 size)))
2364038c »
2011-09-28 Convert tests to Stefil.
178 (is (= end size))
5d1a4268 » Robert Brown
2008-09-30 Initial commit of Common Lisp protocol buffer project.
179 (with-open-file (output-stream +test-file-name+ :direction :output
10fdac3a » Robert Brown
2010-01-14 New file message-test.lisp, containing Lisp versions of several C++
180 :if-exists :supersede :element-type 'unsigned-byte)
5d1a4268 » Robert Brown
2008-09-30 Initial commit of Common Lisp protocol buffer project.
181 (write-sequence output-buffer output-stream)))
182
183 ;; check against the golden data
184 (with-open-file (golden-input +golden-file-name+ :direction :input
10fdac3a » Robert Brown
2010-01-14 New file message-test.lisp, containing Lisp versions of several C++
185 :element-type 'unsigned-byte)
2364038c »
2011-09-28 Convert tests to Stefil.
186 (is (= (file-length golden-input) size))
5d1a4268 » Robert Brown
2008-09-30 Initial commit of Common Lisp protocol buffer project.
187 (with-open-file (test-input +test-file-name+ :direction :input
10fdac3a » Robert Brown
2010-01-14 New file message-test.lisp, containing Lisp versions of several C++
188 :element-type 'unsigned-byte)
2364038c »
2011-09-28 Convert tests to Stefil.
189 (is (= (file-length test-input) size))
761c554b »
2011-09-12 Move the code in base to a new repository. It now lives in a system
190 (let ((golden-buffer (make-octet-vector size))
191 (test-buffer (make-octet-vector size)))
5d1a4268 » Robert Brown
2008-09-30 Initial commit of Common Lisp protocol buffer project.
192 (read-sequence golden-buffer golden-input)
193 (read-sequence test-buffer test-input)
2364038c »
2011-09-28 Convert tests to Stefil.
194 (is (equalp golden-buffer test-buffer))))))
10fdac3a » Robert Brown
2010-01-14 New file message-test.lisp, containing Lisp versions of several C++
195
196 ;; clean up
197 (delete-file +test-file-name+)))
5d1a4268 » Robert Brown
2008-09-30 Initial commit of Common Lisp protocol buffer project.
198
199 (defun test-repeated (value golden)
200 (let ((golden-size (length golden)))
2364038c »
2011-09-28 Convert tests to Stefil.
201 (is (= (length value) golden-size))
5d1a4268 » Robert Brown
2008-09-30 Initial commit of Common Lisp protocol buffer project.
202 (loop for v across value
203 for g in golden
35bb363a »
2012-02-03 Generated protocol buffer code now lives in separate packages, the na…
204 do (cond ((stringp g) (is (string= (pb:string-value v) g)))
205 ((vectorp g)
206 (cond ((stringp (aref g 0))
207 (is (= (length v) (length g)))
208 (dotimes (i (length g))
209 (is (string= (pb:string-value (aref v i)) (aref g i)))))
210 (t (is (equalp v g)))))
211 (t (is (eql v g)))))))
5d1a4268 » Robert Brown
2008-09-30 Initial commit of Common Lisp protocol buffer project.
212
2364038c »
2011-09-28 Convert tests to Stefil.
213 (deftest test-pb-read ()
35bb363a »
2012-02-03 Generated protocol buffer code now lives in separate packages, the na…
214 (let ((p (make-instance 'pb:test1proto)))
5d1a4268 » Robert Brown
2008-09-30 Initial commit of Common Lisp protocol buffer project.
215 (with-open-file (golden-input +golden-file-name+ :direction :input
10fdac3a » Robert Brown
2010-01-14 New file message-test.lisp, containing Lisp versions of several C++
216 :element-type 'unsigned-byte)
5d1a4268 » Robert Brown
2008-09-30 Initial commit of Common Lisp protocol buffer project.
217 (let* ((size (file-length golden-input))
761c554b »
2011-09-12 Move the code in base to a new repository. It now lives in a system
218 (buffer (make-octet-vector size)))
5d1a4268 » Robert Brown
2008-09-30 Initial commit of Common Lisp protocol buffer project.
219 (read-sequence buffer golden-input)
2364038c »
2011-09-28 Convert tests to Stefil.
220 (is (= (pb:merge-from-array p buffer 0 size) size))))
5d1a4268 » Robert Brown
2008-09-30 Initial commit of Common Lisp protocol buffer project.
221
222 ;; unrepeated things
2364038c »
2011-09-28 Convert tests to Stefil.
223 (is (pb:has-o-a p))
224 (is (= (pb:o-a p) 20))
225 (is (not (pb:has-o-b p)))
226 (is (= (pb:u-int32 p) 20))
227 (is (= (pb:u-int64 p) -20))
228 (is (= (pb:u-uint64 p) 12345678900))
229 (is (= (pb:u-fixed32 p) 100))
230 (is (= (pb:u-fixed64 p) 12345678900))
231 (is (eq (pb:u-bool p) t))
232 (is (= (pb:u-float p) 3.14159f0))
233 (is (= (pb:u-double p) 3.14159265d0))
5d1a4268 » Robert Brown
2008-09-30 Initial commit of Common Lisp protocol buffer project.
234
235 ;; Lisp implementation omits "has" function for embedded messages.
2364038c »
2011-09-28 Convert tests to Stefil.
236 ;;(is (has-u-msg p))
237 (is (= (pb:foo (pb:u-msg p)) 12))
5d1a4268 » Robert Brown
2008-09-30 Initial commit of Common Lisp protocol buffer project.
238
239 ;; repeated things
52cbe24a » Robert Brown
2009-12-28 The test that serializes a protocol buffer to octets now works.
240 (test-repeated (pb:r-int32 p)
5d1a4268 » Robert Brown
2008-09-30 Initial commit of Common Lisp protocol buffer project.
241 (list -20 -30 (1- (ash 1 31)) (- (ash 1 31)) 1 0 -1))
52cbe24a » Robert Brown
2009-12-28 The test that serializes a protocol buffer to octets now works.
242 (test-repeated (pb:r-int64 p)
5d1a4268 » Robert Brown
2008-09-30 Initial commit of Common Lisp protocol buffer project.
243 (list 20 30 (1- (ash 1 63)) (- (ash 1 63)) 1 0 -1))
52cbe24a » Robert Brown
2009-12-28 The test that serializes a protocol buffer to octets now works.
244 (test-repeated (pb:r-uint64 p)
5d1a4268 » Robert Brown
2008-09-30 Initial commit of Common Lisp protocol buffer project.
245 (list 12345678900 98765432100
246 (1- (ash 1 64)) (1- (ash 1 63))
247 0 1))
52cbe24a » Robert Brown
2009-12-28 The test that serializes a protocol buffer to octets now works.
248 (test-repeated (pb:r-fixed32 p)
249 (list 12345 23456 #xffffffff (1- (ash 1 31)) 0 1))
250 (test-repeated (pb:r-fixed64 p)
251 (list 12345678900 98765432100 #xffffffffffffffff
252 (1- (ash 1 63)) 0 1))
253 (test-repeated (pb:r-bool p) '(nil t))
254 (test-repeated (pb:r-float p) '(1.5f0 -1.75f0))
255 (test-repeated (pb:r-double p) '(3.3d0 -1.2d0))
35bb363a »
2012-02-03 Generated protocol buffer code now lives in separate packages, the na…
256 (test-repeated (pb:r-string p) '("foo" "bar"))
257 (test-repeated (pb:r-vardata p) '("ping" "pong"))
5d1a4268 » Robert Brown
2008-09-30 Initial commit of Common Lisp protocol buffer project.
258
2364038c »
2011-09-28 Convert tests to Stefil.
259 (is (= (length (pb:r-msg p)) 2))
260 (is (= (pb:foo (aref (pb:r-msg p) 0)) 12))
261 (is (= (pb:foo (aref (pb:r-msg p) 1)) 13))
5d1a4268 » Robert Brown
2008-09-30 Initial commit of Common Lisp protocol buffer project.
262
263 ;; groups
35bb363a »
2012-02-03 Generated protocol buffer code now lives in separate packages, the na…
264 (is (= (length (pb:test-group1 p)) 1))
265 (is (= (pb:a (aref (pb:test-group1 p) 0)) 80))
5d1a4268 » Robert Brown
2008-09-30 Initial commit of Common Lisp protocol buffer project.
266
35bb363a »
2012-02-03 Generated protocol buffer code now lives in separate packages, the na…
267 (is (= (length (pb:test-group2 p)) 2))
268 (is (= (pb:b (aref (pb:test-group2 p) 0)) 100))
269 (is (= (pb:b (aref (pb:test-group2 p) 1)) 130))
5d1a4268 » Robert Brown
2008-09-30 Initial commit of Common Lisp protocol buffer project.
270
271 ;; default settings
2364038c »
2011-09-28 Convert tests to Stefil.
272 (is (= (pb:d-int32 p) 12))
35bb363a »
2012-02-03 Generated protocol buffer code now lives in separate packages, the na…
273 (verify-string-field (pb:d-string p) "foo")
2364038c »
2011-09-28 Convert tests to Stefil.
274 (is (eq (pb:d-bool p) t))))
5d1a4268 » Robert Brown
2008-09-30 Initial commit of Common Lisp protocol buffer project.
275
276 (defun parser-timing (iterations)
35bb363a »
2012-02-03 Generated protocol buffer code now lives in separate packages, the na…
277 (let ((src (make-instance 'pb:time-protocol)))
5d1a4268 » Robert Brown
2008-09-30 Initial commit of Common Lisp protocol buffer project.
278 (dotimes (i 1000)
35bb363a »
2012-02-03 Generated protocol buffer code now lives in separate packages, the na…
279 (let ((new (make-instance 'pb:time-protocol-g)))
5d1a4268 » Robert Brown
2008-09-30 Initial commit of Common Lisp protocol buffer project.
280 (setf (pb:v1 new) 100)
281 (setf (pb:v2 new) 80)
282 (vector-push-extend new (pb:g src))))
283
761c554b »
2011-09-12 Move the code in base to a new repository. It now lives in a system
284 (let* ((buffer (make-octet-vector 10000))
52cbe24a » Robert Brown
2009-12-28 The test that serializes a protocol buffer to octets now works.
285 ;; XXXXXXXXXX
286 (size (pb:serialize src buffer 0 10000)))
5d1a4268 » Robert Brown
2008-09-30 Initial commit of Common Lisp protocol buffer project.
287 (time (dotimes (i iterations)
35bb363a »
2012-02-03 Generated protocol buffer code now lives in separate packages, the na…
288 (let ((msg (make-instance 'pb:time-protocol)))
98203e7f » Robert Brown
2010-01-26 Update to the latest protocol buffer compiler, which generates code
289 (pb:merge-from-array msg buffer 0 size)))))))
5d1a4268 » Robert Brown
2008-09-30 Initial commit of Common Lisp protocol buffer project.
290
291 ;; XXXXXXXXXXXXXXXXXXXX use parser-timing here
292
2364038c »
2011-09-28 Convert tests to Stefil.
293 ;; (defun output-timing ())
294 ;; (defun test-copy-and-merge ())
295 ;; (defun auto-tests ())
296
297 ;; (defun test (&key
298 ;; (time-raw-parse nil)
299 ;; (time-auto-parse nil)
300 ;; (time-raw-output nil)
301 ;; (time-auto-output nil)
302 ;; (iterations 10000))
303 ;; (if (or time-raw-parse time-auto-parse)
304 ;; (parser-timing iterations)
305 ;; (if (or time-raw-output time-auto-output)
306 ;; (output-timing)
307 ;; (progn (correctness-tests)
308 ;; (test-pb-write)
309 ;; (test-pb-read)
310 ;; (test-copy-and-merge)
311 ;; ;; XXXX initialize random number generator ??
312 ;; (auto-tests)
313 ;; (print "PASS"))))
314 ;; (values))
5d1a4268 » Robert Brown
2008-09-30 Initial commit of Common Lisp protocol buffer project.
315
316 ;; XXXXXXXXXXXXXXXXXXXX add more test code here
Something went wrong with that request. Please try again.