Mercurial > core / lisp/lib/dat/tests.lisp
changeset 698: |
96958d3eb5b0 |
parent: |
4d34907c69eb
|
author: |
Richard Westhaver <ellis@rwest.io> |
date: |
Fri, 04 Oct 2024 22:04:59 -0400 |
permissions: |
-rw-r--r-- |
description: |
fixes |
2 (:use :cl :std :rt :dat :log)) 4 (in-package :dat/tests) 13 "Test Graphviz DOT functionality." 14 (let ((g1 (make-instance 'graph:graph))) 15 (graph:add-node g1 "foo") 16 (graph:add-node g1 :bar) 17 (graph:add-node g1 42) 18 (graph:add-edge g1 '("foo" :bar) "a") 19 (graph:add-edge g1 '(:bar 42) "b") 20 (graph:add-edge g1 '(42 "foo") "c") 21 (is (stringp (dat/dot::to-dot g1))) 22 (dat/dot::to-dot-file g1 "/tmp/test") 23 (is (probe-file "/tmp/test")) 24 (is (delete-file "/tmp/test")))) 27 "Test CSV functionality." 31 (with-output-to-string (str) 32 (dat/csv:write-csv-stream 34 #(#(1 2 3 4) #(2 3 4 5) #(3 4 5 6)))))))) 37 (let ((str (format nil "[~s,2,true,null]" "Hello, world!")) 38 (obj (list "Hello, world!" 2 t nil))) 39 (multiple-value-bind (res pos) (json-decode str) 42 (is (equal str (with-output-to-string (s) (json-encode obj s))))) 43 (let ((str2 "[1,2,3]")) 44 (is (equal '(1 2 3) (deserialize str2 :json :end (length str2)))) 45 (is (equal str2 (with-output-to-string (s) (serialize (list 1 2 3) :json :stream s)))))) 48 (is (equal "foo" (xml-node-name (xml-parse "<foo></foo>"))))) 51 "Tests based on https://github.com/toml-lang/toml-test" 65 (defparameter *arff-input* 66 "% 1. Title: Iris Plants Database 69 % (a) Creator: R.A. Fisher 70 % (b) Donor: Michael Marshall (MARSHALL%PLU@io.arc.nasa.gov) 71 % (c) Date: July, 1988 74 @ATTRIBUTE sepallength NUMERIC 75 @ATTRIBUTE sepalwidth NUMERIC 76 @ATTRIBUTE petallength NUMERIC 77 @ATTRIBUTE petalwidth NUMERIC 78 @ATTRIBUTE class {Iris-setosa,Iris-versicolor,Iris-virginica}") 81 (is (typep (parse-arff-string *arff-input*) 'arff))) 85 (defvar *sxp-test-long* "(edges-1 87 (1389.886593 1341.567282) 88 (1383.122623 1339.369530) 91 (1383.122623 1339.369530) 92 (1387.706464 1325.261939) 95 (1387.706464 1325.261939) 96 (1394.470360 1327.459664) 99 (1394.470360 1327.459664) 100 (1389.886593 1341.567282) 105 ( ( 1.1 2.2 ) (2.2 3.3) ) 106 ( ( 2.2 3.3 ) (3.3 3.3) ) 107 ( ( 3.3 3.3 ) (1.1 2.2) ) 108 ) ; end edges of triangle room 118 (if (= 4.0 4.0) (42)) 127 (defvar *sxp-test-short* "(FOO 'BAR `(\"test\" ,BAZ ,@QUX) 123 0.0123 1/3 `(,A1 ,A2))") 133 (is (formp "string")) 134 (is (formp (mapc #`(',a1) '(a)))) 137 (deftest sxp-string () 138 (let ((f (make-instance 'sxp))) 139 (is (formp (read-sxp-string f *sxp-test-short*))) 140 (is (equalp (read-from-string (write-sxp-string f)) (read-from-string *sxp-test-short*))))) 142 (deftest sxp-stream () 143 (let ((f (make-instance 'sxp))) 144 (with-input-from-string (s *sxp-test-long*) 145 (read-sxp-stream f s)) 146 (with-output-to-string (s) 147 (is (write-sxp-stream f s))))) 149 (defparameter *parquet-test-file* 151 (merge-pathnames "../../../.stash/alltypes_plain.parquet" 152 #.(asdf:system-source-directory :dat/tests)))) 153 ;; see also: https://github.com/apache/parquet-testing/blob/master/data/README.md 154 (deftest parquet-basic () 155 (when *parquet-test-file* 156 (with-open-file (st *parquet-test-file* :element-type '(unsigned-byte 8)) 157 (let ((footer (dat/parquet::parquet-read-footer st))) 159 'dat/parquet::parquet-file-meta-data)) 160 (trace! (slot-value footer 'dat/parquet::schema)) 161 (trace! (file-position st)) 162 (trace! (file-length st))))))