File: 20-utf8.t

package info (click to toggle)
libdbd-cassandra-perl 0.57-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 196 kB
  • sloc: perl: 286; makefile: 2
file content (30 lines) | stat: -rw-r--r-- 909 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use 5.010;
use warnings;
use strict;
use DBI;
use Test::More;

unless ($ENV{CASSANDRA_HOST}) {
    plan skip_all => "CASSANDRA_HOST not set";
}

plan tests => 2;

my $tls= $ENV{CASSANDRA_TLS} // '';
my $port= $ENV{CASSANDRA_PORT} ? ";port=$ENV{CASSANDRA_PORT}" : "";
my $dbh= DBI->connect("dbi:Cassandra:host=$ENV{CASSANDRA_HOST};keyspace=dbd_cassandra_tests;read_timeout=1;connect_timeout=1;write_timeout=1;tls=$tls$port", $ENV{CASSANDRA_USER}, $ENV{CASSANDRA_AUTH}, {RaiseError => 1});
ok($dbh);

$dbh->do('create table if not exists test_utf8 (id bigint primary key, str varchar)');

my $test_string= "";
utf8::decode($test_string);
for (1..100) {
    $test_string .= chr(int(rand(30000)+1000));
}

$dbh->do("insert into test_utf8 (id, str) values (?,?)", undef, 1, $test_string);
my $row= $dbh->selectrow_arrayref('select str from test_utf8 where id=1');
ok($row->[0] eq $test_string);

$dbh->disconnect;