Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
node-sqlite3
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
俞永鹏
node-sqlite3
Commits
4fb7b4a2
Commit
4fb7b4a2
authored
Aug 16, 2015
by
Benjamin Byholm
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix broken unicode test
parent
d5b59c31
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
9 deletions
+64
-9
unicode.test.js
test/unicode.test.js
+64
-9
No files found.
test/unicode.test.js
View file @
4fb7b4a2
var
sqlite3
=
require
(
'..'
);
var
assert
=
require
(
'assert'
);
function
randomString
()
{
var
str
=
''
;
for
(
var
i
=
Math
.
random
()
*
300
;
i
>
0
;
i
--
)
{
str
+=
String
.
fromCharCode
(
Math
.
floor
(
Math
.
random
()
*
65536
));
}
return
str
;
}
describe
(
'unicode'
,
function
()
{
var
db
;
var
first_values
=
[],
trailing_values
=
[],
chars
=
[],
subranges
=
new
Array
(
2
),
len
=
subranges
.
length
,
db
,
i
;
before
(
function
(
done
)
{
db
=
new
sqlite3
.
Database
(
':memory:'
,
done
);
});
for
(
i
=
0x20
;
i
<
0x80
;
i
++
)
{
first_values
.
push
(
i
);
}
for
(
i
=
0xc2
;
i
<
0xf0
;
i
++
)
{
first_values
.
push
(
i
);
}
for
(
i
=
0x80
;
i
<
0xc0
;
i
++
)
{
trailing_values
.
push
(
i
);
}
for
(
i
=
0
;
i
<
len
;
i
++
)
{
subranges
[
i
]
=
[];
}
for
(
i
=
0xa0
;
i
<
0xc0
;
i
++
)
{
subranges
[
0
].
push
(
i
);
}
for
(
i
=
0x80
;
i
<
0xa0
;
i
++
)
{
subranges
[
1
].
push
(
i
);
}
function
random_choice
(
arr
)
{
return
arr
[
Math
.
random
()
*
arr
.
length
|
0
];
}
function
random_utf8
()
{
var
first
=
random_choice
(
first_values
);
if
(
first
<
0x80
)
{
return
String
.
fromCharCode
(
first
);
}
else
if
(
first
<
0xe0
)
{
return
String
.
fromCharCode
((
first
&
0x1f
)
<<
0x6
|
random_choice
(
trailing_values
)
&
0x3f
);
}
else
if
(
first
==
0xe0
)
{
return
String
.
fromCharCode
(((
first
&
0xf
)
<<
0xc
)
|
((
random_choice
(
subranges
[
0
])
&
0x3f
)
<<
6
)
|
random_choice
(
trailing_values
)
&
0x3f
);
}
else
if
(
first
==
0xed
)
{
return
String
.
fromCharCode
(((
first
&
0xf
)
<<
0xc
)
|
((
random_choice
(
subranges
[
1
])
&
0x3f
)
<<
6
)
|
random_choice
(
trailing_values
)
&
0x3f
);
}
else
if
(
first
<
0xf0
)
{
return
String
.
fromCharCode
(((
first
&
0xf
)
<<
0xc
)
|
((
random_choice
(
trailing_values
)
&
0x3f
)
<<
6
)
|
random_choice
(
trailing_values
)
&
0x3f
);
}
}
function
randomString
()
{
var
str
=
''
,
i
;
for
(
i
=
Math
.
random
()
*
300
;
i
>
0
;
i
--
)
{
str
+=
random_utf8
();
}
return
str
;
}
// Generate random data.
var
data
=
[];
var
length
=
Math
.
floor
(
Math
.
random
()
*
1000
)
+
200
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment