#lang scheme
(require
(prefix-in main: "main.ss")
(prefix-in vector: "converters/vector.ss")
(prefix-in general: "converters/general.ss"))
(require
(prefix-in log: (planet synx/log)))
(require
(only-in (planet vyzo/crypto/util) hex))
(require (planet schematics/schemeunit))
(define casts
'((("a" "b" "c") . #"0000000100000000000000190000000300000001000000016100000001620000000163")
(("http://aubaus suanoteuh" "aua aueaoue" "coocoocoo") . #"000000010000000000000019000000030000000100000017687474703a2f2f617562617573207375616e6f746575680000000c6175612020617565616f756500000009636f6f636f6f636f6f")
((1 2 3 4) . #"0000000100000000000000150000000400000001000000020001000000020002000000020003000000020004")
(((1 2) (3 4)) . #"00000002000000000000001500000002000000010000000200000001000000020001000000020002000000020003000000020004")
((80000 80001 80002 80003) . #"00000001000000000000001700000004000000010000000400013880000000040001388100000004000138820000000400013883")))
(define
tests
(test-suite
"vector"
(let ([c (main:connect #:dbname "pics" #:user "www" #:port 5433)])
(send c initialize)
(for-each
(λ (cast)
(check-equal? (hex (send c encode (send c divine (car cast)) (car cast)))
(cdr cast)))
casts))))
(define (find-casts l)
(let ([c (main:connect #:dbname "pics" #:user "www" #:port 5433)])
(send c initialize)
(display (format "what we want: SELECT encode(anyarray_send(ARRAY~a),'hex');~n"
(regexp-replace*
#rx"\\)"
(regexp-replace*
#rx"\\("
(regexp-replace*
#rx"\""
(regexp-replace* #rx" " (format "~s" l) ",")
"'")
"[")
"]")))
(display (format "what we get: ~a~n" (hex (send c encode (send c divine l) l))))))