Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
BTrees
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
BTrees
Commits
db4ea45e
Commit
db4ea45e
authored
Nov 11, 2012
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Overlooked.
parent
7b842129
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
82 additions
and
0 deletions
+82
-0
BTrees/tests/test_utils.py
BTrees/tests/test_utils.py
+82
-0
No files found.
BTrees/tests/test_utils.py
0 → 100644
View file @
db4ea45e
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
import
unittest
class
Test_non_negative
(
unittest
.
TestCase
):
def
_callFUT
(
self
,
int_val
):
from
BTrees.utils
import
non_negative
return
non_negative
(
int_val
)
def
test_w_big_negative
(
self
):
import
sys
self
.
assertEqual
(
self
.
_callFUT
(
-
sys
.
maxint
),
1
)
def
test_w_negative
(
self
):
import
sys
self
.
assertEqual
(
self
.
_callFUT
(
-
1
),
sys
.
maxint
)
def
test_w_zero
(
self
):
self
.
assertEqual
(
self
.
_callFUT
(
0
),
0
)
def
test_w_positive
(
self
):
self
.
assertEqual
(
self
.
_callFUT
(
1
),
1
)
def
test_w_big_positive
(
self
):
import
sys
self
.
assertEqual
(
self
.
_callFUT
(
sys
.
maxint
),
sys
.
maxint
)
class
Test_oid_repr
(
unittest
.
TestCase
):
def
_callFUT
(
self
,
oid
):
from
BTrees.utils
import
oid_repr
return
oid_repr
(
oid
)
def
test_w_non_strings
(
self
):
self
.
assertEqual
(
self
.
_callFUT
(
None
),
repr
(
None
))
self
.
assertEqual
(
self
.
_callFUT
(()),
repr
(()))
self
.
assertEqual
(
self
.
_callFUT
([]),
repr
([]))
self
.
assertEqual
(
self
.
_callFUT
({}),
repr
({}))
self
.
assertEqual
(
self
.
_callFUT
(
0
),
repr
(
0
))
def
test_w_short_strings
(
self
):
for
length
in
range
(
8
):
faux
=
'x'
*
length
self
.
assertEqual
(
self
.
_callFUT
(
faux
),
repr
(
faux
))
def
test_w_long_strings
(
self
):
for
length
in
range
(
9
,
1024
):
faux
=
'x'
*
length
self
.
assertEqual
(
self
.
_callFUT
(
faux
),
repr
(
faux
))
def
test_w_zero
(
self
):
self
.
assertEqual
(
self
.
_callFUT
(
'
\
0
\
0
\
0
\
0
\
0
\
0
\
0
\
0
'
),
'0x00'
)
def
test_w_one
(
self
):
self
.
assertEqual
(
self
.
_callFUT
(
'
\
0
\
0
\
0
\
0
\
0
\
0
\
0
\
1
'
),
'0x01'
)
def
test_w_even_length
(
self
):
self
.
assertEqual
(
self
.
_callFUT
(
'
\
0
\
0
\
0
\
0
\
0
\
0
\
xAB
\
xC4
'
),
'0xabc4'
)
def
test_w_odd_length
(
self
):
self
.
assertEqual
(
self
.
_callFUT
(
'
\
0
\
0
\
0
\
0
\
0
\
0
\
x0D
\
xEF
'
),
'0x0def'
)
def
test_suite
():
return
unittest
.
TestSuite
((
unittest
.
makeSuite
(
Test_non_negative
),
unittest
.
makeSuite
(
Test_oid_repr
),
))
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