fixed bug converting to boolean in db-mysql/mysql-sql.lisp - from github user Sectoid
[clsql.git] / tests / test-i18n.lisp
1 ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
4 ;;;;
5 ;;;; Name:    test-i18n.lisp
6 ;;;; Purpose: Tests for passing non-ascii encoded strings to db and back
7 ;;;; Author:  Nathan Bird & Kevin M. Rosenberg
8 ;;;; Created: Feb 2010
9 ;;;;
10 ;;;; This file is part of CLSQL.
11 ;;;;
12 ;;;; CLSQL users are granted the rights to distribute and use this software
13 ;;;; as governed by the terms of the Lisp Lesser GNU Public License
14 ;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL.
15 ;;;; *************************************************************************
16
17 (in-package #:clsql-tests)
18
19 (setq *rt-i18n*
20       '(
21
22 ;;; The point of these two is to require proper encoding support
23 ;;; UTF-8 for example can handle these easily.
24 ;; I show this as a 20char string and 27 bytes in utf-8
25 (deftest :basic/i18n/1
26  (let ((uffi:*default-foreign-encoding* :utf-8))
27    (first (query "SELECT 'Iñtërnâtiônàlizætiøn'"
28                  :flatp t :field-names nil)))
29  "Iñtërnâtiônàlizætiøn")
30
31 ;; the z in this one is even stronger
32 ;; I show this as a 20char string and 28 bytes in utf-8
33 (deftest :basic/i18n/2
34  (let ((uffi:*default-foreign-encoding* :utf-8))
35    (first (query "SELECT 'Iñtërnâtiônàližætiøn'"
36                  :flatp t :field-names nil)))
37  "Iñtërnâtiônàližætiøn")
38
39 (deftest :basic/i18n/big/1
40     (let ((test-string (with-output-to-string (str)
41                          (dotimes (n 250)
42                            (write-sequence "Iñtërnâtiônàližætiøn" str)))))
43       (with-dataset *ds-bigtext*
44         (clsql-sys:execute-command
45          (format nil
46                  "INSERT INTO testbigtext (a) VALUES ('~a')"
47                  test-string))
48         (let ((res (first (clsql:query "SELECT a from testbigtext" :flatp t :field-names nil))))
49           (assert (equal test-string res) (test-string res)
50                   "Returned internationalization string was incorrect. Test :basic/i18n/big/1")))))
51
52 ))