File: 25_blob.t

package info (click to toggle)
liborlite-perl 1.97-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 524 kB
  • sloc: perl: 3,693; sql: 97; makefile: 2
file content (71 lines) | stat: -rw-r--r-- 1,186 bytes parent folder | download | duplicates (4)
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/perl

# Tests for the unicode option

use strict;
BEGIN {
	$|  = 1;
	$^W = 1;
}
use Test::More;
use File::Spec::Functions ':ALL';
use t::lib::Test;





#####################################################################
# Set up for testing

plan tests => 5;

# Connect
my $file = test_db();
my $dbh  = create_ok(
	file    => catfile(qw{ t 25_blob.sql }),
	connect => [ "dbi:SQLite:$file" ],
);

# Create the test package
eval <<"END_PERL"; die $@ if $@;
package My;

use strict;
use ORLite {
	file => '$file',
};

1;
END_PERL





######################################################################
# Test round tripping of unicode objects

SCOPE: {
	my $smiley1 = My::Foo->create(
		name    => 'foo',
		content => "\001\012\015",
		notype  => "\000\001\012\015",
	);
	isa_ok( $smiley1, 'My::Foo' );

	# Known broken
	TODO: {
		local $TODO = "Known problems with BLOB types";

		my $len = My->selectrow_arrayref(
			'select length(name), length(content), length(notype) from foo',
		);
		is_deeply( $len, [ 3, 3, 4 ], 'Lengths ok' );
	}

	my $smiley2 = My::Foo->load($smiley1->id);
	isa_ok( $smiley2, 'My::Foo' );

	is_deeply( $smiley1, $smiley2, 'Round trip ok' );
}