Mercurial > core / lisp/lib/dat/tests.lisp
changeset 541: |
10c4bb778030 |
parent: |
c0fc6b87557f
|
child: |
b57066450cfa |
author: |
Richard Westhaver <ellis@rwest.io> |
date: |
Fri, 12 Jul 2024 22:33:57 -0400 |
permissions: |
-rw-r--r-- |
description: |
bit of parquet refactoring, properly generate slot types |
2 (:use :cl :std :rt :dat)) 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 (deftest parquet-basic () 151 (with-input-from-string 153 (with-output-to-string (s) 154 (dat/parquet::parquet-write-magic s))) 155 (dat/parquet::parquet-read-magic s))))