83753b4fc1294075bd76ed8b94db0151f9b21464
[umlisp.git] / tests / parse.lisp
1 ;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10; Package: umlisp -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
4 ;;;;
5 ;;;; Name:          parse.lisp
6 ;;;; Purpose:       Parsing tests for UMLisp
7 ;;;; Author:        Kevin M. Rosenberg
8 ;;;; Date Started:  May 2003
9 ;;;;
10 ;;;; $Id$
11 ;;;;
12 ;;;; This file, part of UMLisp, is
13 ;;;;    Copyright (c) 2000-2002 by Kevin M. Rosenberg, M.D.
14 ;;;;
15 ;;;; UMLisp users are granted the rights to distribute and use this software
16 ;;;; as governed by the terms of the GNU General Public License.
17 ;;;; *************************************************************************
18
19 (in-package #:umlisp-tests)
20
21 (eval-when (:compile-toplevel :load-toplevel :execute)
22   (import '(umlisp::*umls-files* umlisp::*umls-cols*)))
23
24 (setq *rt-parse*
25   '(
26     (deftest :parse/1
27         (umlisp::decompose-fil "abc")
28       "abc" nil)
29
30     (deftest :parse/2
31         (umlisp::decompose-fil "dir/abc")
32       "abc" "dir")
33
34     (deftest :parse/3
35         (umlisp::decompose-fil nil)
36       nil nil)
37
38     (deftest :parse/4
39         (umlisp::filename-to-tablename "test")
40       "test")
41
42     (deftest :parse/5
43         (umlisp::filename-to-tablename "TEST.AB.RRF")
44       "TEST_AB")))
45
46 ;; specific for UMLS2007AA
47 (when (probe-file (umlisp::umls-pathname "MRFILES.RRF"))
48   (umlisp::ensure-ucols+ufiles)
49   (setq
50    *rt-parse*
51    (append
52     *rt-parse*
53     '(
54       (deftest uparse.1 (length *umls-files*) 63)
55       (deftest uparse.2 (length *umls-cols*) 452)
56       (deftest uparse.3
57           (sort (mapcar #'u::col (umlisp::ucols (umlisp::find-ufile "MRCONSO.RRF")))
58            #'string<)
59         ("AUI" "CODE" "CUI" "CVF" "ISPREF" "KCUILRL" "KCUILUI" "KCUISUI" "KLUILRL"
60          "KPFENG" "KSUILRL" "LAT" "LUI" "SAB" "SAUI" "SCUI" "SDUI" "SRL" "STR" "STT"
61          "SUI" "SUPPRESS" "TS" "TTY"))
62       (deftest uparse.4
63           (equal
64            (sort (mapcar #'u::col (umlisp::ucols (umlisp::find-ufile "MRCONSO.RRF")))
65                  #'string<)
66            (sort (copy-seq (umlisp::fields (umlisp::find-ufile "MRCONSO.RRF")))
67                  #'string<))
68         t)
69       (deftest uparse.5
70           (sort
71            (umlisp::custom-colnames-for-filename "MRCONSO.RRF")
72            #'string<)
73         ("KCUILRL" "KCUILUI" "KCUISUI" "KLUILRL" "KPFENG" "KSUILRL"))
74       (deftest uparse.6
75           (compiled-function-p
76            (umlisp::custom-value-fun
77             (umlisp::find-ucol "KCUISUI" "MRCONSO.RRF")))
78         t)
79       ))))